diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..c78b779 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore index 487047c..6288512 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ node_modules/ test/node_modules/ .idea/ -pavlov/ -index.html \ No newline at end of file +./pavlov +index.html diff --git a/PostalAdapter.md b/PostalAdapter.md new file mode 100644 index 0000000..7a10b38 --- /dev/null +++ b/PostalAdapter.md @@ -0,0 +1,76 @@ +# Postal Topology + + +## Map + exchange cartographer + topic api +#### Message Properties + name template + operation "map" + +## Apply + exchange cartographer + topic api +#### Message Properties + name template name + template template instance id + model object to base the render on + operation "apply" +### Responds With + exchange cartographer + topic render.{templateId} +#### Message Properties + template template instance id + markup the generated DOM + operation "render" + +## Add + exchange cartographer + topic api +### Message + template the template instance id + id the fully qualified id of the list control to add to + model object to create the new item template from + operation "add" +### Responds With + exchange cartographer + topic render.{templateId} +#### Message Properties + template template instance id + parent the fully qualified id for the parent + markup the generated DOM for the new item + operation "add" + +## Update + exchange cartographer + topic api +#### Message Properties + template the template instance id + id the fully qualified id of the control to update + model object to update the control template with + operation "update" +### RespondsWith + exchange cartographer + topic render.{templateId} +#### Message Properties + template template instance id + id the fully qualified id of the item + markup the generated DOM for the new item + operation "update" + +## Append Resolver + exchange cartographer + topic api +#### Message Properties + order "append" + operation "resolver" + resolver callback in the form of function( name, onSuccess, onFailure ) + +## Prepend Resolver + exchange cartographer + topic api +#### Message Properties + order "prepend" + operation "resolver" + resolver callback in the form of function( name, onSuccess, onFailure ) + template template instance id \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..ce4f9b4 --- /dev/null +++ b/README.md @@ -0,0 +1,66 @@ +# Cartographer +Cartographer is an HTML templating engine that works with plain HTML and simple JSON. It does this by inferring intention based on the structure of the markup and JSON. Cartographer will never place the generated markup on the page, it hands it back to the provided callback. + +Though Cartographer's performance should be sufficient for most applications, several trade-offs were made in order to make the advanced features (not provided by the majority of other template engines) possible. + +## Philosophy +I wanted to create a templating engine that would compliment more complex, asynchronous applications in the browser. Cartographer's APIs are built to provide responses to user provided callbacks. It has been designed to be complimentary with other OSS JS Libraries that encourage decoupled application design: (infuser, postal and machina specifically). + +## Advanced Features +* Generate partial templates +* Nest templates +* Specify external templates in the markup or the model +* Generate new markup for new collection items +* Fully qualified namespacing for elements that map to the model +* A flexible way to define custom sources for templates +* Integration with Postal for messaging + * all API methods supported through Postal topography +* Configurable element identifier + * The default attribute used to identify the element for Cartographer is "data-id" +* Configurable template attribute + * The default attribute used to specify a replacement template is "data-template" + +## Concepts +Cartographer creates named templates based on the name of the template source. If your source is an external file, the name of the template is the name of the file. If the source of the template is a DOM element then the data-template property would match the template name. + +Once the template has been created, it can be used to create instances which must be uniquely identified (more on why later). The rendered instance is give fully qualified, hierarchical namespaces for all of the controls that had a data-id (mapped to a model property). + +Partial renders can be done as an add or update. Adding is intended to support rendered a specific item template for a collection when new elements are added to the model that produced the original render. Updates allow you to regenerate the template, starting at any level, in order to get updated markup for the section of the template that should be reproduced. + +## API + +### Map - cartographer.map(templateName) +Creates a template from a named HTML source that will be used to generate markup from JSON. + +### Apply - cartographer.render( templateName, templateId, model, onMarkup ) +Renders the templateName and assigns the rendered instance templateId. The template instance id becomes the top of the fqn for all controls in the rendered instance. onMarkup is a function with 3 arguments: template id, markup and operation ( included for integration purposes ). + +### Add - cartographer.add( templateId, containerControlFqn, model, onMarkup ) +Adding creates a new set of markup for an existing template / model collection. The containerControlFqn is the fully qualified name of the containing list control. The other arguments are like the 'render' call. + +### Update - cartographer.update( templateId, targetFqn, model, onMarkup ) +Updating creates a new render at any level in the template hierarchy. The targetFqn is the level of the DOM template where the render should begin. + +### Adding Template Resolvers - cartographer.resolver.appendSource|prependSource( resolverFunction ) +Cartographer looks for the HTML using the template name. It searches its resolvers, in order, and by default has resolvers for in-page and infuser. If you glance at template-source.coffee under the spec folder, you'll see that it's trivial to create these and provide markup from any source you like. + +You can add a resolver and control when it will be checked by either appending or prepending your resolver to the list. + +The resolver has the signature function(name, success, fail). It uses the name argument to search for an HTML template based on the name and calls success with the HTML when it's found or fail when something tanks. + +### Changing The Element Id Attribute + +By default, Cartographer uses 'data-id' as the means to identify and correlate a DOM element to your model. This can be changed as follows: + + cartographer.config.elementIdentifier + +## Examples +Currently, there aren't a lot of great examples but the unit tests actually show all of the features. + +## Dependencies + +Cartographer has a number of dependencies which you must either include on your page OR have available via some AMD system (I've only tested it against Require at this point). + +If you happen to use require, here are the path aliases it expects: + + 'jQuery', 'underscore', 'infuser', 'DOMBuilder' \ No newline at end of file diff --git a/build.json b/build.json index 27b55c5..113db1d 100644 --- a/build.json +++ b/build.json @@ -5,8 +5,19 @@ "ext": "ext", "lint": {}, "uglify": {}, - "wrap":{ - "prefix": "(function(context) {", - "suffix": "})(window);" + "gzip": {}, + "hosts": { + "/": "./html", + "/play": "./play", + "/spec": "./spec" + }, + "finalize": { + "header-file": "./header.txt" + }, + "name": { + "amd.js": "cartographer.amd.js", + "browser.js": "cartographer.js", + "adapter.js": "postal.adapter.js", + "adapter.amd.js": "postal.adapter.amd.js" } } \ No newline at end of file diff --git a/ext/infuser-0.2.0.js b/ext/infuser-0.2.0.js new file mode 100644 index 0000000..7f59bc0 --- /dev/null +++ b/ext/infuser-0.2.0.js @@ -0,0 +1,188 @@ +define(['jquery', 'trafficcop'],function($,trafficcop) { // You might need to set up a config for require.js for the jquery/trafficcop dependencies to work, or replace it with an absolute path + /* + infuser.js + Author: Jim Cowart + License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) + Version 0.2.0 + */ + var hashStorage = { + templates: {}, + + storeTemplate: function(templateId, templateContent) { + this.templates[templateId] = templateContent; + }, + + getTemplate: function(templateId) { + return this.templates[templateId]; + }, + + purge: function() { + this.templates = {}; + } + }; + var scriptStorage = { + templateIds: [], + storeTemplate: function(templateId, templateContent) { + var node = document.getElementById(templateId); + if(node === null) { + this.templateIds.push(templateId); + node = document.createElement("script"); + node.type = "text/html"; + node.id = templateId; + document.body.appendChild(node); + } + node.text = templateContent; + }, + + getTemplate: function(templateId) { + return document.getElementById(templateId); + }, + + purge: function() { + for(var i = 0; i < this.templateIds.length; i++) { + document.body.removeChild(document.getElementById(this.templateIds[i])); + } + this.templateIds = []; + } + }; + var errorHtml = "
The template {TEMPLATEID} could not be loaded. {STATUS}
", + returnErrorTemplate = function(status, templateId, templatePath) { + return errorHtml.replace('{STATUS}', status).replace('{TEMPLATEID}', templateId).replace('{TEMPLATEURL}', templatePath); + }, + errors = []; + var helpers = { + getTemplatePath: function(templateOptions) { + var templateFile = templateOptions.templatePrefix + templateOptions.templateId + templateOptions.templateSuffix; + return templateOptions.templateUrl === undefined || templateOptions.templateUrl === "" ? + templateFile : templateOptions.templateUrl + "/" + templateFile; + }, + templateGetSuccess: function(templateId, callback) { + return function(response) { + infuser.store.storeTemplate(templateId, response); + callback(infuser.store.getTemplate(templateId)); + }; + }, + templateGetError: function(templateId, templatePath, callback) { + return function(exception) { + if($.inArray(templateId, errors) === -1) { + errors.push(templateId); + } + var templateHtml = returnErrorTemplate("HTTP Status code: " + exception.status, templateId, templatePath); + infuser.store.storeTemplate(templateId, templateHtml); + callback(infuser.store.getTemplate(templateId)); + }; + }, + getAjaxOptions: function(templateOptions) { + + } + }, + infuserOptions = ['target','loadingTemplate','postRender','preRender','render','bindingInstruction','useLoadingTemplate','model','templateUrl','templateSuffix','templatePrefix','']; + var infuser = { + storageOptions: { + hash: hashStorage, + script: scriptStorage + }, + + store: hashStorage, + + defaults: { + // Template name conventions + templateUrl: "", + templateSuffix: ".html", + templatePrefix: "", + // AJAX Options + ajax: { + "async": true, + "dataType": "html", + "type": "GET" + }, + // infuse() specific options - NOT used for "get" or "getSync" + target: function(templateId) { return "#" + templateId }, // DEFAULT MAPPING + loadingTemplate: { + content: '
Loading...
', + transitionIn: function(target, content) { + var tgt = $(target); + tgt.hide(); + tgt.html(content); + tgt.fadeIn(); + }, + transitionOut: function(target) { + $(target).html(""); + } + }, + postRender: function(targetElement) { }, // NO_OP effectively by default + preRender: function(targetElement, template) { }, // NO_OP effectively by default + render: function(target, template) { + var tgt = $(target); + if(tgt.children().length === 0) { + tgt.append($(template)); + } + else { + tgt.children().replaceWith($(template)); + } + }, + bindingInstruction: function(template, model) { return template; }, // NO_OP effectively by default + useLoadingTemplate: true // true/false + }, + + get: function(options, callback) { + var templateOptions = $.extend({}, infuser.defaults, (typeof options === "object" ? options : { templateId: options })), + template; + templateOptions.ajax.url = helpers.getTemplatePath(templateOptions); + template = infuser.store.getTemplate(templateOptions.ajax.url); + if(!template || $.inArray(templateOptions.ajax.url, errors) !== -1) { + templateOptions.ajax.success = helpers.templateGetSuccess(templateOptions.ajax.url, callback); + templateOptions.ajax.error = helpers.templateGetError(templateOptions.templateId, templateOptions.ajax.url, callback); + $.trafficCop(templateOptions.ajax); + } + else { + callback(template); + } + }, + + getSync: function(options) { + var templateOptions = $.extend({}, infuser.defaults, (typeof options === "object" ? options : { templateId: options }), { ajax: { async: false } }), + template, + templateHtml; + templateOptions.ajax.url = helpers.getTemplatePath(templateOptions); + template = infuser.store.getTemplate(templateOptions.ajax.url); + if(!template || $.inArray(templateOptions.ajax.url, errors) !== -1) { + templateHtml = null; + templateOptions.ajax.success = function(response) { templateHtml = response; }; + templateOptions.ajax.error = function(exception) { + if($.inArray(templateOptions.ajax.url) === -1) { + errors.push(templateOptions.ajax.url); + } + templateHtml = returnErrorTemplate("HTTP Status code: exception.status", templateOptions.templateId, templateOptions.ajax.url); + }; + $.ajax(templateOptions.ajax); + if(templateHtml === null) { + templateHtml = returnErrorTemplate("An unknown error occurred.", templateOptions.templateId, templateOptions.ajax.url); + } + else { + infuser.store.storeTemplate(templateOptions.ajax.url, templateHtml); + template = infuser.store.getTemplate(templateOptions.ajax.url); + } + } + return template; + }, + + infuse: function(templateId, renderOptions) { + var templateOptions = $.extend({}, infuser.defaults, (typeof templateId === "object" ? templateId : renderOptions), (typeof templateId === "string" ? { templateId: templateId } : undefined )), + targetElement = typeof templateOptions.target === 'function' ? templateOptions.target(templateId) : templateOptions.target; + if(templateOptions.useLoadingTemplate) { + templateOptions.loadingTemplate.transitionIn(targetElement, templateOptions.loadingTemplate.content); + } + infuser.get(templateOptions, function(template) { + var _template = template; + templateOptions.preRender(targetElement, _template); + _template = templateOptions.bindingInstruction(_template, templateOptions.model); + if(templateOptions.useLoadingTemplate) { + templateOptions.loadingTemplate.transitionOut(targetElement); + } + templateOptions.render(targetElement, _template); + templateOptions.postRender(targetElement); + }); + } + }; + return infuser; }); \ No newline at end of file diff --git a/ext/infuser.js b/ext/infuser.js new file mode 100644 index 0000000..d3772b9 --- /dev/null +++ b/ext/infuser.js @@ -0,0 +1,188 @@ +(function($, global, undefined) { + /* + infuser.js + Author: Jim Cowart + License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) + Version 0.2.0 + */ + var hashStorage = { + templates: {}, + + storeTemplate: function(templateId, templateContent) { + this.templates[templateId] = templateContent; + }, + + getTemplate: function(templateId) { + return this.templates[templateId]; + }, + + purge: function() { + this.templates = {}; + } + }; + var scriptStorage = { + templateIds: [], + storeTemplate: function(templateId, templateContent) { + var node = document.getElementById(templateId); + if(node === null) { + this.templateIds.push(templateId); + node = document.createElement("script"); + node.type = "text/html"; + node.id = templateId; + document.body.appendChild(node); + } + node.text = templateContent; + }, + + getTemplate: function(templateId) { + return document.getElementById(templateId); + }, + + purge: function() { + for(var i = 0; i < this.templateIds.length; i++) { + document.body.removeChild(document.getElementById(this.templateIds[i])); + } + this.templateIds = []; + } + }; + var errorHtml = "
The template {TEMPLATEID} could not be loaded. {STATUS}
", + returnErrorTemplate = function(status, templateId, templatePath) { + return errorHtml.replace('{STATUS}', status).replace('{TEMPLATEID}', templateId).replace('{TEMPLATEURL}', templatePath); + }, + errors = []; + var helpers = { + getTemplatePath: function(templateOptions) { + var templateFile = templateOptions.templatePrefix + templateOptions.templateId + templateOptions.templateSuffix; + return templateOptions.templateUrl === undefined || templateOptions.templateUrl === "" ? + templateFile : templateOptions.templateUrl + "/" + templateFile; + }, + templateGetSuccess: function(templateId, callback) { + return function(response) { + infuser.store.storeTemplate(templateId, response); + callback(infuser.store.getTemplate(templateId)); + }; + }, + templateGetError: function(templateId, templatePath, callback) { + return function(exception) { + if($.inArray(templateId, errors) === -1) { + errors.push(templateId); + } + var templateHtml = returnErrorTemplate("HTTP Status code: " + exception.status, templateId, templatePath); + infuser.store.storeTemplate(templateId, templateHtml); + callback(infuser.store.getTemplate(templateId)); + }; + }, + getAjaxOptions: function(templateOptions) { + + } + }, + infuserOptions = ['target','loadingTemplate','postRender','preRender','render','bindingInstruction','useLoadingTemplate','model','templateUrl','templateSuffix','templatePrefix','']; + var infuser = { + storageOptions: { + hash: hashStorage, + script: scriptStorage + }, + + store: hashStorage, + + defaults: { + // Template name conventions + templateUrl: "", + templateSuffix: ".html", + templatePrefix: "", + // AJAX Options + ajax: { + "async": true, + "dataType": "html", + "type": "GET" + }, + // infuse() specific options - NOT used for "get" or "getSync" + target: function(templateId) { return "#" + templateId }, // DEFAULT MAPPING + loadingTemplate: { + content: '
Loading...
', + transitionIn: function(target, content) { + var tgt = $(target); + tgt.hide(); + tgt.html(content); + tgt.fadeIn(); + }, + transitionOut: function(target) { + $(target).html(""); + } + }, + postRender: function(targetElement) { }, // NO_OP effectively by default + preRender: function(targetElement, template) { }, // NO_OP effectively by default + render: function(target, template) { + var tgt = $(target); + if(tgt.children().length === 0) { + tgt.append($(template)); + } + else { + tgt.children().replaceWith($(template)); + } + }, + bindingInstruction: function(template, model) { return template; }, // NO_OP effectively by default + useLoadingTemplate: true // true/false + }, + + get: function(options, callback) { + var templateOptions = $.extend({}, infuser.defaults, (typeof options === "object" ? options : { templateId: options })), + template; + templateOptions.ajax.url = helpers.getTemplatePath(templateOptions); + template = infuser.store.getTemplate(templateOptions.ajax.url); + if(!template || $.inArray(templateOptions.ajax.url, errors) !== -1) { + templateOptions.ajax.success = helpers.templateGetSuccess(templateOptions.ajax.url, callback); + templateOptions.ajax.error = helpers.templateGetError(templateOptions.templateId, templateOptions.ajax.url, callback); + $.trafficCop(templateOptions.ajax); + } + else { + callback(template); + } + }, + + getSync: function(options) { + var templateOptions = $.extend({}, infuser.defaults, (typeof options === "object" ? options : { templateId: options }), { ajax: { async: false } }), + template, + templateHtml; + templateOptions.ajax.url = helpers.getTemplatePath(templateOptions); + template = infuser.store.getTemplate(templateOptions.ajax.url); + if(!template || $.inArray(templateOptions.ajax.url, errors) !== -1) { + templateHtml = null; + templateOptions.ajax.success = function(response) { templateHtml = response; }; + templateOptions.ajax.error = function(exception) { + if($.inArray(templateOptions.ajax.url) === -1) { + errors.push(templateOptions.ajax.url); + } + templateHtml = returnErrorTemplate("HTTP Status code: exception.status", templateOptions.templateId, templateOptions.ajax.url); + }; + $.ajax(templateOptions.ajax); + if(templateHtml === null) { + templateHtml = returnErrorTemplate("An unknown error occurred.", templateOptions.templateId, templateOptions.ajax.url); + } + else { + infuser.store.storeTemplate(templateOptions.ajax.url, templateHtml); + template = infuser.store.getTemplate(templateOptions.ajax.url); + } + } + return template; + }, + + infuse: function(templateId, renderOptions) { + var templateOptions = $.extend({}, infuser.defaults, (typeof templateId === "object" ? templateId : renderOptions), (typeof templateId === "string" ? { templateId: templateId } : undefined )), + targetElement = typeof templateOptions.target === 'function' ? templateOptions.target(templateId) : templateOptions.target; + if(templateOptions.useLoadingTemplate) { + templateOptions.loadingTemplate.transitionIn(targetElement, templateOptions.loadingTemplate.content); + } + infuser.get(templateOptions, function(template) { + var _template = template; + templateOptions.preRender(targetElement, _template); + _template = templateOptions.bindingInstruction(_template, templateOptions.model); + if(templateOptions.useLoadingTemplate) { + templateOptions.loadingTemplate.transitionOut(targetElement); + } + templateOptions.render(targetElement, _template); + templateOptions.postRender(targetElement); + }); + } + }; + global.infuser = infuser; })(jQuery, window); \ No newline at end of file diff --git a/ext/jquery-1.6.4.min.js b/ext/jquery-1.6.4.min.js deleted file mode 100644 index 628ed9b..0000000 --- a/ext/jquery-1.6.4.min.js +++ /dev/null @@ -1,4 +0,0 @@ -/*! jQuery v1.6.4 http://jquery.com/ | http://jquery.org/license */ -(function(a,b){function cu(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cr(a){if(!cg[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){ch||(ch=c.createElement("iframe"),ch.frameBorder=ch.width=ch.height=0),b.appendChild(ch);if(!ci||!ch.createElement)ci=(ch.contentWindow||ch.contentDocument).document,ci.write((c.compatMode==="CSS1Compat"?"":"")+""),ci.close();d=ci.createElement(a),ci.body.appendChild(d),e=f.css(d,"display"),b.removeChild(ch)}cg[a]=e}return cg[a]}function cq(a,b){var c={};f.each(cm.concat.apply([],cm.slice(0,b)),function(){c[this]=a});return c}function cp(){cn=b}function co(){setTimeout(cp,0);return cn=f.now()}function cf(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ce(){try{return new a.XMLHttpRequest}catch(b){}}function b$(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){c!=="border"&&f.each(e,function(){c||(d-=parseFloat(f.css(a,"padding"+this))||0),c==="margin"?d+=parseFloat(f.css(a,c+this))||0:d-=parseFloat(f.css(a,"border"+this+"Width"))||0});return d+"px"}d=bv(a,b,b);if(d<0||d==null)d=a.style[b]||0;d=parseFloat(d)||0,c&&f.each(e,function(){d+=parseFloat(f.css(a,"padding"+this))||0,c!=="padding"&&(d+=parseFloat(f.css(a,"border"+this+"Width"))||0),c==="margin"&&(d+=parseFloat(f.css(a,c+this))||0)});return d+"px"}function bl(a,b){b.src?f.ajax({url:b.src,async:!1,dataType:"script"}):f.globalEval((b.text||b.textContent||b.innerHTML||"").replace(bd,"/*$0*/")),b.parentNode&&b.parentNode.removeChild(b)}function bk(a){f.nodeName(a,"input")?bj(a):"getElementsByTagName"in a&&f.grep(a.getElementsByTagName("input"),bj)}function bj(a){if(a.type==="checkbox"||a.type==="radio")a.defaultChecked=a.checked}function bi(a){return"getElementsByTagName"in a?a.getElementsByTagName("*"):"querySelectorAll"in a?a.querySelectorAll("*"):[]}function bh(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(f.expando)}}function bg(a,b){if(b.nodeType===1&&!!f.hasData(a)){var c=f.expando,d=f.data(a),e=f.data(b,d);if(d=d[c]){var g=d.events;e=e[c]=f.extend({},d);if(g){delete e.handle,e.events={};for(var h in g)for(var i=0,j=g[h].length;i=0===c})}function U(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function M(a,b){return(a&&a!=="*"?a+".":"")+b.replace(y,"`").replace(z,"&")}function L(a){var b,c,d,e,g,h,i,j,k,l,m,n,o,p=[],q=[],r=f._data(this,"events");if(!(a.liveFired===this||!r||!r.live||a.target.disabled||a.button&&a.type==="click")){a.namespace&&(n=new RegExp("(^|\\.)"+a.namespace.split(".").join("\\.(?:.*\\.)?")+"(\\.|$)")),a.liveFired=this;var s=r.live.slice(0);for(i=0;ic)break;a.currentTarget=e.elem,a.data=e.handleObj.data,a.handleObj=e.handleObj,o=e.handleObj.origHandler.apply(e.elem,arguments);if(o===!1||a.isPropagationStopped()){c=e.level,o===!1&&(b=!1);if(a.isImmediatePropagationStopped())break}}return b}}function J(a,c,d){var e=f.extend({},d[0]);e.type=a,e.originalEvent={},e.liveFired=b,f.event.handle.call(c,e),e.isDefaultPrevented()&&d[0].preventDefault()}function D(){return!0}function C(){return!1}function m(a,c,d){var e=c+"defer",g=c+"queue",h=c+"mark",i=f.data(a,e,b,!0);i&&(d==="queue"||!f.data(a,g,b,!0))&&(d==="mark"||!f.data(a,h,b,!0))&&setTimeout(function(){!f.data(a,g,b,!0)&&!f.data(a,h,b,!0)&&(f.removeData(a,e,!0),i.resolve())},0)}function l(a){for(var b in a)if(b!=="toJSON")return!1;return!0}function k(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(j,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNaN(d)?i.test(d)?f.parseJSON(d):d:parseFloat(d)}catch(g){}f.data(a,c,d)}else d=b}return d}var c=a.document,d=a.navigator,e=a.location,f=function(){function K(){if(!e.isReady){try{c.documentElement.doScroll("left")}catch(a){setTimeout(K,1);return}e.ready()}}var e=function(a,b){return new e.fn.init(a,b,h)},f=a.jQuery,g=a.$,h,i=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/\d/,n=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,o=/^[\],:{}\s]*$/,p=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,q=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,r=/(?:^|:|,)(?:\s*\[)+/g,s=/(webkit)[ \/]([\w.]+)/,t=/(opera)(?:.*version)?[ \/]([\w.]+)/,u=/(msie) ([\w.]+)/,v=/(mozilla)(?:.*? rv:([\w.]+))?/,w=/-([a-z]|[0-9])/ig,x=/^-ms-/,y=function(a,b){return(b+"").toUpperCase()},z=d.userAgent,A,B,C,D=Object.prototype.toString,E=Object.prototype.hasOwnProperty,F=Array.prototype.push,G=Array.prototype.slice,H=String.prototype.trim,I=Array.prototype.indexOf,J={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=n.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.6.4",length:0,size:function(){return this.length},toArray:function(){return G.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 d=this.constructor();e.isArray(a)?F.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),B.done(a);return this},eq:function(a){return 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(G.apply(this,arguments),"slice",G.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:F,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,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"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;B.resolveWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").unbind("ready")}},bindReady:function(){if(!B){B=e._Deferred();if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",C,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",C),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&K()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.type(a)==="array"},isWindow:function(a){return a&&typeof a=="object"&&"setInterval"in a},isNaN:function(a){return a==null||!m.test(a)||isNaN(a)},type:function(a){return a==null?String(a):J[D.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!E.call(a,"constructor")&&!E.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||E.call(a,d)},isEmptyObject:function(a){for(var b in a)return!1;return!0},error:function(a){throw a},parseJSON:function(b){if(typeof b!="string"||!b)return null;b=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(o.test(b.replace(p,"@").replace(q,"]").replace(r,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(x,"ms-").replace(w,y)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?h.call(arguments,0):c,--e||g.resolveWith(g,h.call(b,0))}}var b=arguments,c=0,d=b.length,e=d,g=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred();if(d>1){for(;c
a",d=a.getElementsByTagName("*"),e=a.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=a.getElementsByTagName("input")[0],k={leadingWhitespace:a.firstChild.nodeType===3,tbody:!a.getElementsByTagName("tbody").length,htmlSerialize:!!a.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55$/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:a.className!=="t",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,k.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,k.optDisabled=!h.disabled;try{delete a.test}catch(v){k.deleteExpando=!1}!a.addEventListener&&a.attachEvent&&a.fireEvent&&(a.attachEvent("onclick",function(){k.noCloneEvent=!1}),a.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),k.radioValue=i.value==="t",i.setAttribute("checked","checked"),a.appendChild(i),l=c.createDocumentFragment(),l.appendChild(a.firstChild),k.checkClone=l.cloneNode(!0).cloneNode(!0).lastChild.checked,a.innerHTML="",a.style.width=a.style.paddingLeft="1px",m=c.getElementsByTagName("body")[0],o=c.createElement(m?"div":"body"),p={visibility:"hidden",width:0,height:0,border:0,margin:0,background:"none"},m&&f.extend(p,{position:"absolute",left:"-1000px",top:"-1000px"});for(t in p)o.style[t]=p[t];o.appendChild(a),n=m||b,n.insertBefore(o,n.firstChild),k.appendChecked=i.checked,k.boxModel=a.offsetWidth===2,"zoom"in a.style&&(a.style.display="inline",a.style.zoom=1,k.inlineBlockNeedsLayout=a.offsetWidth===2,a.style.display="",a.innerHTML="
",k.shrinkWrapBlocks=a.offsetWidth!==2),a.innerHTML="
t
",q=a.getElementsByTagName("td"),u=q[0].offsetHeight===0,q[0].style.display="",q[1].style.display="none",k.reliableHiddenOffsets=u&&q[0].offsetHeight===0,a.innerHTML="",c.defaultView&&c.defaultView.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",a.appendChild(j),k.reliableMarginRight=(parseInt((c.defaultView.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0),o.innerHTML="",n.removeChild(o);if(a.attachEvent)for(t in{submit:1,change:1,focusin:1})s="on"+t,u=s in a,u||(a.setAttribute(s,"return;"),u=typeof a[s]=="function"),k[t+"Bubbles"]=u;o=l=g=h=m=j=a=i=null;return k}(),f.boxModel=f.support.boxModel;var i=/^(?:\{.*\}|\[.*\])$/,j=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!l(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i=f.expando,j=typeof c=="string",k=a.nodeType,l=k?f.cache:a,m=k?a[f.expando]:a[f.expando]&&f.expando;if((!m||e&&m&&l[m]&&!l[m][i])&&j&&d===b)return;m||(k?a[f.expando]=m=++f.uuid:m=f.expando),l[m]||(l[m]={},k||(l[m].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?l[m][i]=f.extend(l[m][i],c):l[m]=f.extend(l[m],c);g=l[m],e&&(g[i]||(g[i]={}),g=g[i]),d!==b&&(g[f.camelCase(c)]=d);if(c==="events"&&!g[c])return g[i]&&g[i].events;j?(h=g[c],h==null&&(h=g[f.camelCase(c)])):h=g;return h}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e=f.expando,g=a.nodeType,h=g?f.cache:a,i=g?a[f.expando]:f.expando;if(!h[i])return;if(b){d=c?h[i][e]:h[i];if(d){d[b]||(b=f.camelCase(b)),delete d[b];if(!l(d))return}}if(c){delete h[i][e];if(!l(h[i]))return}var j=h[i][e];f.support.deleteExpando||!h.setInterval?delete h[i]:h[i]=null,j?(h[i]={},g||(h[i].toJSON=f.noop),h[i][e]=j):g&&(f.support.deleteExpando?delete a[f.expando]:a.removeAttribute?a.removeAttribute(f.expando):a[f.expando]=null)}},_data:function(a,b,c){return f.data(a,b,c,!0)},acceptData:function(a){if(a.nodeName){var b=f.noData[a.nodeName.toLowerCase()];if(b)return b!==!0&&a.getAttribute("classid")===b}return!0}}),f.fn.extend({data:function(a,c){var d=null;if(typeof a=="undefined"){if(this.length){d=f.data(this[0]);if(this[0].nodeType===1){var e=this[0].attributes,g;for(var h=0,i=e.length;h-1)return!0;return!1},val:function(a){var c,d,e=this[0];if(!arguments.length){if(e){c=f.valHooks[e.nodeName.toLowerCase()]||f.valHooks[e.type];if(c&&"get"in c&&(d=c.get(e,"value"))!==b)return d;d=e.value;return typeof d=="string"?d.replace(p,""):d==null?"":d}return b}var g=f.isFunction(a);return this.each(function(d){var e=f(this),h;if(this.nodeType===1){g?h=a.call(this,d,e.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}}),f.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=a.selectedIndex,d=[],e=a.options,g=a.type==="select-one";if(c<0)return null;for(var h=g?c:0,i=g?c+1:e.length;h=0}),c.length||(a.selectedIndex=-1);return c}}},attrFn:{val:!0,css:!0,html:!0,text:!0,data:!0,width:!0,height:!0,offset:!0},attrFix:{tabindex:"tabIndex"},attr:function(a,c,d,e){var g=a.nodeType;if(!a||g===3||g===8||g===2)return b;if(e&&c in f.attrFn)return f(a)[c](d);if(!("getAttribute"in a))return f.prop(a,c,d);var h,i,j=g!==1||!f.isXMLDoc(a);j&&(c=f.attrFix[c]||c,i=f.attrHooks[c],i||(t.test(c)?i=v:u&&(i=u)));if(d!==b){if(d===null){f.removeAttr(a,c);return b}if(i&&"set"in i&&j&&(h=i.set(a,d,c))!==b)return h;a.setAttribute(c,""+d);return d}if(i&&"get"in i&&j&&(h=i.get(a,c))!==null)return h;h=a.getAttribute(c);return h===null?b:h},removeAttr:function(a,b){var c;a.nodeType===1&&(b=f.attrFix[b]||b,f.attr(a,b,""),a.removeAttribute(b),t.test(b)&&(c=f.propFix[b]||b)in a&&(a[c]=!1))},attrHooks:{type:{set:function(a,b){if(q.test(a.nodeName)&&a.parentNode)f.error("type property can't be changed");else if(!f.support.radioValue&&b==="radio"&&f.nodeName(a,"input")){var c=a.value;a.setAttribute("type",b),c&&(a.value=c);return b}}},value:{get:function(a,b){if(u&&f.nodeName(a,"button"))return u.get(a,b);return b in a?a.value:null},set:function(a,b,c){if(u&&f.nodeName(a,"button"))return u.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=a.nodeType;if(!a||e===3||e===8||e===2)return b;var g,h,i=e!==1||!f.isXMLDoc(a);i&&(c=f.propFix[c]||c,h=f.propHooks[c]);return d!==b?h&&"set"in h&&(g=h.set(a,d,c))!==b?g:a[c]=d:h&&"get"in h&&(g=h.get(a,c))!==null?g:a[c]},propHooks:{tabIndex:{get:function(a){var c=a.getAttributeNode("tabindex");return c&&c.specified?parseInt(c.value,10):r.test(a.nodeName)||s.test(a.nodeName)&&a.href?0:b}}}}),f.attrHooks.tabIndex=f.propHooks.tabIndex,v={get:function(a,c){var d;return f.prop(a,c)===!0||(d=a.getAttributeNode(c))&&d.nodeValue!==!1?c.toLowerCase():b},set:function(a,b,c){var d;b===!1?f.removeAttr(a,c):(d=f.propFix[c]||c,d in a&&(a[d]=!0),a.setAttribute(c,c.toLowerCase()));return c}},f.support.getSetAttribute||(u=f.valHooks.button={get:function(a,c){var d;d=a.getAttributeNode(c);return d&&d.nodeValue!==""?d.nodeValue:b},set:function(a,b,d){var e=a.getAttributeNode(d);e||(e=c.createAttribute(d),a.setAttributeNode(e));return e.nodeValue=b+""}},f.each(["width","height"],function(a,b){f.attrHooks[b]=f.extend(f.attrHooks[b],{set:function(a,c){if(c===""){a.setAttribute(b,"auto");return c}}})})),f.support.hrefNormalized||f.each(["href","src","width","height"],function(a,c){f.attrHooks[c]=f.extend(f.attrHooks[c],{get:function(a){var d=a.getAttribute(c,2);return d===null?b:d}})}),f.support.style||(f.attrHooks.style={get:function(a){return a.style.cssText.toLowerCase()||b},set:function(a,b){return a.style.cssText=""+b}}),f.support.optSelected||(f.propHooks.selected=f.extend(f.propHooks.selected,{get:function(a){var b=a.parentNode;b&&(b.selectedIndex,b.parentNode&&b.parentNode.selectedIndex);return null}})),f.support.checkOn||f.each(["radio","checkbox"],function(){f.valHooks[this]={get:function(a){return a.getAttribute("value")===null?"on":a.value}}}),f.each(["radio","checkbox"],function(){f.valHooks[this]=f.extend(f.valHooks[this],{set:function(a,b){if(f.isArray(b))return a.checked=f.inArray(f(a).val(),b)>=0}})});var w=/\.(.*)$/,x=/^(?:textarea|input|select)$/i,y=/\./g,z=/ /g,A=/[^\w\s.|`]/g,B=function(a){return a.replace(A,"\\$&")};f.event={add:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){if(d===!1)d=C;else if(!d)return;var g,h;d.handler&&(g=d,d=g.handler),d.guid||(d.guid=f.guid++);var i=f._data(a);if(!i)return;var j=i.events,k=i.handle;j||(i.events=j={}),k||(i.handle=k=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.handle.apply(k.elem,arguments):b}),k.elem=a,c=c.split(" ");var l,m=0,n;while(l=c[m++]){h=g?f.extend({},g):{handler:d,data:e},l.indexOf(".")>-1?(n=l.split("."),l=n.shift(),h.namespace=n.slice(0).sort().join(".")):(n=[],h.namespace=""),h.type=l,h.guid||(h.guid=d.guid);var o=j[l],p=f.event.special[l]||{};if(!o){o=j[l]=[];if(!p.setup||p.setup.call(a,e,n,k)===!1)a.addEventListener?a.addEventListener(l,k,!1):a.attachEvent&&a.attachEvent("on"+l,k)}p.add&&(p.add.call(a,h),h.handler.guid||(h.handler.guid=d.guid)),o.push(h),f.event.global[l]=!0}a=null}},global:{},remove:function(a,c,d,e){if(a.nodeType!==3&&a.nodeType!==8){d===!1&&(d=C);var g,h,i,j,k=0,l,m,n,o,p,q,r,s=f.hasData(a)&&f._data(a),t=s&&s.events;if(!s||!t)return;c&&c.type&&(d=c.handler,c=c.type);if(!c||typeof c=="string"&&c.charAt(0)==="."){c=c||"";for(h in t)f.event.remove(a,h+c);return}c=c.split(" ");while(h=c[k++]){r=h,q=null,l=h.indexOf(".")<0,m=[],l||(m=h.split("."),h=m.shift(),n=new RegExp("(^|\\.)"+f.map(m.slice(0).sort(),B).join("\\.(?:.*\\.)?")+"(\\.|$)")),p=t[h];if(!p)continue;if(!d){for(j=0;j=0&&(h=h.slice(0,-1),j=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if(!!e&&!f.event.customEvent[h]||!!f.event.global[h]){c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.exclusive=j,c.namespace=i.join("."),c.namespace_re=new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)");if(g||!e)c.preventDefault(),c.stopPropagation();if(!e){f.each(f.cache,function(){var a=f.expando,b=this[a];b&&b.events&&b.events[h]&&f.event.trigger(c,d,b.handle.elem)});return}if(e.nodeType===3||e.nodeType===8)return;c.result=b,c.target=e,d=d!=null?f.makeArray(d):[],d.unshift(c);var k=e,l=h.indexOf(":")<0?"on"+h:"";do{var m=f._data(k,"handle");c.currentTarget=k,m&&m.apply(k,d),l&&f.acceptData(k)&&k[l]&&k[l].apply(k,d)===!1&&(c.result=!1,c.preventDefault()),k=k.parentNode||k.ownerDocument||k===c.target.ownerDocument&&a}while(k&&!c.isPropagationStopped());if(!c.isDefaultPrevented()){var n,o=f.event.special[h]||{};if((!o._default||o._default.call(e.ownerDocument,c)===!1)&&(h!=="click"||!f.nodeName(e,"a"))&&f.acceptData(e)){try{l&&e[h]&&(n=e[l],n&&(e[l]=null),f.event.triggered=h,e[h]())}catch(p){}n&&(e[l]=n),f.event.triggered=b}}return c.result}},handle:function(c){c=f.event.fix(c||a.event);var d=((f._data(this,"events")||{})[c.type]||[]).slice(0),e=!c.exclusive&&!c.namespace,g=Array.prototype.slice.call(arguments,0);g[0]=c,c.currentTarget=this;for(var h=0,i=d.length;h-1?f.map(a.options,function(a){return a.selected}).join("-"):"":f.nodeName(a,"select")&&(c=a.selectedIndex);return c},I=function(c){var d=c.target,e,g;if(!!x.test(d.nodeName)&&!d.readOnly){e=f._data(d,"_change_data"),g=H(d),(c.type!=="focusout"||d.type!=="radio")&&f._data(d,"_change_data",g);if(e===b||g===e)return;if(e!=null||g)c.type="change",c.liveFired=b,f.event.trigger(c,arguments[1],d)}};f.event.special.change={filters:{focusout:I,beforedeactivate:I,click:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(c==="radio"||c==="checkbox"||f.nodeName(b,"select"))&&I.call(this,a)},keydown:function(a){var b=a.target,c=f.nodeName(b,"input")?b.type:"";(a.keyCode===13&&!f.nodeName(b,"textarea")||a.keyCode===32&&(c==="checkbox"||c==="radio")||c==="select-multiple")&&I.call(this,a)},beforeactivate:function(a){var b=a.target;f._data(b,"_change_data",H(b))}},setup:function(a,b){if(this.type==="file")return!1;for(var c in G)f.event.add(this,c+".specialChange",G[c]);return x.test(this.nodeName)},teardown:function(a){f.event.remove(this,".specialChange");return x.test(this.nodeName)}},G=f.event.special.change.filters,G.focus=G.beforeactivate}f.support.focusinBubbles||f.each({focus:"focusin",blur:"focusout"},function(a,b){function e(a){var c=f.event.fix(a);c.type=b,c.originalEvent={},f.event.trigger(c,null,c.target),c.isDefaultPrevented()&&a.preventDefault()}var d=0;f.event.special[b]={setup:function(){d++===0&&c.addEventListener(a,e,!0)},teardown:function(){--d===0&&c.removeEventListener(a,e,!0)}}}),f.each(["bind","one"],function(a,c){f.fn[c]=function(a,d,e){var g;if(typeof a=="object"){for(var h in a)this[c](h,d,a[h],e);return this}if(arguments.length===2||d===!1)e=d,d=b;c==="one"?(g=function(a){f(this).unbind(a,g);return e.apply(this,arguments)},g.guid=e.guid||f.guid++):g=e;if(a==="unload"&&c!=="one")this.one(a,d,e);else for(var i=0,j=this.length;i0?this.bind(b,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0)}),function(){function u(a,b,c,d,e,f){for(var g=0,h=d.length;g0){j=i;break}}i=i[a]}d[g]=j}}}function t(a,b,c,d,e,f){for(var g=0,h=d.length;g+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d=0,e=Object.prototype.toString,g=!1,h=!0,i=/\\/g,j=/\W/;[0,0].sort(function(){h=!1;return 0});var k=function(b,d,f,g){f=f||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return f;var i,j,n,o,q,r,s,t,u=!0,w=k.isXML(d),x=[],y=b;do{a.exec(""),i=a.exec(y);if(i){y=i[3],x.push(i[1]);if(i[2]){o=i[3];break}}}while(i);if(x.length>1&&m.exec(b))if(x.length===2&&l.relative[x[0]])j=v(x[0]+x[1],d);else{j=l.relative[x[0]]?[d]:k(x.shift(),d);while(x.length)b=x.shift(),l.relative[b]&&(b+=x.shift()),j=v(b,j)}else{!g&&x.length>1&&d.nodeType===9&&!w&&l.match.ID.test(x[0])&&!l.match.ID.test(x[x.length-1])&&(q=k.find(x.shift(),d,w),d=q.expr?k.filter(q.expr,q.set)[0]:q.set[0]);if(d){q=g?{expr:x.pop(),set:p(g)}:k.find(x.pop(),x.length===1&&(x[0]==="~"||x[0]==="+")&&d.parentNode?d.parentNode:d,w),j=q.expr?k.filter(q.expr,q.set):q.set,x.length>0?n=p(j):u=!1;while(x.length)r=x.pop(),s=r,l.relative[r]?s=x.pop():r="",s==null&&(s=d),l.relative[r](n,s,w)}else n=x=[]}n||(n=j),n||k.error(r||b);if(e.call(n)==="[object Array]")if(!u)f.push.apply(f,n);else if(d&&d.nodeType===1)for(t=0;n[t]!=null;t++)n[t]&&(n[t]===!0||n[t].nodeType===1&&k.contains(d,n[t]))&&f.push(j[t]);else for(t=0;n[t]!=null;t++)n[t]&&n[t].nodeType===1&&f.push(j[t]);else p(n,f);o&&(k(o,h,f,g),k.uniqueSort(f));return f};k.uniqueSort=function(a){if(r){g=h,a.sort(r);if(g)for(var b=1;b0},k.find=function(a,b,c){var d;if(!a)return[];for(var e=0,f=l.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!j.test(b)){b=b.toLowerCase();for(;e=0)?c||d.push(h):c&&(b[g]=!1));return!1},ID:function(a){return a[1].replace(i,"")},TAG:function(a,b){return a[1].replace(i,"").toLowerCase()},CHILD:function(a){if(a[1]==="nth"){a[2]||k.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]&&k.error(a[0]);a[0]=d++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(i,"");!f&&l.attrMap[g]&&(a[1]=l.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(i,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=k(b[3],null,null,c);else{var g=k.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(l.match.POS.test(b[0])||l.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return 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){a.parentNode&&a.parentNode.selectedIndex;return a.selected===!0},parent:function(a){return!!a.firstChild},empty:function(a){return!a.firstChild},has:function(a,b,c){return!!k(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 bc[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=l.filters[e];if(f)return f(a,c,b,d);if(e==="contains")return(a.textContent||a.innerText||k.getText([a])||"").indexOf(b[3])>=0;if(e==="not"){var g=b[3];for(var h=0,i=g.length;h=0}},ID:function(a,b){return a.nodeType===1&&a.getAttribute("id")===b},TAG:function(a,b){return b==="*"&&a.nodeType===1||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=l.attrHandle[c]?l.attrHandle[c](a):a[c]!=null?a[c]:a.getAttribute(c),e=d+"",f=b[2],g=b[4];return d==null?f==="!=":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=l.setFilters[e];if(f)return f(a,c,b,d)}}},m=l.match.POS,n=function(a,b){return"\\"+(b-0+1)};for(var o in l.match)l.match[o]=new RegExp(l.match[o].source+/(?![^\[]*\])(?![^\(]*\))/.source),l.leftMatch[o]=new RegExp(/(^(?:.|\r|\n)*?)/.source+l.match[o].source.replace(/\\(\d+)/g,n));var p=function(a,b){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.documentElement.childNodes,0)[0].nodeType}catch(q){p=function(a,b){var c=0,d=b||[];if(e.call(a)==="[object Array]")Array.prototype.push.apply(d,a);else if(typeof a.length=="number")for(var f=a.length;c",e.insertBefore(a,e.firstChild),c.getElementById(d)&&(l.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:[]}},l.filter.ID=function(a,b){var c=typeof a.getAttributeNode!="undefined"&&a.getAttributeNode("id");return a.nodeType===1&&c&&c.nodeValue===b}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.createComment("")),a.getElementsByTagName("*").length>0&&(l.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.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(l.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=k,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){k=function(b,e,f,g){e=e||c;if(!g&&!k.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return p(e.getElementsByTagName(b),f);if(h[2]&&l.find.CLASS&&e.getElementsByClassName)return p(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return p([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return p([],f);if(i.id===h[3])return p([i],f)}try{return p(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var m=e,n=e.getAttribute("id"),o=n||d,q=e.parentNode,r=/^\s*[+~]/.test(b);n?o=o.replace(/'/g,"\\$&"):e.setAttribute("id",o),r&&q&&(e=e.parentNode);try{if(!r||q)return p(e.querySelectorAll("[id='"+o+"'] "+b),f)}catch(s){}finally{n||m.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)k[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}k.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!k.isXML(a))try{if(e||!l.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return k(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";if(!!a.getElementsByClassName&&a.getElementsByClassName("e").length!==0){a.lastChild.className="e";if(a.getElementsByClassName("e").length===1)return;l.order.splice(1,0,"CLASS"),l.find.CLASS=function(a,b,c){if(typeof b.getElementsByClassName!="undefined"&&!c)return b.getElementsByClassName(a[1])},a=null}}(),c.documentElement.contains?k.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.documentElement.compareDocumentPosition?k.contains=function(a,b){return!!(a.compareDocumentPosition(b)&16)}:k.contains=function(){return!1},k.isXML=function(a){var b=(a?a.ownerDocument||a:0).documentElement;return b?b.nodeName!=="HTML":!1};var v=function(a,b){var c,d=[],e="",f=b.nodeType?[b]:b;while(c=l.match.PSEUDO.exec(a))e+=c[0],a=a.replace(l.match.PSEUDO,"");a=l.relative[a]?a+"*":a;for(var g=0,h=f.length;g0)for(h=g;h0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h,i,j={},k=1;if(g&&a.length){for(d=0,e=a.length;d-1:f(g).is(h))&&c.push({selector:i,elem:g,level:k});g=g.parentNode,k++}}return c}var l=S.test(a)||typeof a!="string"?f(a,b||this.context):0;for(d=0,e=this.length;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(U(c[0])||U(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c),g=R.call(arguments);N.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!T[a]?f.unique(e):e,(this.length>1||P.test(d))&&O.test(a)&&(e=e.reverse());return this.pushStack(e,a,g.join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[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 W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]};be.optgroup=be.option,be.tbody=be.tfoot=be.colgroup=be.caption=be.thead,be.th=be.td,f.support.htmlSerialize||(be._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(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){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){return this.each(function(){f(this).wrapAll(a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(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=f(arguments[0]);a.push.apply(a,this.toArray());return 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);a.push.apply(a,f(arguments[0]).toArray());return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.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&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!be[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d=a.cloneNode(!0),e,g,h;if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bh(a,d),e=bi(a),g=bi(d);for(h=0;e[h];++h)g[h]&&bh(e[h],g[h])}if(b){bg(a,d);if(c){e=bi(a),g=bi(d);for(h=0;e[h];++h)bg(e[h],g[h])}}e=g=null;return d},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=be[l]||be._default,n=m[0],o=b.createElement("div");o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return bn.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=f.isNaN(b)?"":"alpha(opacity="+b*100+")",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bm,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bm.test(g)?g.replace(bm,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bv(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bw=function(a,c){var d,e,g;c=c.replace(bo,"-$1").toLowerCase();if(!(e=a.ownerDocument.defaultView))return b;if(g=e.getComputedStyle(a,null))d=g.getPropertyValue(c),d===""&&!f.contains(a.ownerDocument.documentElement,a)&&(d=f.style(a,c));return d}),c.documentElement.currentStyle&&(bx=function(a,b){var c,d=a.currentStyle&&a.currentStyle[b],e=a.runtimeStyle&&a.runtimeStyle[b],f=a.style;!bp.test(d)&&bq.test(d)&&(c=f.left,e&&(a.runtimeStyle.left=a.currentStyle.left),f.left=b==="fontSize"?"1em":d||0,d=f.pixelLeft+"px",f.left=c,e&&(a.runtimeStyle.left=e));return d===""?"auto":d}),bv=bw||bx,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bz=/%20/g,bA=/\[\]$/,bB=/\r?\n/g,bC=/#.*$/,bD=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bE=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bF=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bG=/^(?:GET|HEAD)$/,bH=/^\/\//,bI=/\?/,bJ=/)<[^<]*)*<\/script>/gi,bK=/^(?:select|textarea)/i,bL=/\s+/,bM=/([?&])_=[^&]*/,bN=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bO=f.fn.load,bP={},bQ={},bR,bS,bT=["*/"]+["*"];try{bR=e.href}catch(bU){bR=c.createElement("a"),bR.href="",bR=bR.href}bS=bN.exec(bR.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bO)return bO.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bJ,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bK.test(this.nodeName)||bE.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bB,"\r\n")}}):{name:b.name,value:c.replace(bB,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.bind(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?bX(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),bX(a,b);return a},ajaxSettings:{url:bR,isLocal:bF.test(bS[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","*":bT},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bV(bP),ajaxTransport:bV(bQ),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?bZ(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=b$(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.resolveWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f._Deferred(),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bD.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.done,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bC,"").replace(bH,bS[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bL),d.crossDomain==null&&(r=bN.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bS[1]&&r[2]==bS[2]&&(r[3]||(r[1]==="http:"?80:443))==(bS[3]||(bS[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),bW(bP,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bG.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bI.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bM,"$1_="+x);d.url=y+(y===d.url?(bI.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bT+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=bW(bQ,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){s<2?w(-1,z):f.error(z)}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)bY(g,a[g],c,e);return d.join("&").replace(bz,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var b_=f.now(),ca=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+b_++}}),f.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&&(ca.test(b.url)||e&&ca.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ca,l),b.url===j&&(e&&(k=k.replace(ca,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cb=a.ActiveXObject?function(){for(var a in cd)cd[a](0,1)}:!1,cc=0,cd;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ce()||cf()}:ce,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cb&&delete cd[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cc,cb&&(cd||(cd={},f(a).unload(cb)),cd[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var cg={},ch,ci,cj=/^(?:toggle|show|hide)$/,ck=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cl,cm=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cn;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cq("show",3),a,b,c);for(var g=0,h=this.length;g=e.duration+this.startTime){this.now=this.end,this.pos=this.state=1,this.update(),e.animatedProperties[this.prop]=!0;for(g in e.animatedProperties)e.animatedProperties[g]!==!0&&(c=!1);if(c){e.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){d.style["overflow"+b]=e.overflow[a]}),e.hide&&f(d).hide();if(e.hide||e.show)for(var i in e.animatedProperties)f.style(d,i,e.orig[i]);e.complete.call(d)}return!1}e.duration==Infinity?this.now=b:(h=b-this.startTime,this.state=h/e.duration,this.pos=f.easing[e.animatedProperties[this.prop]](this.state,h,0,1,e.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){for(var a=f.timers,b=0;b
";f.extend(b.style,{position:"absolute",top:0,left:0,margin:0,border:0,width:"1px",height:"1px",visibility:"hidden"}),b.innerHTML=j,a.insertBefore(b,a.firstChild),d=b.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,this.doesNotAddBorder=e.offsetTop!==5,this.doesAddBorderForTableAndCells=h.offsetTop===5,e.style.position="fixed",e.style.top="20px",this.supportsFixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",this.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,this.doesNotIncludeMarginInBodyOffset=a.offsetTop!==i,a.removeChild(b),f.offset.initialize=f.noop},bodyOffset:function(a){var b=a.offsetTop,c=a.offsetLeft;f.offset.initialize(),f.offset.doesNotIncludeMarginInBodyOffset&&(b+=parseFloat(f.css(a,"marginTop"))||0,c+=parseFloat(f.css(a,"marginLeft"))||0);return{top:b,left:c}},setOffset:function(a,b,c){var d=f.css(a,"position");d==="static"&&(a.style.position="relative");var e=f(a),g=e.offset(),h=f.css(a,"top"),i=f.css(a,"left"),j=(d==="absolute"||d==="fixed")&&f.inArray("auto",[h,i])>-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=ct.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!ct.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cu(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cu(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a&&a.style?parseFloat(f.css(a,d,"padding")):null},f.fn["outer"+c]=function(a){var b=this[0];return b&&b.style?parseFloat(f.css(b,d,a?"margin":"border")):null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}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 i=f.css(e,d),j=parseFloat(i);return f.isNaN(j)?i:j}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f})(window); \ No newline at end of file diff --git a/ext/jquery-1.7.1.js b/ext/jquery-1.7.1.js new file mode 100644 index 0000000..ee02337 --- /dev/null +++ b/ext/jquery-1.7.1.js @@ -0,0 +1,4 @@ +/*! jQuery v1.7.1 jquery.com | jquery.org/license */ +(function(a,b){function cy(a){return f.isWindow(a)?a:a.nodeType===9?a.defaultView||a.parentWindow:!1}function cv(a){if(!ck[a]){var b=c.body,d=f("<"+a+">").appendTo(b),e=d.css("display");d.remove();if(e==="none"||e===""){cl||(cl=c.createElement("iframe"),cl.frameBorder=cl.width=cl.height=0),b.appendChild(cl);if(!cm||!cl.createElement)cm=(cl.contentWindow||cl.contentDocument).document,cm.write((c.compatMode==="CSS1Compat"?"":"")+""),cm.close();d=cm.createElement(a),cm.body.appendChild(d),e=f.css(d,"display"),b.removeChild(cl)}ck[a]=e}return ck[a]}function cu(a,b){var c={};f.each(cq.concat.apply([],cq.slice(0,b)),function(){c[this]=a});return c}function ct(){cr=b}function cs(){setTimeout(ct,0);return cr=f.now()}function cj(){try{return new a.ActiveXObject("Microsoft.XMLHTTP")}catch(b){}}function ci(){try{return new a.XMLHttpRequest}catch(b){}}function cc(a,c){a.dataFilter&&(c=a.dataFilter(c,a.dataType));var d=a.dataTypes,e={},g,h,i=d.length,j,k=d[0],l,m,n,o,p;for(g=1;g0){if(c!=="border")for(;g=0===c})}function S(a){return!a||!a.parentNode||a.parentNode.nodeType===11}function K(){return!0}function J(){return!1}function n(a,b,c){var d=b+"defer",e=b+"queue",g=b+"mark",h=f._data(a,d);h&&(c==="queue"||!f._data(a,e))&&(c==="mark"||!f._data(a,g))&&setTimeout(function(){!f._data(a,e)&&!f._data(a,g)&&(f.removeData(a,d,!0),h.fire())},0)}function m(a){for(var b in a){if(b==="data"&&f.isEmptyObject(a[b]))continue;if(b!=="toJSON")return!1}return!0}function l(a,c,d){if(d===b&&a.nodeType===1){var e="data-"+c.replace(k,"-$1").toLowerCase();d=a.getAttribute(e);if(typeof d=="string"){try{d=d==="true"?!0:d==="false"?!1:d==="null"?null:f.isNumeric(d)?parseFloat(d):j.test(d)?f.parseJSON(d):d}catch(g){}f.data(a,c,d)}else d=b}return d}function h(a){var b=g[a]={},c,d;a=a.split(/\s+/);for(c=0,d=a.length;c)[^>]*$|#([\w\-]*)$)/,j=/\S/,k=/^\s+/,l=/\s+$/,m=/^<(\w+)\s*\/?>(?:<\/\1>)?$/,n=/^[\],:{}\s]*$/,o=/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,p=/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,q=/(?:^|:|,)(?:\s*\[)+/g,r=/(webkit)[ \/]([\w.]+)/,s=/(opera)(?:.*version)?[ \/]([\w.]+)/,t=/(msie) ([\w.]+)/,u=/(mozilla)(?:.*? rv:([\w.]+))?/,v=/-([a-z]|[0-9])/ig,w=/^-ms-/,x=function(a,b){return(b+"").toUpperCase()},y=d.userAgent,z,A,B,C=Object.prototype.toString,D=Object.prototype.hasOwnProperty,E=Array.prototype.push,F=Array.prototype.slice,G=String.prototype.trim,H=Array.prototype.indexOf,I={};e.fn=e.prototype={constructor:e,init:function(a,d,f){var g,h,j,k;if(!a)return this;if(a.nodeType){this.context=this[0]=a,this.length=1;return this}if(a==="body"&&!d&&c.body){this.context=c,this[0]=c.body,this.selector=a,this.length=1;return this}if(typeof a=="string"){a.charAt(0)!=="<"||a.charAt(a.length-1)!==">"||a.length<3?g=i.exec(a):g=[null,a,null];if(g&&(g[1]||!d)){if(g[1]){d=d instanceof e?d[0]:d,k=d?d.ownerDocument||d:c,j=m.exec(a),j?e.isPlainObject(d)?(a=[c.createElement(j[1])],e.fn.attr.call(a,d,!0)):a=[k.createElement(j[1])]:(j=e.buildFragment([g[1]],[k]),a=(j.cacheable?e.clone(j.fragment):j.fragment).childNodes);return e.merge(this,a)}h=c.getElementById(g[2]);if(h&&h.parentNode){if(h.id!==g[2])return f.find(a);this.length=1,this[0]=h}this.context=c,this.selector=a;return this}return!d||d.jquery?(d||f).find(a):this.constructor(d).find(a)}if(e.isFunction(a))return f.ready(a);a.selector!==b&&(this.selector=a.selector,this.context=a.context);return e.makeArray(a,this)},selector:"",jquery:"1.7.1",length:0,size:function(){return this.length},toArray:function(){return F.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 d=this.constructor();e.isArray(a)?E.apply(d,a):e.merge(d,a),d.prevObject=this,d.context=this.context,b==="find"?d.selector=this.selector+(this.selector?" ":"")+c:b&&(d.selector=this.selector+"."+b+"("+c+")");return d},each:function(a,b){return e.each(this,a,b)},ready:function(a){e.bindReady(),A.add(a);return this},eq:function(a){a=+a;return 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(F.apply(this,arguments),"slice",F.call(arguments).join(","))},map:function(a){return this.pushStack(e.map(this,function(b,c){return a.call(b,c,b)}))},end:function(){return this.prevObject||this.constructor(null)},push:E,sort:[].sort,splice:[].splice},e.fn.init.prototype=e.fn,e.extend=e.fn.extend=function(){var a,c,d,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"&&!e.isFunction(i)&&(i={}),k===j&&(i=this,--j);for(;j0)return;A.fireWith(c,[e]),e.fn.trigger&&e(c).trigger("ready").off("ready")}},bindReady:function(){if(!A){A=e.Callbacks("once memory");if(c.readyState==="complete")return setTimeout(e.ready,1);if(c.addEventListener)c.addEventListener("DOMContentLoaded",B,!1),a.addEventListener("load",e.ready,!1);else if(c.attachEvent){c.attachEvent("onreadystatechange",B),a.attachEvent("onload",e.ready);var b=!1;try{b=a.frameElement==null}catch(d){}c.documentElement.doScroll&&b&&J()}}},isFunction:function(a){return e.type(a)==="function"},isArray:Array.isArray||function(a){return e.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):I[C.call(a)]||"object"},isPlainObject:function(a){if(!a||e.type(a)!=="object"||a.nodeType||e.isWindow(a))return!1;try{if(a.constructor&&!D.call(a,"constructor")&&!D.call(a.constructor.prototype,"isPrototypeOf"))return!1}catch(c){return!1}var d;for(d in a);return d===b||D.call(a,d)},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=e.trim(b);if(a.JSON&&a.JSON.parse)return a.JSON.parse(b);if(n.test(b.replace(o,"@").replace(p,"]").replace(q,"")))return(new Function("return "+b))();e.error("Invalid JSON: "+b)},parseXML:function(c){var d,f;try{a.DOMParser?(f=new DOMParser,d=f.parseFromString(c,"text/xml")):(d=new ActiveXObject("Microsoft.XMLDOM"),d.async="false",d.loadXML(c))}catch(g){d=b}(!d||!d.documentElement||d.getElementsByTagName("parsererror").length)&&e.error("Invalid XML: "+c);return d},noop:function(){},globalEval:function(b){b&&j.test(b)&&(a.execScript||function(b){a.eval.call(a,b)})(b)},camelCase:function(a){return a.replace(w,"ms-").replace(v,x)},nodeName:function(a,b){return a.nodeName&&a.nodeName.toUpperCase()===b.toUpperCase()},each:function(a,c,d){var f,g=0,h=a.length,i=h===b||e.isFunction(a);if(d){if(i){for(f in a)if(c.apply(a[f],d)===!1)break}else for(;g0&&a[0]&&a[j-1]||j===0||e.isArray(a));if(k)for(;i1?i.call(arguments,0):b,j.notifyWith(k,e)}}function l(a){return function(c){b[a]=arguments.length>1?i.call(arguments,0):c,--g||j.resolveWith(j,b)}}var b=i.call(arguments,0),c=0,d=b.length,e=Array(d),g=d,h=d,j=d<=1&&a&&f.isFunction(a.promise)?a:f.Deferred(),k=j.promise();if(d>1){for(;c
a",d=q.getElementsByTagName("*"),e=q.getElementsByTagName("a")[0];if(!d||!d.length||!e)return{};g=c.createElement("select"),h=g.appendChild(c.createElement("option")),i=q.getElementsByTagName("input")[0],b={leadingWhitespace:q.firstChild.nodeType===3,tbody:!q.getElementsByTagName("tbody").length,htmlSerialize:!!q.getElementsByTagName("link").length,style:/top/.test(e.getAttribute("style")),hrefNormalized:e.getAttribute("href")==="/a",opacity:/^0.55/.test(e.style.opacity),cssFloat:!!e.style.cssFloat,checkOn:i.value==="on",optSelected:h.selected,getSetAttribute:q.className!=="t",enctype:!!c.createElement("form").enctype,html5Clone:c.createElement("nav").cloneNode(!0).outerHTML!=="<:nav>",submitBubbles:!0,changeBubbles:!0,focusinBubbles:!1,deleteExpando:!0,noCloneEvent:!0,inlineBlockNeedsLayout:!1,shrinkWrapBlocks:!1,reliableMarginRight:!0},i.checked=!0,b.noCloneChecked=i.cloneNode(!0).checked,g.disabled=!0,b.optDisabled=!h.disabled;try{delete q.test}catch(s){b.deleteExpando=!1}!q.addEventListener&&q.attachEvent&&q.fireEvent&&(q.attachEvent("onclick",function(){b.noCloneEvent=!1}),q.cloneNode(!0).fireEvent("onclick")),i=c.createElement("input"),i.value="t",i.setAttribute("type","radio"),b.radioValue=i.value==="t",i.setAttribute("checked","checked"),q.appendChild(i),k=c.createDocumentFragment(),k.appendChild(q.lastChild),b.checkClone=k.cloneNode(!0).cloneNode(!0).lastChild.checked,b.appendChecked=i.checked,k.removeChild(i),k.appendChild(q),q.innerHTML="",a.getComputedStyle&&(j=c.createElement("div"),j.style.width="0",j.style.marginRight="0",q.style.width="2px",q.appendChild(j),b.reliableMarginRight=(parseInt((a.getComputedStyle(j,null)||{marginRight:0}).marginRight,10)||0)===0);if(q.attachEvent)for(o in{submit:1,change:1,focusin:1})n="on"+o,p=n in q,p||(q.setAttribute(n,"return;"),p=typeof q[n]=="function"),b[o+"Bubbles"]=p;k.removeChild(q),k=g=h=j=q=i=null,f(function(){var a,d,e,g,h,i,j,k,m,n,o,r=c.getElementsByTagName("body")[0];!r||(j=1,k="position:absolute;top:0;left:0;width:1px;height:1px;margin:0;",m="visibility:hidden;border:0;",n="style='"+k+"border:5px solid #000;padding:0;'",o="
"+""+"
",a=c.createElement("div"),a.style.cssText=m+"width:0;height:0;position:static;top:0;margin-top:"+j+"px",r.insertBefore(a,r.firstChild),q=c.createElement("div"),a.appendChild(q),q.innerHTML="
t
",l=q.getElementsByTagName("td"),p=l[0].offsetHeight===0,l[0].style.display="",l[1].style.display="none",b.reliableHiddenOffsets=p&&l[0].offsetHeight===0,q.innerHTML="",q.style.width=q.style.paddingLeft="1px",f.boxModel=b.boxModel=q.offsetWidth===2,typeof q.style.zoom!="undefined"&&(q.style.display="inline",q.style.zoom=1,b.inlineBlockNeedsLayout=q.offsetWidth===2,q.style.display="",q.innerHTML="
",b.shrinkWrapBlocks=q.offsetWidth!==2),q.style.cssText=k+m,q.innerHTML=o,d=q.firstChild,e=d.firstChild,h=d.nextSibling.firstChild.firstChild,i={doesNotAddBorder:e.offsetTop!==5,doesAddBorderForTableAndCells:h.offsetTop===5},e.style.position="fixed",e.style.top="20px",i.fixedPosition=e.offsetTop===20||e.offsetTop===15,e.style.position=e.style.top="",d.style.overflow="hidden",d.style.position="relative",i.subtractsBorderForOverflowNotVisible=e.offsetTop===-5,i.doesNotIncludeMarginInBodyOffset=r.offsetTop!==j,r.removeChild(a),q=a=null,f.extend(b,i))});return b}();var j=/^(?:\{.*\}|\[.*\])$/,k=/([A-Z])/g;f.extend({cache:{},uuid:0,expando:"jQuery"+(f.fn.jquery+Math.random()).replace(/\D/g,""),noData:{embed:!0,object:"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000",applet:!0},hasData:function(a){a=a.nodeType?f.cache[a[f.expando]]:a[f.expando];return!!a&&!m(a)},data:function(a,c,d,e){if(!!f.acceptData(a)){var g,h,i,j=f.expando,k=typeof c=="string",l=a.nodeType,m=l?f.cache:a,n=l?a[j]:a[j]&&j,o=c==="events";if((!n||!m[n]||!o&&!e&&!m[n].data)&&k&&d===b)return;n||(l?a[j]=n=++f.uuid:n=j),m[n]||(m[n]={},l||(m[n].toJSON=f.noop));if(typeof c=="object"||typeof c=="function")e?m[n]=f.extend(m[n],c):m[n].data=f.extend(m[n].data,c);g=h=m[n],e||(h.data||(h.data={}),h=h.data),d!==b&&(h[f.camelCase(c)]=d);if(o&&!h[c])return g.events;k?(i=h[c],i==null&&(i=h[f.camelCase(c)])):i=h;return i}},removeData:function(a,b,c){if(!!f.acceptData(a)){var d,e,g,h=f.expando,i=a.nodeType,j=i?f.cache:a,k=i?a[h]:h;if(!j[k])return;if(b){d=c?j[k]:j[k].data;if(d){f.isArray(b)||(b in d?b=[b]:(b=f.camelCase(b),b in d?b=[b]:b=b.split(" ")));for(e=0,g=b.length;e-1)return!0;return!1},val:function(a){var c,d,e,g=this[0];{if(!!arguments.length){e=f.isFunction(a);return this.each(function(d){var g=f(this),h;if(this.nodeType===1){e?h=a.call(this,d,g.val()):h=a,h==null?h="":typeof h=="number"?h+="":f.isArray(h)&&(h=f.map(h,function(a){return a==null?"":a+""})),c=f.valHooks[this.nodeName.toLowerCase()]||f.valHooks[this.type];if(!c||!("set"in c)||c.set(this,h,"value")===b)this.value=h}})}if(g){c=f.valHooks[g.nodeName.toLowerCase()]||f.valHooks[g.type];if(c&&"get"in c&&(d=c.get(g,"value"))!==b)return d;d=g.value;return typeof d=="string"?d.replace(q,""):d==null?"":d}}}}),f.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,g=a.selectedIndex,h=[],i=a.options,j=a.type==="select-one";if(g<0)return null;c=j?g:0,d=j?g+1:i.length;for(;c=0}),c.length||(a.selectedIndex=-1);return 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 g,h,i,j=a.nodeType;if(!!a&&j!==3&&j!==8&&j!==2){if(e&&c in f.attrFn)return f(a)[c](d);if(typeof a.getAttribute=="undefined")return f.prop(a,c,d);i=j!==1||!f.isXMLDoc(a),i&&(c=c.toLowerCase(),h=f.attrHooks[c]||(u.test(c)?x:w));if(d!==b){if(d===null){f.removeAttr(a,c);return}if(h&&"set"in h&&i&&(g=h.set(a,d,c))!==b)return g;a.setAttribute(c,""+d);return d}if(h&&"get"in h&&i&&(g=h.get(a,c))!==null)return g;g=a.getAttribute(c);return g===null?b:g}},removeAttr:function(a,b){var c,d,e,g,h=0;if(b&&a.nodeType===1){d=b.toLowerCase().split(p),g=d.length;for(;h=0}})});var z=/^(?:textarea|input|select)$/i,A=/^([^\.]*)?(?:\.(.+))?$/,B=/\bhover(\.\S+)?\b/,C=/^key/,D=/^(?:mouse|contextmenu)|click/,E=/^(?:focusinfocus|focusoutblur)$/,F=/^(\w*)(?:#([\w\-]+))?(?:\.([\w\-]+))?$/,G=function(a){var b=F.exec(a);b&&(b[1]=(b[1]||"").toLowerCase(),b[3]=b[3]&&new RegExp("(?:^|\\s)"+b[3]+"(?:\\s|$)"));return b},H=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))},I=function(a){return f.event.special.hover?a:a.replace(B,"mouseenter$1 mouseleave$1")}; +f.event={add:function(a,c,d,e,g){var h,i,j,k,l,m,n,o,p,q,r,s;if(!(a.nodeType===3||a.nodeType===8||!c||!d||!(h=f._data(a)))){d.handler&&(p=d,d=p.handler),d.guid||(d.guid=f.guid++),j=h.events,j||(h.events=j={}),i=h.handle,i||(h.handle=i=function(a){return typeof f!="undefined"&&(!a||f.event.triggered!==a.type)?f.event.dispatch.apply(i.elem,arguments):b},i.elem=a),c=f.trim(I(c)).split(" ");for(k=0;k=0&&(h=h.slice(0,-1),k=!0),h.indexOf(".")>=0&&(i=h.split("."),h=i.shift(),i.sort());if((!e||f.event.customEvent[h])&&!f.event.global[h])return;c=typeof c=="object"?c[f.expando]?c:new f.Event(h,c):new f.Event(h),c.type=h,c.isTrigger=!0,c.exclusive=k,c.namespace=i.join("."),c.namespace_re=c.namespace?new RegExp("(^|\\.)"+i.join("\\.(?:.*\\.)?")+"(\\.|$)"):null,o=h.indexOf(":")<0?"on"+h:"";if(!e){j=f.cache;for(l in j)j[l].events&&j[l].events[h]&&f.event.trigger(c,d,j[l].handle.elem,!0);return}c.result=b,c.target||(c.target=e),d=d!=null?f.makeArray(d):[],d.unshift(c),p=f.event.special[h]||{};if(p.trigger&&p.trigger.apply(e,d)===!1)return;r=[[e,p.bindType||h]];if(!g&&!p.noBubble&&!f.isWindow(e)){s=p.delegateType||h,m=E.test(s+h)?e:e.parentNode,n=null;for(;m;m=m.parentNode)r.push([m,s]),n=m;n&&n===e.ownerDocument&&r.push([n.defaultView||n.parentWindow||a,s])}for(l=0;le&&i.push({elem:this,matches:d.slice(e)});for(j=0;j0?this.on(b,null,a,c):this.trigger(b)},f.attrFn&&(f.attrFn[b]=!0),C.test(b)&&(f.event.fixHooks[b]=f.event.keyHooks),D.test(b)&&(f.event.fixHooks[b]=f.event.mouseHooks)}),function(){function x(a,b,c,e,f,g){for(var h=0,i=e.length;h0){k=j;break}}j=j[a]}e[h]=k}}}function w(a,b,c,e,f,g){for(var h=0,i=e.length;h+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,d="sizcache"+(Math.random()+"").replace(".",""),e=0,g=Object.prototype.toString,h=!1,i=!0,j=/\\/g,k=/\r\n/g,l=/\W/;[0,0].sort(function(){i=!1;return 0});var m=function(b,d,e,f){e=e||[],d=d||c;var h=d;if(d.nodeType!==1&&d.nodeType!==9)return[];if(!b||typeof b!="string")return e;var i,j,k,l,n,q,r,t,u=!0,v=m.isXML(d),w=[],x=b;do{a.exec(""),i=a.exec(x);if(i){x=i[3],w.push(i[1]);if(i[2]){l=i[3];break}}}while(i);if(w.length>1&&p.exec(b))if(w.length===2&&o.relative[w[0]])j=y(w[0]+w[1],d,f);else{j=o.relative[w[0]]?[d]:m(w.shift(),d);while(w.length)b=w.shift(),o.relative[b]&&(b+=w.shift()),j=y(b,j,f)}else{!f&&w.length>1&&d.nodeType===9&&!v&&o.match.ID.test(w[0])&&!o.match.ID.test(w[w.length-1])&&(n=m.find(w.shift(),d,v),d=n.expr?m.filter(n.expr,n.set)[0]:n.set[0]);if(d){n=f?{expr:w.pop(),set:s(f)}:m.find(w.pop(),w.length===1&&(w[0]==="~"||w[0]==="+")&&d.parentNode?d.parentNode:d,v),j=n.expr?m.filter(n.expr,n.set):n.set,w.length>0?k=s(j):u=!1;while(w.length)q=w.pop(),r=q,o.relative[q]?r=w.pop():q="",r==null&&(r=d),o.relative[q](k,r,v)}else k=w=[]}k||(k=j),k||m.error(q||b);if(g.call(k)==="[object Array]")if(!u)e.push.apply(e,k);else if(d&&d.nodeType===1)for(t=0;k[t]!=null;t++)k[t]&&(k[t]===!0||k[t].nodeType===1&&m.contains(d,k[t]))&&e.push(j[t]);else for(t=0;k[t]!=null;t++)k[t]&&k[t].nodeType===1&&e.push(j[t]);else s(k,e);l&&(m(l,h,e,f),m.uniqueSort(e));return e};m.uniqueSort=function(a){if(u){h=i,a.sort(u);if(h)for(var b=1;b0},m.find=function(a,b,c){var d,e,f,g,h,i;if(!a)return[];for(e=0,f=o.order.length;e":function(a,b){var c,d=typeof b=="string",e=0,f=a.length;if(d&&!l.test(b)){b=b.toLowerCase();for(;e=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]);a[0]=e++;return a},ATTR:function(a,b,c,d,e,f){var g=a[1]=a[1].replace(j,"");!f&&o.attrMap[g]&&(a[1]=o.attrMap[g]),a[4]=(a[4]||a[5]||"").replace(j,""),a[2]==="~="&&(a[4]=" "+a[4]+" ");return a},PSEUDO:function(b,c,d,e,f){if(b[1]==="not")if((a.exec(b[3])||"").length>1||/^\w/.test(b[3]))b[3]=m(b[3],null,null,c);else{var g=m.filter(b[3],c,d,!0^f);d||e.push.apply(e,g);return!1}else if(o.match.POS.test(b[0])||o.match.CHILD.test(b[0]))return!0;return b},POS:function(a){a.unshift(!0);return 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){a.parentNode&&a.parentNode.selectedIndex;return 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 bc[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=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){a=Array.prototype.slice.call(a,0);if(b){b.push.apply(b,a);return b}return a};try{Array.prototype.slice.call(c.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.insertBefore(a,e.firstChild),c.getElementById(d)&&(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}),e.removeChild(a),e=a=null}(),function(){var a=c.createElement("div");a.appendChild(c.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.firstChild&&typeof a.firstChild.getAttribute!="undefined"&&a.firstChild.getAttribute("href")!=="#"&&(o.attrHandle.href=function(a){return a.getAttribute("href",2)}),a=null}(),c.querySelectorAll&&function(){var a=m,b=c.createElement("div"),d="__sizzle__";b.innerHTML="

";if(!b.querySelectorAll||b.querySelectorAll(".TEST").length!==0){m=function(b,e,f,g){e=e||c;if(!g&&!m.isXML(e)){var h=/^(\w+$)|^\.([\w\-]+$)|^#([\w\-]+$)/.exec(b);if(h&&(e.nodeType===1||e.nodeType===9)){if(h[1])return s(e.getElementsByTagName(b),f);if(h[2]&&o.find.CLASS&&e.getElementsByClassName)return s(e.getElementsByClassName(h[2]),f)}if(e.nodeType===9){if(b==="body"&&e.body)return s([e.body],f);if(h&&h[3]){var i=e.getElementById(h[3]);if(!i||!i.parentNode)return s([],f);if(i.id===h[3])return s([i],f)}try{return s(e.querySelectorAll(b),f)}catch(j){}}else if(e.nodeType===1&&e.nodeName.toLowerCase()!=="object"){var k=e,l=e.getAttribute("id"),n=l||d,p=e.parentNode,q=/^\s*[+~]/.test(b);l?n=n.replace(/'/g,"\\$&"):e.setAttribute("id",n),q&&p&&(e=e.parentNode);try{if(!q||p)return s(e.querySelectorAll("[id='"+n+"'] "+b),f)}catch(r){}finally{l||k.removeAttribute("id")}}}return a(b,e,f,g)};for(var e in a)m[e]=a[e];b=null}}(),function(){var a=c.documentElement,b=a.matchesSelector||a.mozMatchesSelector||a.webkitMatchesSelector||a.msMatchesSelector;if(b){var d=!b.call(c.createElement("div"),"div"),e=!1;try{b.call(c.documentElement,"[test!='']:sizzle")}catch(f){e=!0}m.matchesSelector=function(a,c){c=c.replace(/\=\s*([^'"\]]*)\s*\]/g,"='$1']");if(!m.isXML(a))try{if(e||!o.match.PSEUDO.test(c)&&!/!=/.test(c)){var f=b.call(a,c);if(f||!d||a.document&&a.document.nodeType!==11)return f}}catch(g){}return m(c,null,null,[a]).length>0}}}(),function(){var a=c.createElement("div");a.innerHTML="
";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}}(),c.documentElement.contains?m.contains=function(a,b){return a!==b&&(a.contains?a.contains(b):!0)}:c.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 y=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;h0)for(h=g;h=0:f.filter(a,this).length>0:this.filter(a).length>0)},closest:function(a,b){var c=[],d,e,g=this[0];if(f.isArray(a)){var h=1;while(g&&g.ownerDocument&&g!==b){for(d=0;d-1:f.find.matchesSelector(g,a)){c.push(g);break}g=g.parentNode;if(!g||!g.ownerDocument||g===b||g.nodeType===11)break}}c=c.length>1?f.unique(c):c;return this.pushStack(c,"closest",a)},index:function(a){if(!a)return this[0]&&this[0].parentNode?this.prevAll().length:-1;if(typeof a=="string")return f.inArray(this[0],f(a));return f.inArray(a.jquery?a[0]:a,this)},add:function(a,b){var c=typeof a=="string"?f(a,b):f.makeArray(a&&a.nodeType?[a]:a),d=f.merge(this.get(),c);return this.pushStack(S(c[0])||S(d[0])?d:f.unique(d))},andSelf:function(){return this.add(this.prevObject)}}),f.each({parent:function(a){var b=a.parentNode;return b&&b.nodeType!==11?b:null},parents:function(a){return f.dir(a,"parentNode")},parentsUntil:function(a,b,c){return f.dir(a,"parentNode",c)},next:function(a){return f.nth(a,2,"nextSibling")},prev:function(a){return f.nth(a,2,"previousSibling")},nextAll:function(a){return f.dir(a,"nextSibling")},prevAll:function(a){return f.dir(a,"previousSibling")},nextUntil:function(a,b,c){return f.dir(a,"nextSibling",c)},prevUntil:function(a,b,c){return f.dir(a,"previousSibling",c)},siblings:function(a){return f.sibling(a.parentNode.firstChild,a)},children:function(a){return f.sibling(a.firstChild)},contents:function(a){return f.nodeName(a,"iframe")?a.contentDocument||a.contentWindow.document:f.makeArray(a.childNodes)}},function(a,b){f.fn[a]=function(c,d){var e=f.map(this,b,c);L.test(a)||(d=c),d&&typeof d=="string"&&(e=f.filter(d,e)),e=this.length>1&&!R[a]?f.unique(e):e,(this.length>1||N.test(d))&&M.test(a)&&(e=e.reverse());return this.pushStack(e,a,P.call(arguments).join(","))}}),f.extend({filter:function(a,b,c){c&&(a=":not("+a+")");return b.length===1?f.find.matchesSelector(b[0],a)?[b[0]]:[]:f.find.matches(a,b)},dir:function(a,c,d){var e=[],g=a[c];while(g&&g.nodeType!==9&&(d===b||g.nodeType!==1||!f(g).is(d)))g.nodeType===1&&e.push(g),g=g[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 V="abbr|article|aside|audio|canvas|datalist|details|figcaption|figure|footer|header|hgroup|mark|meter|nav|output|progress|section|summary|time|video",W=/ jQuery\d+="(?:\d+|null)"/g,X=/^\s+/,Y=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,Z=/<([\w:]+)/,$=/",""],legend:[1,"
","
"],thead:[1,"","
"],tr:[2,"","
"],td:[3,"","
"],col:[2,"","
"],area:[1,"",""],_default:[0,"",""]},bh=U(c);bg.optgroup=bg.option,bg.tbody=bg.tfoot=bg.colgroup=bg.caption=bg.thead,bg.th=bg.td,f.support.htmlSerialize||(bg._default=[1,"div
","
"]),f.fn.extend({text:function(a){if(f.isFunction(a))return this.each(function(b){var c=f(this);c.text(a.call(this,b,c.text()))});if(typeof a!="object"&&a!==b)return this.empty().append((this[0]&&this[0].ownerDocument||c).createTextNode(a));return f.text(this)},wrapAll:function(a){if(f.isFunction(a))return this.each(function(b){f(this).wrapAll(a.call(this,b))});if(this[0]){var b=f(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){if(f.isFunction(a))return this.each(function(b){f(this).wrapInner(a.call(this,b))});return this.each(function(){var b=f(this),c=b.contents();c.length?c.wrapAll(a):b.append(a)})},wrap:function(a){var b=f.isFunction(a);return this.each(function(c){f(this).wrapAll(b?a.call(this,c):a)})},unwrap:function(){return this.parent().each(function(){f.nodeName(this,"body")||f(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=f.clean(arguments);a.push.apply(a,this.toArray());return 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);a.push.apply(a,f.clean(arguments));return a}},remove:function(a,b){for(var c=0,d;(d=this[c])!=null;c++)if(!a||f.filter(a,[d]).length)!b&&d.nodeType===1&&(f.cleanData(d.getElementsByTagName("*")),f.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&&f.cleanData(b.getElementsByTagName("*"));while(b.firstChild)b.removeChild(b.firstChild)}return this},clone:function(a,b){a=a==null?!1:a,b=b==null?a:b;return this.map(function(){return f.clone(this,a,b)})},html:function(a){if(a===b)return this[0]&&this[0].nodeType===1?this[0].innerHTML.replace(W,""):null;if(typeof a=="string"&&!ba.test(a)&&(f.support.leadingWhitespace||!X.test(a))&&!bg[(Z.exec(a)||["",""])[1].toLowerCase()]){a=a.replace(Y,"<$1>");try{for(var c=0,d=this.length;c1&&l0?this.clone(!0):this).get();f(e[h])[b](j),d=d.concat(j)}return this.pushStack(d,a,e.selector)}}),f.extend({clone:function(a,b,c){var d,e,g,h=f.support.html5Clone||!bc.test("<"+a.nodeName)?a.cloneNode(!0):bo(a);if((!f.support.noCloneEvent||!f.support.noCloneChecked)&&(a.nodeType===1||a.nodeType===11)&&!f.isXMLDoc(a)){bk(a,h),d=bl(a),e=bl(h);for(g=0;d[g];++g)e[g]&&bk(d[g],e[g])}if(b){bj(a,h);if(c){d=bl(a),e=bl(h);for(g=0;d[g];++g)bj(d[g],e[g])}}d=e=null;return h},clean:function(a,b,d,e){var g;b=b||c,typeof b.createElement=="undefined"&&(b=b.ownerDocument||b[0]&&b[0].ownerDocument||c);var h=[],i;for(var j=0,k;(k=a[j])!=null;j++){typeof k=="number"&&(k+="");if(!k)continue;if(typeof k=="string")if(!_.test(k))k=b.createTextNode(k);else{k=k.replace(Y,"<$1>");var l=(Z.exec(k)||["",""])[1].toLowerCase(),m=bg[l]||bg._default,n=m[0],o=b.createElement("div");b===c?bh.appendChild(o):U(b).appendChild(o),o.innerHTML=m[1]+k+m[2];while(n--)o=o.lastChild;if(!f.support.tbody){var p=$.test(k),q=l==="table"&&!p?o.firstChild&&o.firstChild.childNodes:m[1]===""&&!p?o.childNodes:[];for(i=q.length-1;i>=0;--i)f.nodeName(q[i],"tbody")&&!q[i].childNodes.length&&q[i].parentNode.removeChild(q[i])}!f.support.leadingWhitespace&&X.test(k)&&o.insertBefore(b.createTextNode(X.exec(k)[0]),o.firstChild),k=o.childNodes}var r;if(!f.support.appendChecked)if(k[0]&&typeof (r=k.length)=="number")for(i=0;i=0)return b+"px"}}}),f.support.opacity||(f.cssHooks.opacity={get:function(a,b){return br.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=f.isNumeric(b)?"alpha(opacity="+b*100+")":"",g=d&&d.filter||c.filter||"";c.zoom=1;if(b>=1&&f.trim(g.replace(bq,""))===""){c.removeAttribute("filter");if(d&&!d.filter)return}c.filter=bq.test(g)?g.replace(bq,e):g+" "+e}}),f(function(){f.support.reliableMarginRight||(f.cssHooks.marginRight={get:function(a,b){var c;f.swap(a,{display:"inline-block"},function(){b?c=bz(a,"margin-right","marginRight"):c=a.style.marginRight});return c}})}),c.defaultView&&c.defaultView.getComputedStyle&&(bA=function(a,b){var c,d,e;b=b.replace(bs,"-$1").toLowerCase(),(d=a.ownerDocument.defaultView)&&(e=d.getComputedStyle(a,null))&&(c=e.getPropertyValue(b),c===""&&!f.contains(a.ownerDocument.documentElement,a)&&(c=f.style(a,b)));return c}),c.documentElement.currentStyle&&(bB=function(a,b){var c,d,e,f=a.currentStyle&&a.currentStyle[b],g=a.style;f===null&&g&&(e=g[b])&&(f=e),!bt.test(f)&&bu.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));return f===""?"auto":f}),bz=bA||bB,f.expr&&f.expr.filters&&(f.expr.filters.hidden=function(a){var b=a.offsetWidth,c=a.offsetHeight;return b===0&&c===0||!f.support.reliableHiddenOffsets&&(a.style&&a.style.display||f.css(a,"display"))==="none"},f.expr.filters.visible=function(a){return!f.expr.filters.hidden(a)});var bD=/%20/g,bE=/\[\]$/,bF=/\r?\n/g,bG=/#.*$/,bH=/^(.*?):[ \t]*([^\r\n]*)\r?$/mg,bI=/^(?:color|date|datetime|datetime-local|email|hidden|month|number|password|range|search|tel|text|time|url|week)$/i,bJ=/^(?:about|app|app\-storage|.+\-extension|file|res|widget):$/,bK=/^(?:GET|HEAD)$/,bL=/^\/\//,bM=/\?/,bN=/)<[^<]*)*<\/script>/gi,bO=/^(?:select|textarea)/i,bP=/\s+/,bQ=/([?&])_=[^&]*/,bR=/^([\w\+\.\-]+:)(?:\/\/([^\/?#:]*)(?::(\d+))?)?/,bS=f.fn.load,bT={},bU={},bV,bW,bX=["*/"]+["*"];try{bV=e.href}catch(bY){bV=c.createElement("a"),bV.href="",bV=bV.href}bW=bR.exec(bV.toLowerCase())||[],f.fn.extend({load:function(a,c,d){if(typeof a!="string"&&bS)return bS.apply(this,arguments);if(!this.length)return this;var e=a.indexOf(" ");if(e>=0){var g=a.slice(e,a.length);a=a.slice(0,e)}var h="GET";c&&(f.isFunction(c)?(d=c,c=b):typeof c=="object"&&(c=f.param(c,f.ajaxSettings.traditional),h="POST"));var i=this;f.ajax({url:a,type:h,dataType:"html",data:c,complete:function(a,b,c){c=a.responseText,a.isResolved()&&(a.done(function(a){c=a}),i.html(g?f("
").append(c.replace(bN,"")).find(g):c)),d&&i.each(d,[c,b,a])}});return this},serialize:function(){return f.param(this.serializeArray())},serializeArray:function(){return this.map(function(){return this.elements?f.makeArray(this.elements):this}).filter(function(){return this.name&&!this.disabled&&(this.checked||bO.test(this.nodeName)||bI.test(this.type))}).map(function(a,b){var c=f(this).val();return c==null?null:f.isArray(c)?f.map(c,function(a,c){return{name:b.name,value:a.replace(bF,"\r\n")}}):{name:b.name,value:c.replace(bF,"\r\n")}}).get()}}),f.each("ajaxStart ajaxStop ajaxComplete ajaxError ajaxSuccess ajaxSend".split(" "),function(a,b){f.fn[b]=function(a){return this.on(b,a)}}),f.each(["get","post"],function(a,c){f[c]=function(a,d,e,g){f.isFunction(d)&&(g=g||e,e=d,d=b);return f.ajax({type:c,url:a,data:d,success:e,dataType:g})}}),f.extend({getScript:function(a,c){return f.get(a,b,c,"script")},getJSON:function(a,b,c){return f.get(a,b,c,"json")},ajaxSetup:function(a,b){b?b_(a,f.ajaxSettings):(b=a,a=f.ajaxSettings),b_(a,b);return a},ajaxSettings:{url:bV,isLocal:bJ.test(bW[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","*":bX},contents:{xml:/xml/,html:/html/,json:/json/},responseFields:{xml:"responseXML",text:"responseText"},converters:{"* text":a.String,"text html":!0,"text json":f.parseJSON,"text xml":f.parseXML},flatOptions:{context:!0,url:!0}},ajaxPrefilter:bZ(bT),ajaxTransport:bZ(bU),ajax:function(a,c){function w(a,c,l,m){if(s!==2){s=2,q&&clearTimeout(q),p=b,n=m||"",v.readyState=a>0?4:0;var o,r,u,w=c,x=l?cb(d,v,l):b,y,z;if(a>=200&&a<300||a===304){if(d.ifModified){if(y=v.getResponseHeader("Last-Modified"))f.lastModified[k]=y;if(z=v.getResponseHeader("Etag"))f.etag[k]=z}if(a===304)w="notmodified",o=!0;else try{r=cc(d,x),w="success",o=!0}catch(A){w="parsererror",u=A}}else{u=w;if(!w||a)w="error",a<0&&(a=0)}v.status=a,v.statusText=""+(c||w),o?h.resolveWith(e,[r,w,v]):h.rejectWith(e,[v,w,u]),v.statusCode(j),j=b,t&&g.trigger("ajax"+(o?"Success":"Error"),[v,d,o?r:u]),i.fireWith(e,[v,w]),t&&(g.trigger("ajaxComplete",[v,d]),--f.active||f.event.trigger("ajaxStop"))}}typeof a=="object"&&(c=a,a=b),c=c||{};var d=f.ajaxSetup({},c),e=d.context||d,g=e!==d&&(e.nodeType||e instanceof f)?f(e):f.event,h=f.Deferred(),i=f.Callbacks("once memory"),j=d.statusCode||{},k,l={},m={},n,o,p,q,r,s=0,t,u,v={readyState:0,setRequestHeader:function(a,b){if(!s){var c=a.toLowerCase();a=m[c]=m[c]||a,l[a]=b}return this},getAllResponseHeaders:function(){return s===2?n:null},getResponseHeader:function(a){var c;if(s===2){if(!o){o={};while(c=bH.exec(n))o[c[1].toLowerCase()]=c[2]}c=o[a.toLowerCase()]}return c===b?null:c},overrideMimeType:function(a){s||(d.mimeType=a);return this},abort:function(a){a=a||"abort",p&&p.abort(a),w(0,a);return this}};h.promise(v),v.success=v.done,v.error=v.fail,v.complete=i.add,v.statusCode=function(a){if(a){var b;if(s<2)for(b in a)j[b]=[j[b],a[b]];else b=a[v.status],v.then(b,b)}return this},d.url=((a||d.url)+"").replace(bG,"").replace(bL,bW[1]+"//"),d.dataTypes=f.trim(d.dataType||"*").toLowerCase().split(bP),d.crossDomain==null&&(r=bR.exec(d.url.toLowerCase()),d.crossDomain=!(!r||r[1]==bW[1]&&r[2]==bW[2]&&(r[3]||(r[1]==="http:"?80:443))==(bW[3]||(bW[1]==="http:"?80:443)))),d.data&&d.processData&&typeof d.data!="string"&&(d.data=f.param(d.data,d.traditional)),b$(bT,d,c,v);if(s===2)return!1;t=d.global,d.type=d.type.toUpperCase(),d.hasContent=!bK.test(d.type),t&&f.active++===0&&f.event.trigger("ajaxStart");if(!d.hasContent){d.data&&(d.url+=(bM.test(d.url)?"&":"?")+d.data,delete d.data),k=d.url;if(d.cache===!1){var x=f.now(),y=d.url.replace(bQ,"$1_="+x);d.url=y+(y===d.url?(bM.test(d.url)?"&":"?")+"_="+x:"")}}(d.data&&d.hasContent&&d.contentType!==!1||c.contentType)&&v.setRequestHeader("Content-Type",d.contentType),d.ifModified&&(k=k||d.url,f.lastModified[k]&&v.setRequestHeader("If-Modified-Since",f.lastModified[k]),f.etag[k]&&v.setRequestHeader("If-None-Match",f.etag[k])),v.setRequestHeader("Accept",d.dataTypes[0]&&d.accepts[d.dataTypes[0]]?d.accepts[d.dataTypes[0]]+(d.dataTypes[0]!=="*"?", "+bX+"; q=0.01":""):d.accepts["*"]);for(u in d.headers)v.setRequestHeader(u,d.headers[u]);if(d.beforeSend&&(d.beforeSend.call(e,v,d)===!1||s===2)){v.abort();return!1}for(u in{success:1,error:1,complete:1})v[u](d[u]);p=b$(bU,d,c,v);if(!p)w(-1,"No Transport");else{v.readyState=1,t&&g.trigger("ajaxSend",[v,d]),d.async&&d.timeout>0&&(q=setTimeout(function(){v.abort("timeout")},d.timeout));try{s=1,p.send(l,w)}catch(z){if(s<2)w(-1,z);else throw z}}return v},param:function(a,c){var d=[],e=function(a,b){b=f.isFunction(b)?b():b,d[d.length]=encodeURIComponent(a)+"="+encodeURIComponent(b)};c===b&&(c=f.ajaxSettings.traditional);if(f.isArray(a)||a.jquery&&!f.isPlainObject(a))f.each(a,function(){e(this.name,this.value)});else for(var g in a)ca(g,a[g],c,e);return d.join("&").replace(bD,"+")}}),f.extend({active:0,lastModified:{},etag:{}});var cd=f.now(),ce=/(\=)\?(&|$)|\?\?/i;f.ajaxSetup({jsonp:"callback",jsonpCallback:function(){return f.expando+"_"+cd++}}),f.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&&(ce.test(b.url)||e&&ce.test(b.data))){var g,h=b.jsonpCallback=f.isFunction(b.jsonpCallback)?b.jsonpCallback():b.jsonpCallback,i=a[h],j=b.url,k=b.data,l="$1"+h+"$2";b.jsonp!==!1&&(j=j.replace(ce,l),b.url===j&&(e&&(k=k.replace(ce,l)),b.data===k&&(j+=(/\?/.test(j)?"&":"?")+b.jsonp+"="+h))),b.url=j,b.data=k,a[h]=function(a){g=[a]},d.always(function(){a[h]=i,g&&f.isFunction(i)&&a[h](g[0])}),b.converters["script json"]=function(){g||f.error(h+" was not called");return g[0]},b.dataTypes[0]="json";return"script"}}),f.ajaxSetup({accepts:{script:"text/javascript, application/javascript, application/ecmascript, application/x-ecmascript"},contents:{script:/javascript|ecmascript/},converters:{"text script":function(a){f.globalEval(a);return a}}}),f.ajaxPrefilter("script",function(a){a.cache===b&&(a.cache=!1),a.crossDomain&&(a.type="GET",a.global=!1)}),f.ajaxTransport("script",function(a){if(a.crossDomain){var d,e=c.head||c.getElementsByTagName("head")[0]||c.documentElement;return{send:function(f,g){d=c.createElement("script"),d.async="async",a.scriptCharset&&(d.charset=a.scriptCharset),d.src=a.url,d.onload=d.onreadystatechange=function(a,c){if(c||!d.readyState||/loaded|complete/.test(d.readyState))d.onload=d.onreadystatechange=null,e&&d.parentNode&&e.removeChild(d),d=b,c||g(200,"success")},e.insertBefore(d,e.firstChild)},abort:function(){d&&d.onload(0,1)}}}});var cf=a.ActiveXObject?function(){for(var a in ch)ch[a](0,1)}:!1,cg=0,ch;f.ajaxSettings.xhr=a.ActiveXObject?function(){return!this.isLocal&&ci()||cj()}:ci,function(a){f.extend(f.support,{ajax:!!a,cors:!!a&&"withCredentials"in a})}(f.ajaxSettings.xhr()),f.support.ajax&&f.ajaxTransport(function(c){if(!c.crossDomain||f.support.cors){var d;return{send:function(e,g){var h=c.xhr(),i,j;c.username?h.open(c.type,c.url,c.async,c.username,c.password):h.open(c.type,c.url,c.async);if(c.xhrFields)for(j in c.xhrFields)h[j]=c.xhrFields[j];c.mimeType&&h.overrideMimeType&&h.overrideMimeType(c.mimeType),!c.crossDomain&&!e["X-Requested-With"]&&(e["X-Requested-With"]="XMLHttpRequest");try{for(j in e)h.setRequestHeader(j,e[j])}catch(k){}h.send(c.hasContent&&c.data||null),d=function(a,e){var j,k,l,m,n;try{if(d&&(e||h.readyState===4)){d=b,i&&(h.onreadystatechange=f.noop,cf&&delete ch[i]);if(e)h.readyState!==4&&h.abort();else{j=h.status,l=h.getAllResponseHeaders(),m={},n=h.responseXML,n&&n.documentElement&&(m.xml=n),m.text=h.responseText;try{k=h.statusText}catch(o){k=""}!j&&c.isLocal&&!c.crossDomain?j=m.text?200:404:j===1223&&(j=204)}}}catch(p){e||g(-1,p)}m&&g(j,k,m,l)},!c.async||h.readyState===4?d():(i=++cg,cf&&(ch||(ch={},f(a).unload(cf)),ch[i]=d),h.onreadystatechange=d)},abort:function(){d&&d(0,1)}}}});var ck={},cl,cm,cn=/^(?:toggle|show|hide)$/,co=/^([+\-]=)?([\d+.\-]+)([a-z%]*)$/i,cp,cq=[["height","marginTop","marginBottom","paddingTop","paddingBottom"],["width","marginLeft","marginRight","paddingLeft","paddingRight"],["opacity"]],cr;f.fn.extend({show:function(a,b,c){var d,e;if(a||a===0)return this.animate(cu("show",3),a,b,c);for(var g=0,h=this.length;g=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&&(g=!1);if(g){i.overflow!=null&&!f.support.shrinkWrapBlocks&&f.each(["","X","Y"],function(a,b){h.style["overflow"+b]=i.overflow[a]}),i.hide&&f(h).hide();if(i.hide||i.show)for(b in i.animatedProperties)f.style(h,b,i.orig[b]),f.removeData(h,"fxshow"+b,!0),f.removeData(h,"toggle"+b,!0);d=i.complete,d&&(i.complete=!1,d.call(h))}return!1}i.duration==Infinity?this.now=e:(c=e-this.startTime,this.state=c/i.duration,this.pos=f.easing[i.animatedProperties[this.prop]](this.state,c,0,1,i.duration),this.now=this.start+(this.end-this.start)*this.pos),this.update();return!0}},f.extend(f.fx,{tick:function(){var a,b=f.timers,c=0;for(;c-1,k={},l={},m,n;j?(l=e.position(),m=l.top,n=l.left):(m=parseFloat(h)||0,n=parseFloat(i)||0),f.isFunction(b)&&(b=b.call(a,c,g)),b.top!=null&&(k.top=b.top-g.top+m),b.left!=null&&(k.left=b.left-g.left+n),"using"in b?b.using.call(a,k):e.css(k)}},f.fn.extend({position:function(){if(!this[0])return null;var a=this[0],b=this.offsetParent(),c=this.offset(),d=cx.test(b[0].nodeName)?{top:0,left:0}:b.offset();c.top-=parseFloat(f.css(a,"marginTop"))||0,c.left-=parseFloat(f.css(a,"marginLeft"))||0,d.top+=parseFloat(f.css(b[0],"borderTopWidth"))||0,d.left+=parseFloat(f.css(b[0],"borderLeftWidth"))||0;return{top:c.top-d.top,left:c.left-d.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||c.body;while(a&&!cx.test(a.nodeName)&&f.css(a,"position")==="static")a=a.offsetParent;return a})}}),f.each(["Left","Top"],function(a,c){var d="scroll"+c;f.fn[d]=function(c){var e,g;if(c===b){e=this[0];if(!e)return null;g=cy(e);return g?"pageXOffset"in g?g[a?"pageYOffset":"pageXOffset"]:f.support.boxModel&&g.document.documentElement[d]||g.document.body[d]:e[d]}return this.each(function(){g=cy(this),g?g.scrollTo(a?f(g).scrollLeft():c,a?c:f(g).scrollTop()):this[d]=c})}}),f.each(["Height","Width"],function(a,c){var d=c.toLowerCase();f.fn["inner"+c]=function(){var a=this[0];return a?a.style?parseFloat(f.css(a,d,"padding")):this[d]():null},f.fn["outer"+c]=function(a){var b=this[0];return b?b.style?parseFloat(f.css(b,d,a?"margin":"border")):this[d]():null},f.fn[d]=function(a){var e=this[0];if(!e)return a==null?null:this;if(f.isFunction(a))return this.each(function(b){var c=f(this);c[d](a.call(this,b,c[d]()))});if(f.isWindow(e)){var g=e.document.documentElement["client"+c],h=e.document.body;return e.document.compatMode==="CSS1Compat"&&g||h&&h["client"+c]||g}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 i=f.css(e,d),j=parseFloat(i);return f.isNumeric(j)?j:i}return this.css(d,typeof a=="string"?a:a+"px")}}),a.jQuery=a.$=f,typeof define=="function"&&define.amd&&define.amd.jQuery&&define("jquery",[],function(){return f})})(window); \ No newline at end of file diff --git a/ext/jquery-ui-1.8.16.custom.min.js b/ext/jquery-ui-1.8.16.custom.min.js deleted file mode 100755 index 14c9064..0000000 --- a/ext/jquery-ui-1.8.16.custom.min.js +++ /dev/null @@ -1,791 +0,0 @@ -/*! - * jQuery UI 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI - */ -(function(c,j){function k(a,b){var d=a.nodeName.toLowerCase();if("area"===d){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&l(a)}return(/input|select|textarea|button|object/.test(d)?!a.disabled:"a"==d?a.href||b:b)&&l(a)}function l(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.16", -keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({propAttr:c.fn.prop||c.fn.attr,_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d= -this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,"position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this, -"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart": -"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,m,n){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(m)g-=parseFloat(c.curCSS(f,"border"+this+"Width",true))||0;if(n)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight, -outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){return k(a,!isNaN(c.attr(a,"tabindex")))},tabbable:function(a){var b=c.attr(a, -"tabindex"),d=isNaN(b);return(d||b>=0)&&k(a,!d)}});c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&& -a.element[0].parentNode)for(var e=0;e0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){b(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted= -false;a.target==this._mouseDownEvent.target&&b.data(a.target,this.widgetName+".preventClickEvent",true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery); -;/* - * jQuery UI Position 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Position - */ -(function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY, -left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+= -k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-= -m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left= -d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+= -a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b), -g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery); -;/* - * jQuery UI Draggable 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Draggables - * - * Depends: - * jquery.ui.core.js - * jquery.ui.mouse.js - * jquery.ui.widget.js - */ -(function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper== -"original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b= -this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;if(b.iframeFix)d(b.iframeFix===true?"iframe":b.iframeFix).each(function(){d('
').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")});return true},_mouseStart:function(a){var b=this.options; -this.helper=this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()}); -this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);d.ui.ddmanager&&d.ui.ddmanager.dragStart(this,a);return true}, -_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b= -false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration, -10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},_mouseUp:function(a){this.options.iframeFix===true&&d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)});d.ui.ddmanager&&d.ui.ddmanager.dragStop(this,a);return d.ui.mouse.prototype._mouseUp.call(this,a)},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle|| -!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone().removeAttr("id"):this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&& -a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent= -this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"), -10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-(parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0,right:parseInt(this.element.css("marginRight"),10)||0,bottom:parseInt(this.element.css("marginBottom"), -10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment=="parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[a.containment=="document"?0:d(window).scrollLeft()-this.offset.relative.left-this.offset.parent.left,a.containment=="document"?0:d(window).scrollTop()-this.offset.relative.top-this.offset.parent.top, -(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){a=d(a.containment);var b=a[0];if(b){a.offset();var c=d(b).css("overflow")!= -"hidden";this.containment=[(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0),(parseInt(d(b).css("borderTopWidth"),10)||0)+(parseInt(d(b).css("paddingTop"),10)||0),(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left-this.margins.right,(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"), -10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top-this.margins.bottom];this.relative_container=a}}else if(a.containment.constructor==Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+ -this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&& -!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,h=a.pageY;if(this.originalPosition){var g;if(this.containment){if(this.relative_container){g=this.relative_container.offset();g=[this.containment[0]+g.left,this.containment[1]+g.top,this.containment[2]+g.left,this.containment[3]+g.top]}else g=this.containment;if(a.pageX-this.offset.click.leftg[2])e=g[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>g[3])h=g[3]+this.offset.click.top}if(b.grid){h=b.grid[1]?this.originalPageY+Math.round((h-this.originalPageY)/b.grid[1])*b.grid[1]:this.originalPageY;h=g?!(h-this.offset.click.topg[3])?h:!(h-this.offset.click.topg[2])?e:!(e-this.offset.click.left=0;i--){var j=c.snapElements[i].left,l=j+c.snapElements[i].width,k=c.snapElements[i].top,m=k+c.snapElements[i].height;if(j-e=j&&f<=l||h>=j&&h<=l||fl)&&(e>= -i&&e<=k||g>=i&&g<=k||ek);default:return false}};d.ui.ddmanager={current:null,droppables:{"default":[]},prepareOffsets:function(a,b){var c=d.ui.ddmanager.droppables[a.options.scope]||[],e=b?b.type:null,g=(a.currentItem||a.element).find(":data(droppable)").andSelf(),f=0;a:for(;f
').css({position:this.element.css("position"),width:this.element.outerWidth(),height:this.element.outerHeight(), -top:this.element.css("top"),left:this.element.css("left")}));this.element=this.element.parent().data("resizable",this.element.data("resizable"));this.elementIsWrapper=true;this.element.css({marginLeft:this.originalElement.css("marginLeft"),marginTop:this.originalElement.css("marginTop"),marginRight:this.originalElement.css("marginRight"),marginBottom:this.originalElement.css("marginBottom")});this.originalElement.css({marginLeft:0,marginTop:0,marginRight:0,marginBottom:0});this.originalResizeStyle= -this.originalElement.css("resize");this.originalElement.css("resize","none");this._proportionallyResizeElements.push(this.originalElement.css({position:"static",zoom:1,display:"block"}));this.originalElement.css({margin:this.originalElement.css("margin")});this._proportionallyResize()}this.handles=a.handles||(!e(".ui-resizable-handle",this.element).length?"e,s,se":{n:".ui-resizable-n",e:".ui-resizable-e",s:".ui-resizable-s",w:".ui-resizable-w",se:".ui-resizable-se",sw:".ui-resizable-sw",ne:".ui-resizable-ne", -nw:".ui-resizable-nw"});if(this.handles.constructor==String){if(this.handles=="all")this.handles="n,e,s,w,se,sw,ne,nw";var c=this.handles.split(",");this.handles={};for(var d=0;d');/sw|se|ne|nw/.test(f)&&g.css({zIndex:++a.zIndex});"se"==f&&g.addClass("ui-icon ui-icon-gripsmall-diagonal-se");this.handles[f]=".ui-resizable-"+f;this.element.append(g)}}this._renderAxis=function(h){h=h||this.element;for(var i in this.handles){if(this.handles[i].constructor== -String)this.handles[i]=e(this.handles[i],this.element).show();if(this.elementIsWrapper&&this.originalElement[0].nodeName.match(/textarea|input|select|button/i)){var j=e(this.handles[i],this.element),l=0;l=/sw|ne|nw|se|n|s/.test(i)?j.outerHeight():j.outerWidth();j=["padding",/ne|nw|n/.test(i)?"Top":/se|sw|s/.test(i)?"Bottom":/^e$/.test(i)?"Right":"Left"].join("");h.css(j,l);this._proportionallyResize()}e(this.handles[i])}};this._renderAxis(this.element);this._handles=e(".ui-resizable-handle",this.element).disableSelection(); -this._handles.mouseover(function(){if(!b.resizing){if(this.className)var h=this.className.match(/ui-resizable-(se|sw|ne|nw|n|e|s|w)/i);b.axis=h&&h[1]?h[1]:"se"}});if(a.autoHide){this._handles.hide();e(this.element).addClass("ui-resizable-autohide").hover(function(){if(!a.disabled){e(this).removeClass("ui-resizable-autohide");b._handles.show()}},function(){if(!a.disabled)if(!b.resizing){e(this).addClass("ui-resizable-autohide");b._handles.hide()}})}this._mouseInit()},destroy:function(){this._mouseDestroy(); -var b=function(c){e(c).removeClass("ui-resizable ui-resizable-disabled ui-resizable-resizing").removeData("resizable").unbind(".resizable").find(".ui-resizable-handle").remove()};if(this.elementIsWrapper){b(this.element);var a=this.element;a.after(this.originalElement.css({position:a.css("position"),width:a.outerWidth(),height:a.outerHeight(),top:a.css("top"),left:a.css("left")})).remove()}this.originalElement.css("resize",this.originalResizeStyle);b(this.originalElement);return this},_mouseCapture:function(b){var a= -false;for(var c in this.handles)if(e(this.handles[c])[0]==b.target)a=true;return!this.options.disabled&&a},_mouseStart:function(b){var a=this.options,c=this.element.position(),d=this.element;this.resizing=true;this.documentScroll={top:e(document).scrollTop(),left:e(document).scrollLeft()};if(d.is(".ui-draggable")||/absolute/.test(d.css("position")))d.css({position:"absolute",top:c.top,left:c.left});e.browser.opera&&/relative/.test(d.css("position"))&&d.css({position:"relative",top:"auto",left:"auto"}); -this._renderProxy();c=m(this.helper.css("left"));var f=m(this.helper.css("top"));if(a.containment){c+=e(a.containment).scrollLeft()||0;f+=e(a.containment).scrollTop()||0}this.offset=this.helper.offset();this.position={left:c,top:f};this.size=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalSize=this._helper?{width:d.outerWidth(),height:d.outerHeight()}:{width:d.width(),height:d.height()};this.originalPosition={left:c,top:f};this.sizeDiff= -{width:d.outerWidth()-d.width(),height:d.outerHeight()-d.height()};this.originalMousePosition={left:b.pageX,top:b.pageY};this.aspectRatio=typeof a.aspectRatio=="number"?a.aspectRatio:this.originalSize.width/this.originalSize.height||1;a=e(".ui-resizable-"+this.axis).css("cursor");e("body").css("cursor",a=="auto"?this.axis+"-resize":a);d.addClass("ui-resizable-resizing");this._propagate("start",b);return true},_mouseDrag:function(b){var a=this.helper,c=this.originalMousePosition,d=this._change[this.axis]; -if(!d)return false;c=d.apply(this,[b,b.pageX-c.left||0,b.pageY-c.top||0]);this._updateVirtualBoundaries(b.shiftKey);if(this._aspectRatio||b.shiftKey)c=this._updateRatio(c,b);c=this._respectSize(c,b);this._propagate("resize",b);a.css({top:this.position.top+"px",left:this.position.left+"px",width:this.size.width+"px",height:this.size.height+"px"});!this._helper&&this._proportionallyResizeElements.length&&this._proportionallyResize();this._updateCache(c);this._trigger("resize",b,this.ui());return false}, -_mouseStop:function(b){this.resizing=false;var a=this.options,c=this;if(this._helper){var d=this._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName);d=f&&e.ui.hasScroll(d[0],"left")?0:c.sizeDiff.height;f=f?0:c.sizeDiff.width;f={width:c.helper.width()-f,height:c.helper.height()-d};d=parseInt(c.element.css("left"),10)+(c.position.left-c.originalPosition.left)||null;var g=parseInt(c.element.css("top"),10)+(c.position.top-c.originalPosition.top)||null;a.animate||this.element.css(e.extend(f, -{top:g,left:d}));c.helper.height(c.size.height);c.helper.width(c.size.width);this._helper&&!a.animate&&this._proportionallyResize()}e("body").css("cursor","auto");this.element.removeClass("ui-resizable-resizing");this._propagate("stop",b);this._helper&&this.helper.remove();return false},_updateVirtualBoundaries:function(b){var a=this.options,c,d,f;a={minWidth:k(a.minWidth)?a.minWidth:0,maxWidth:k(a.maxWidth)?a.maxWidth:Infinity,minHeight:k(a.minHeight)?a.minHeight:0,maxHeight:k(a.maxHeight)?a.maxHeight: -Infinity};if(this._aspectRatio||b){b=a.minHeight*this.aspectRatio;d=a.minWidth/this.aspectRatio;c=a.maxHeight*this.aspectRatio;f=a.maxWidth/this.aspectRatio;if(b>a.minWidth)a.minWidth=b;if(d>a.minHeight)a.minHeight=d;if(cb.width,h=k(b.height)&&a.minHeight&&a.minHeight>b.height;if(g)b.width=a.minWidth;if(h)b.height=a.minHeight;if(d)b.width=a.maxWidth;if(f)b.height=a.maxHeight;var i=this.originalPosition.left+this.originalSize.width,j=this.position.top+this.size.height,l=/sw|nw|w/.test(c);c=/nw|ne|n/.test(c);if(g&&l)b.left=i-a.minWidth;if(d&&l)b.left=i-a.maxWidth;if(h&&c)b.top=j-a.minHeight;if(f&&c)b.top=j-a.maxHeight;if((a=!b.width&&!b.height)&&!b.left&&b.top)b.top=null;else if(a&&!b.top&&b.left)b.left= -null;return b},_proportionallyResize:function(){if(this._proportionallyResizeElements.length)for(var b=this.helper||this.element,a=0;a');var a=e.browser.msie&&e.browser.version<7,c=a?1:0;a=a?2:-1;this.helper.addClass(this._helper).css({width:this.element.outerWidth()+ -a,height:this.element.outerHeight()+a,position:"absolute",left:this.elementOffset.left-c+"px",top:this.elementOffset.top-c+"px",zIndex:++b.zIndex});this.helper.appendTo("body").disableSelection()}else this.helper=this.element},_change:{e:function(b,a){return{width:this.originalSize.width+a}},w:function(b,a){return{left:this.originalPosition.left+a,width:this.originalSize.width-a}},n:function(b,a,c){return{top:this.originalPosition.top+c,height:this.originalSize.height-c}},s:function(b,a,c){return{height:this.originalSize.height+ -c}},se:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},sw:function(b,a,c){return e.extend(this._change.s.apply(this,arguments),this._change.w.apply(this,[b,a,c]))},ne:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.e.apply(this,[b,a,c]))},nw:function(b,a,c){return e.extend(this._change.n.apply(this,arguments),this._change.w.apply(this,[b,a,c]))}},_propagate:function(b,a){e.ui.plugin.call(this,b,[a,this.ui()]); -b!="resize"&&this._trigger(b,a,this.ui())},plugins:{},ui:function(){return{originalElement:this.originalElement,element:this.element,helper:this.helper,position:this.position,size:this.size,originalSize:this.originalSize,originalPosition:this.originalPosition}}});e.extend(e.ui.resizable,{version:"1.8.16"});e.ui.plugin.add("resizable","alsoResize",{start:function(){var b=e(this).data("resizable").options,a=function(c){e(c).each(function(){var d=e(this);d.data("resizable-alsoresize",{width:parseInt(d.width(), -10),height:parseInt(d.height(),10),left:parseInt(d.css("left"),10),top:parseInt(d.css("top"),10),position:d.css("position")})})};if(typeof b.alsoResize=="object"&&!b.alsoResize.parentNode)if(b.alsoResize.length){b.alsoResize=b.alsoResize[0];a(b.alsoResize)}else e.each(b.alsoResize,function(c){a(c)});else a(b.alsoResize)},resize:function(b,a){var c=e(this).data("resizable");b=c.options;var d=c.originalSize,f=c.originalPosition,g={height:c.size.height-d.height||0,width:c.size.width-d.width||0,top:c.position.top- -f.top||0,left:c.position.left-f.left||0},h=function(i,j){e(i).each(function(){var l=e(this),q=e(this).data("resizable-alsoresize"),p={},r=j&&j.length?j:l.parents(a.originalElement[0]).length?["width","height"]:["width","height","top","left"];e.each(r,function(n,o){if((n=(q[o]||0)+(g[o]||0))&&n>=0)p[o]=n||null});if(e.browser.opera&&/relative/.test(l.css("position"))){c._revertToRelativePosition=true;l.css({position:"absolute",top:"auto",left:"auto"})}l.css(p)})};typeof b.alsoResize=="object"&&!b.alsoResize.nodeType? -e.each(b.alsoResize,function(i,j){h(i,j)}):h(b.alsoResize)},stop:function(){var b=e(this).data("resizable"),a=b.options,c=function(d){e(d).each(function(){var f=e(this);f.css({position:f.data("resizable-alsoresize").position})})};if(b._revertToRelativePosition){b._revertToRelativePosition=false;typeof a.alsoResize=="object"&&!a.alsoResize.nodeType?e.each(a.alsoResize,function(d){c(d)}):c(a.alsoResize)}e(this).removeData("resizable-alsoresize")}});e.ui.plugin.add("resizable","animate",{stop:function(b){var a= -e(this).data("resizable"),c=a.options,d=a._proportionallyResizeElements,f=d.length&&/textarea/i.test(d[0].nodeName),g=f&&e.ui.hasScroll(d[0],"left")?0:a.sizeDiff.height;f={width:a.size.width-(f?0:a.sizeDiff.width),height:a.size.height-g};g=parseInt(a.element.css("left"),10)+(a.position.left-a.originalPosition.left)||null;var h=parseInt(a.element.css("top"),10)+(a.position.top-a.originalPosition.top)||null;a.element.animate(e.extend(f,h&&g?{top:h,left:g}:{}),{duration:c.animateDuration,easing:c.animateEasing, -step:function(){var i={width:parseInt(a.element.css("width"),10),height:parseInt(a.element.css("height"),10),top:parseInt(a.element.css("top"),10),left:parseInt(a.element.css("left"),10)};d&&d.length&&e(d[0]).css({width:i.width,height:i.height});a._updateCache(i);a._propagate("resize",b)}})}});e.ui.plugin.add("resizable","containment",{start:function(){var b=e(this).data("resizable"),a=b.element,c=b.options.containment;if(a=c instanceof e?c.get(0):/parent/.test(c)?a.parent().get(0):c){b.containerElement= -e(a);if(/document/.test(c)||c==document){b.containerOffset={left:0,top:0};b.containerPosition={left:0,top:0};b.parentData={element:e(document),left:0,top:0,width:e(document).width(),height:e(document).height()||document.body.parentNode.scrollHeight}}else{var d=e(a),f=[];e(["Top","Right","Left","Bottom"]).each(function(i,j){f[i]=m(d.css("padding"+j))});b.containerOffset=d.offset();b.containerPosition=d.position();b.containerSize={height:d.innerHeight()-f[3],width:d.innerWidth()-f[1]};c=b.containerOffset; -var g=b.containerSize.height,h=b.containerSize.width;h=e.ui.hasScroll(a,"left")?a.scrollWidth:h;g=e.ui.hasScroll(a)?a.scrollHeight:g;b.parentData={element:a,left:c.left,top:c.top,width:h,height:g}}}},resize:function(b){var a=e(this).data("resizable"),c=a.options,d=a.containerOffset,f=a.position;b=a._aspectRatio||b.shiftKey;var g={top:0,left:0},h=a.containerElement;if(h[0]!=document&&/static/.test(h.css("position")))g=d;if(f.left<(a._helper?d.left:0)){a.size.width+=a._helper?a.position.left-d.left: -a.position.left-g.left;if(b)a.size.height=a.size.width/c.aspectRatio;a.position.left=c.helper?d.left:0}if(f.top<(a._helper?d.top:0)){a.size.height+=a._helper?a.position.top-d.top:a.position.top;if(b)a.size.width=a.size.height*c.aspectRatio;a.position.top=a._helper?d.top:0}a.offset.left=a.parentData.left+a.position.left;a.offset.top=a.parentData.top+a.position.top;c=Math.abs((a._helper?a.offset.left-g.left:a.offset.left-g.left)+a.sizeDiff.width);d=Math.abs((a._helper?a.offset.top-g.top:a.offset.top- -d.top)+a.sizeDiff.height);f=a.containerElement.get(0)==a.element.parent().get(0);g=/relative|absolute/.test(a.containerElement.css("position"));if(f&&g)c-=a.parentData.left;if(c+a.size.width>=a.parentData.width){a.size.width=a.parentData.width-c;if(b)a.size.height=a.size.width/a.aspectRatio}if(d+a.size.height>=a.parentData.height){a.size.height=a.parentData.height-d;if(b)a.size.width=a.size.height*a.aspectRatio}},stop:function(){var b=e(this).data("resizable"),a=b.options,c=b.containerOffset,d=b.containerPosition, -f=b.containerElement,g=e(b.helper),h=g.offset(),i=g.outerWidth()-b.sizeDiff.width;g=g.outerHeight()-b.sizeDiff.height;b._helper&&!a.animate&&/relative/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g});b._helper&&!a.animate&&/static/.test(f.css("position"))&&e(this).css({left:h.left-d.left-c.left,width:i,height:g})}});e.ui.plugin.add("resizable","ghost",{start:function(){var b=e(this).data("resizable"),a=b.options,c=b.size;b.ghost=b.originalElement.clone();b.ghost.css({opacity:0.25, -display:"block",position:"relative",height:c.height,width:c.width,margin:0,left:0,top:0}).addClass("ui-resizable-ghost").addClass(typeof a.ghost=="string"?a.ghost:"");b.ghost.appendTo(b.helper)},resize:function(){var b=e(this).data("resizable");b.ghost&&b.ghost.css({position:"relative",height:b.size.height,width:b.size.width})},stop:function(){var b=e(this).data("resizable");b.ghost&&b.helper&&b.helper.get(0).removeChild(b.ghost.get(0))}});e.ui.plugin.add("resizable","grid",{resize:function(){var b= -e(this).data("resizable"),a=b.options,c=b.size,d=b.originalSize,f=b.originalPosition,g=b.axis;a.grid=typeof a.grid=="number"?[a.grid,a.grid]:a.grid;var h=Math.round((c.width-d.width)/(a.grid[0]||1))*(a.grid[0]||1);a=Math.round((c.height-d.height)/(a.grid[1]||1))*(a.grid[1]||1);if(/^(se|s|e)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a}else if(/^(ne)$/.test(g)){b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}else{if(/^(sw)$/.test(g)){b.size.width=d.width+h;b.size.height= -d.height+a}else{b.size.width=d.width+h;b.size.height=d.height+a;b.position.top=f.top-a}b.position.left=f.left-h}}});var m=function(b){return parseInt(b,10)||0},k=function(b){return!isNaN(parseInt(b,10))}})(jQuery); -;/* - * jQuery UI Selectable 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Selectables - * - * Depends: - * jquery.ui.core.js - * jquery.ui.mouse.js - * jquery.ui.widget.js - */ -(function(e){e.widget("ui.selectable",e.ui.mouse,{options:{appendTo:"body",autoRefresh:true,distance:0,filter:"*",tolerance:"touch"},_create:function(){var c=this;this.element.addClass("ui-selectable");this.dragged=false;var f;this.refresh=function(){f=e(c.options.filter,c.element[0]);f.each(function(){var d=e(this),b=d.offset();e.data(this,"selectable-item",{element:this,$element:d,left:b.left,top:b.top,right:b.left+d.outerWidth(),bottom:b.top+d.outerHeight(),startselected:false,selected:d.hasClass("ui-selected"), -selecting:d.hasClass("ui-selecting"),unselecting:d.hasClass("ui-unselecting")})})};this.refresh();this.selectees=f.addClass("ui-selectee");this._mouseInit();this.helper=e("
")},destroy:function(){this.selectees.removeClass("ui-selectee").removeData("selectable-item");this.element.removeClass("ui-selectable ui-selectable-disabled").removeData("selectable").unbind(".selectable");this._mouseDestroy();return this},_mouseStart:function(c){var f=this;this.opos=[c.pageX, -c.pageY];if(!this.options.disabled){var d=this.options;this.selectees=e(d.filter,this.element[0]);this._trigger("start",c);e(d.appendTo).append(this.helper);this.helper.css({left:c.clientX,top:c.clientY,width:0,height:0});d.autoRefresh&&this.refresh();this.selectees.filter(".ui-selected").each(function(){var b=e.data(this,"selectable-item");b.startselected=true;if(!c.metaKey){b.$element.removeClass("ui-selected");b.selected=false;b.$element.addClass("ui-unselecting");b.unselecting=true;f._trigger("unselecting", -c,{unselecting:b.element})}});e(c.target).parents().andSelf().each(function(){var b=e.data(this,"selectable-item");if(b){var g=!c.metaKey||!b.$element.hasClass("ui-selected");b.$element.removeClass(g?"ui-unselecting":"ui-selected").addClass(g?"ui-selecting":"ui-unselecting");b.unselecting=!g;b.selecting=g;(b.selected=g)?f._trigger("selecting",c,{selecting:b.element}):f._trigger("unselecting",c,{unselecting:b.element});return false}})}},_mouseDrag:function(c){var f=this;this.dragged=true;if(!this.options.disabled){var d= -this.options,b=this.opos[0],g=this.opos[1],h=c.pageX,i=c.pageY;if(b>h){var j=h;h=b;b=j}if(g>i){j=i;i=g;g=j}this.helper.css({left:b,top:g,width:h-b,height:i-g});this.selectees.each(function(){var a=e.data(this,"selectable-item");if(!(!a||a.element==f.element[0])){var k=false;if(d.tolerance=="touch")k=!(a.left>h||a.righti||a.bottomb&&a.rightg&&a.bottom *",opacity:false,placeholder:false,revert:false,scroll:true,scrollSensitivity:20,scrollSpeed:20,scope:"default",tolerance:"intersect",zIndex:1E3},_create:function(){var a=this.options;this.containerCache={};this.element.addClass("ui-sortable"); -this.refresh();this.floating=this.items.length?a.axis==="x"||/left|right/.test(this.items[0].item.css("float"))||/inline|table-cell/.test(this.items[0].item.css("display")):false;this.offset=this.element.offset();this._mouseInit()},destroy:function(){this.element.removeClass("ui-sortable ui-sortable-disabled").removeData("sortable").unbind(".sortable");this._mouseDestroy();for(var a=this.items.length-1;a>=0;a--)this.items[a].item.removeData("sortable-item");return this},_setOption:function(a,b){if(a=== -"disabled"){this.options[a]=b;this.widget()[b?"addClass":"removeClass"]("ui-sortable-disabled")}else d.Widget.prototype._setOption.apply(this,arguments)},_mouseCapture:function(a,b){if(this.reverting)return false;if(this.options.disabled||this.options.type=="static")return false;this._refreshItems(a);var c=null,e=this;d(a.target).parents().each(function(){if(d.data(this,"sortable-item")==e){c=d(this);return false}});if(d.data(a.target,"sortable-item")==e)c=d(a.target);if(!c)return false;if(this.options.handle&& -!b){var f=false;d(this.options.handle,c).find("*").andSelf().each(function(){if(this==a.target)f=true});if(!f)return false}this.currentItem=c;this._removeCurrentsFromItems();return true},_mouseStart:function(a,b,c){b=this.options;var e=this;this.currentContainer=this;this.refreshPositions();this.helper=this._createHelper(a);this._cacheHelperProportions();this._cacheMargins();this.scrollParent=this.helper.scrollParent();this.offset=this.currentItem.offset();this.offset={top:this.offset.top-this.margins.top, -left:this.offset.left-this.margins.left};this.helper.css("position","absolute");this.cssPosition=this.helper.css("position");d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);this.domPosition={prev:this.currentItem.prev()[0],parent:this.currentItem.parent()[0]}; -this.helper[0]!=this.currentItem[0]&&this.currentItem.hide();this._createPlaceholder();b.containment&&this._setContainment();if(b.cursor){if(d("body").css("cursor"))this._storedCursor=d("body").css("cursor");d("body").css("cursor",b.cursor)}if(b.opacity){if(this.helper.css("opacity"))this._storedOpacity=this.helper.css("opacity");this.helper.css("opacity",b.opacity)}if(b.zIndex){if(this.helper.css("zIndex"))this._storedZIndex=this.helper.css("zIndex");this.helper.css("zIndex",b.zIndex)}if(this.scrollParent[0]!= -document&&this.scrollParent[0].tagName!="HTML")this.overflowOffset=this.scrollParent.offset();this._trigger("start",a,this._uiHash());this._preserveHelperProportions||this._cacheHelperProportions();if(!c)for(c=this.containers.length-1;c>=0;c--)this.containers[c]._trigger("activate",a,e._uiHash(this));if(d.ui.ddmanager)d.ui.ddmanager.current=this;d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.dragging=true;this.helper.addClass("ui-sortable-helper");this._mouseDrag(a); -return true},_mouseDrag:function(a){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!this.lastPositionAbs)this.lastPositionAbs=this.positionAbs;if(this.options.scroll){var b=this.options,c=false;if(this.scrollParent[0]!=document&&this.scrollParent[0].tagName!="HTML"){if(this.overflowOffset.top+this.scrollParent[0].offsetHeight-a.pageY=0;b--){c=this.items[b];var e=c.item[0],f=this._intersectsWithPointer(c);if(f)if(e!=this.currentItem[0]&&this.placeholder[f==1?"next":"prev"]()[0]!=e&&!d.ui.contains(this.placeholder[0],e)&&(this.options.type=="semi-dynamic"?!d.ui.contains(this.element[0], -e):true)){this.direction=f==1?"down":"up";if(this.options.tolerance=="pointer"||this._intersectsWithSides(c))this._rearrange(a,c);else break;this._trigger("change",a,this._uiHash());break}}this._contactContainers(a);d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);this._trigger("sort",a,this._uiHash());this.lastPositionAbs=this.positionAbs;return false},_mouseStop:function(a,b){if(a){d.ui.ddmanager&&!this.options.dropBehaviour&&d.ui.ddmanager.drop(this,a);if(this.options.revert){var c=this;b=c.placeholder.offset(); -c.reverting=true;d(this.helper).animate({left:b.left-this.offset.parent.left-c.margins.left+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollLeft),top:b.top-this.offset.parent.top-c.margins.top+(this.offsetParent[0]==document.body?0:this.offsetParent[0].scrollTop)},parseInt(this.options.revert,10)||500,function(){c._clear(a)})}else this._clear(a,b);return false}},cancel:function(){var a=this;if(this.dragging){this._mouseUp({target:null});this.options.helper=="original"?this.currentItem.css(this._storedCSS).removeClass("ui-sortable-helper"): -this.currentItem.show();for(var b=this.containers.length-1;b>=0;b--){this.containers[b]._trigger("deactivate",null,a._uiHash(this));if(this.containers[b].containerCache.over){this.containers[b]._trigger("out",null,a._uiHash(this));this.containers[b].containerCache.over=0}}}if(this.placeholder){this.placeholder[0].parentNode&&this.placeholder[0].parentNode.removeChild(this.placeholder[0]);this.options.helper!="original"&&this.helper&&this.helper[0].parentNode&&this.helper.remove();d.extend(this,{helper:null, -dragging:false,reverting:false,_noFinalSort:null});this.domPosition.prev?d(this.domPosition.prev).after(this.currentItem):d(this.domPosition.parent).prepend(this.currentItem)}return this},serialize:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};d(b).each(function(){var e=(d(a.item||this).attr(a.attribute||"id")||"").match(a.expression||/(.+)[-=_](.+)/);if(e)c.push((a.key||e[1]+"[]")+"="+(a.key&&a.expression?e[1]:e[2]))});!c.length&&a.key&&c.push(a.key+"=");return c.join("&")}, -toArray:function(a){var b=this._getItemsAsjQuery(a&&a.connected),c=[];a=a||{};b.each(function(){c.push(d(a.item||this).attr(a.attribute||"id")||"")});return c},_intersectsWith:function(a){var b=this.positionAbs.left,c=b+this.helperProportions.width,e=this.positionAbs.top,f=e+this.helperProportions.height,g=a.left,h=g+a.width,i=a.top,k=i+a.height,j=this.offset.click.top,l=this.offset.click.left;j=e+j>i&&e+jg&&b+la[this.floating?"width":"height"]?j:g0?"down":"up")},_getDragHorizontalDirection:function(){var a=this.positionAbs.left-this.lastPositionAbs.left;return a!=0&&(a>0?"right":"left")},refresh:function(a){this._refreshItems(a);this.refreshPositions();return this},_connectWith:function(){var a=this.options;return a.connectWith.constructor==String?[a.connectWith]:a.connectWith},_getItemsAsjQuery:function(a){var b=[],c=[],e=this._connectWith(); -if(e&&a)for(a=e.length-1;a>=0;a--)for(var f=d(e[a]),g=f.length-1;g>=0;g--){var h=d.data(f[g],"sortable");if(h&&h!=this&&!h.options.disabled)c.push([d.isFunction(h.options.items)?h.options.items.call(h.element):d(h.options.items,h.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"),h])}c.push([d.isFunction(this.options.items)?this.options.items.call(this.element,null,{options:this.options,item:this.currentItem}):d(this.options.items,this.element).not(".ui-sortable-helper").not(".ui-sortable-placeholder"), -this]);for(a=c.length-1;a>=0;a--)c[a][0].each(function(){b.push(this)});return d(b)},_removeCurrentsFromItems:function(){for(var a=this.currentItem.find(":data(sortable-item)"),b=0;b=0;f--)for(var g=d(e[f]),h=g.length-1;h>=0;h--){var i=d.data(g[h],"sortable");if(i&&i!=this&&!i.options.disabled){c.push([d.isFunction(i.options.items)?i.options.items.call(i.element[0],a,{item:this.currentItem}):d(i.options.items,i.element),i]);this.containers.push(i)}}for(f=c.length-1;f>=0;f--){a=c[f][1];e=c[f][0];h=0;for(g=e.length;h=0;b--){var c=this.items[b];if(!(c.instance!=this.currentContainer&&this.currentContainer&&c.item[0]!=this.currentItem[0])){var e=this.options.toleranceElement?d(this.options.toleranceElement,c.item):c.item;if(!a){c.width=e.outerWidth();c.height=e.outerHeight()}e=e.offset();c.left=e.left;c.top=e.top}}if(this.options.custom&&this.options.custom.refreshContainers)this.options.custom.refreshContainers.call(this);else for(b= -this.containers.length-1;b>=0;b--){e=this.containers[b].element.offset();this.containers[b].containerCache.left=e.left;this.containers[b].containerCache.top=e.top;this.containers[b].containerCache.width=this.containers[b].element.outerWidth();this.containers[b].containerCache.height=this.containers[b].element.outerHeight()}return this},_createPlaceholder:function(a){var b=a||this,c=b.options;if(!c.placeholder||c.placeholder.constructor==String){var e=c.placeholder;c.placeholder={element:function(){var f= -d(document.createElement(b.currentItem[0].nodeName)).addClass(e||b.currentItem[0].className+" ui-sortable-placeholder").removeClass("ui-sortable-helper")[0];if(!e)f.style.visibility="hidden";return f},update:function(f,g){if(!(e&&!c.forcePlaceholderSize)){g.height()||g.height(b.currentItem.innerHeight()-parseInt(b.currentItem.css("paddingTop")||0,10)-parseInt(b.currentItem.css("paddingBottom")||0,10));g.width()||g.width(b.currentItem.innerWidth()-parseInt(b.currentItem.css("paddingLeft")||0,10)-parseInt(b.currentItem.css("paddingRight")|| -0,10))}}}}b.placeholder=d(c.placeholder.element.call(b.element,b.currentItem));b.currentItem.after(b.placeholder);c.placeholder.update(b,b.placeholder)},_contactContainers:function(a){for(var b=null,c=null,e=this.containers.length-1;e>=0;e--)if(!d.ui.contains(this.currentItem[0],this.containers[e].element[0]))if(this._intersectsWith(this.containers[e].containerCache)){if(!(b&&d.ui.contains(this.containers[e].element[0],b.element[0]))){b=this.containers[e];c=e}}else if(this.containers[e].containerCache.over){this.containers[e]._trigger("out", -a,this._uiHash(this));this.containers[e].containerCache.over=0}if(b)if(this.containers.length===1){this.containers[c]._trigger("over",a,this._uiHash(this));this.containers[c].containerCache.over=1}else if(this.currentContainer!=this.containers[c]){b=1E4;e=null;for(var f=this.positionAbs[this.containers[c].floating?"left":"top"],g=this.items.length-1;g>=0;g--)if(d.ui.contains(this.containers[c].element[0],this.items[g].item[0])){var h=this.items[g][this.containers[c].floating?"left":"top"];if(Math.abs(h- -f)this.containment[2])f=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g- -this.originalPageY)/b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.topthis.containment[3])?g:!(g-this.offset.click.topthis.containment[2])?f:!(f-this.offset.click.left=0;e--)if(d.ui.contains(this.containers[e].element[0],this.currentItem[0])&&!b){c.push(function(f){return function(g){f._trigger("receive",g,this._uiHash(this))}}.call(this,this.containers[e]));c.push(function(f){return function(g){f._trigger("update",g,this._uiHash(this))}}.call(this,this.containers[e]))}}for(e=this.containers.length-1;e>=0;e--){b||c.push(function(f){return function(g){f._trigger("deactivate",g,this._uiHash(this))}}.call(this, -this.containers[e]));if(this.containers[e].containerCache.over){c.push(function(f){return function(g){f._trigger("out",g,this._uiHash(this))}}.call(this,this.containers[e]));this.containers[e].containerCache.over=0}}this._storedCursor&&d("body").css("cursor",this._storedCursor);this._storedOpacity&&this.helper.css("opacity",this._storedOpacity);if(this._storedZIndex)this.helper.css("zIndex",this._storedZIndex=="auto"?"":this._storedZIndex);this.dragging=false;if(this.cancelHelperRemoval){if(!b){this._trigger("beforeStop", -a,this._uiHash());for(e=0;e li > :first-child,> :not(li):even",icons:{header:"ui-icon-triangle-1-e",headerSelected:"ui-icon-triangle-1-s"},navigation:false,navigationFilter:function(){return this.href.toLowerCase()===location.href.toLowerCase()}},_create:function(){var a=this,b=a.options;a.running=0;a.element.addClass("ui-accordion ui-widget ui-helper-reset").children("li").addClass("ui-accordion-li-fix"); -a.headers=a.element.find(b.header).addClass("ui-accordion-header ui-helper-reset ui-state-default ui-corner-all").bind("mouseenter.accordion",function(){b.disabled||c(this).addClass("ui-state-hover")}).bind("mouseleave.accordion",function(){b.disabled||c(this).removeClass("ui-state-hover")}).bind("focus.accordion",function(){b.disabled||c(this).addClass("ui-state-focus")}).bind("blur.accordion",function(){b.disabled||c(this).removeClass("ui-state-focus")});a.headers.next().addClass("ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom"); -if(b.navigation){var d=a.element.find("a").filter(b.navigationFilter).eq(0);if(d.length){var h=d.closest(".ui-accordion-header");a.active=h.length?h:d.closest(".ui-accordion-content").prev()}}a.active=a._findActive(a.active||b.active).addClass("ui-state-default ui-state-active").toggleClass("ui-corner-all").toggleClass("ui-corner-top");a.active.next().addClass("ui-accordion-content-active");a._createIcons();a.resize();a.element.attr("role","tablist");a.headers.attr("role","tab").bind("keydown.accordion", -function(f){return a._keydown(f)}).next().attr("role","tabpanel");a.headers.not(a.active||"").attr({"aria-expanded":"false","aria-selected":"false",tabIndex:-1}).next().hide();a.active.length?a.active.attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}):a.headers.eq(0).attr("tabIndex",0);c.browser.safari||a.headers.find("a").attr("tabIndex",-1);b.event&&a.headers.bind(b.event.split(" ").join(".accordion ")+".accordion",function(f){a._clickHandler.call(a,f,this);f.preventDefault()})},_createIcons:function(){var a= -this.options;if(a.icons){c("").addClass("ui-icon "+a.icons.header).prependTo(this.headers);this.active.children(".ui-icon").toggleClass(a.icons.header).toggleClass(a.icons.headerSelected);this.element.addClass("ui-accordion-icons")}},_destroyIcons:function(){this.headers.children(".ui-icon").remove();this.element.removeClass("ui-accordion-icons")},destroy:function(){var a=this.options;this.element.removeClass("ui-accordion ui-widget ui-helper-reset").removeAttr("role");this.headers.unbind(".accordion").removeClass("ui-accordion-header ui-accordion-disabled ui-helper-reset ui-state-default ui-corner-all ui-state-active ui-state-disabled ui-corner-top").removeAttr("role").removeAttr("aria-expanded").removeAttr("aria-selected").removeAttr("tabIndex"); -this.headers.find("a").removeAttr("tabIndex");this._destroyIcons();var b=this.headers.next().css("display","").removeAttr("role").removeClass("ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content ui-accordion-content-active ui-accordion-disabled ui-state-disabled");if(a.autoHeight||a.fillHeight)b.css("height","");return c.Widget.prototype.destroy.call(this)},_setOption:function(a,b){c.Widget.prototype._setOption.apply(this,arguments);a=="active"&&this.activate(b);if(a=="icons"){this._destroyIcons(); -b&&this._createIcons()}if(a=="disabled")this.headers.add(this.headers.next())[b?"addClass":"removeClass"]("ui-accordion-disabled ui-state-disabled")},_keydown:function(a){if(!(this.options.disabled||a.altKey||a.ctrlKey)){var b=c.ui.keyCode,d=this.headers.length,h=this.headers.index(a.target),f=false;switch(a.keyCode){case b.RIGHT:case b.DOWN:f=this.headers[(h+1)%d];break;case b.LEFT:case b.UP:f=this.headers[(h-1+d)%d];break;case b.SPACE:case b.ENTER:this._clickHandler({target:a.target},a.target); -a.preventDefault()}if(f){c(a.target).attr("tabIndex",-1);c(f).attr("tabIndex",0);f.focus();return false}return true}},resize:function(){var a=this.options,b;if(a.fillSpace){if(c.browser.msie){var d=this.element.parent().css("overflow");this.element.parent().css("overflow","hidden")}b=this.element.parent().height();c.browser.msie&&this.element.parent().css("overflow",d);this.headers.each(function(){b-=c(this).outerHeight(true)});this.headers.next().each(function(){c(this).height(Math.max(0,b-c(this).innerHeight()+ -c(this).height()))}).css("overflow","auto")}else if(a.autoHeight){b=0;this.headers.next().each(function(){b=Math.max(b,c(this).height("").height())}).height(b)}return this},activate:function(a){this.options.active=a;a=this._findActive(a)[0];this._clickHandler({target:a},a);return this},_findActive:function(a){return a?typeof a==="number"?this.headers.filter(":eq("+a+")"):this.headers.not(this.headers.not(a)):a===false?c([]):this.headers.filter(":eq(0)")},_clickHandler:function(a,b){var d=this.options; -if(!d.disabled)if(a.target){a=c(a.currentTarget||b);b=a[0]===this.active[0];d.active=d.collapsible&&b?false:this.headers.index(a);if(!(this.running||!d.collapsible&&b)){var h=this.active;j=a.next();g=this.active.next();e={options:d,newHeader:b&&d.collapsible?c([]):a,oldHeader:this.active,newContent:b&&d.collapsible?c([]):j,oldContent:g};var f=this.headers.index(this.active[0])>this.headers.index(a[0]);this.active=b?c([]):a;this._toggle(j,g,e,b,f);h.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header); -if(!b){a.removeClass("ui-state-default ui-corner-all").addClass("ui-state-active ui-corner-top").children(".ui-icon").removeClass(d.icons.header).addClass(d.icons.headerSelected);a.next().addClass("ui-accordion-content-active")}}}else if(d.collapsible){this.active.removeClass("ui-state-active ui-corner-top").addClass("ui-state-default ui-corner-all").children(".ui-icon").removeClass(d.icons.headerSelected).addClass(d.icons.header);this.active.next().addClass("ui-accordion-content-active");var g=this.active.next(), -e={options:d,newHeader:c([]),oldHeader:d.active,newContent:c([]),oldContent:g},j=this.active=c([]);this._toggle(j,g,e)}},_toggle:function(a,b,d,h,f){var g=this,e=g.options;g.toShow=a;g.toHide=b;g.data=d;var j=function(){if(g)return g._completed.apply(g,arguments)};g._trigger("changestart",null,g.data);g.running=b.size()===0?a.size():b.size();if(e.animated){d={};d=e.collapsible&&h?{toShow:c([]),toHide:b,complete:j,down:f,autoHeight:e.autoHeight||e.fillSpace}:{toShow:a,toHide:b,complete:j,down:f,autoHeight:e.autoHeight|| -e.fillSpace};if(!e.proxied)e.proxied=e.animated;if(!e.proxiedDuration)e.proxiedDuration=e.duration;e.animated=c.isFunction(e.proxied)?e.proxied(d):e.proxied;e.duration=c.isFunction(e.proxiedDuration)?e.proxiedDuration(d):e.proxiedDuration;h=c.ui.accordion.animations;var i=e.duration,k=e.animated;if(k&&!h[k]&&!c.easing[k])k="slide";h[k]||(h[k]=function(l){this.slide(l,{easing:k,duration:i||700})});h[k](d)}else{if(e.collapsible&&h)a.toggle();else{b.hide();a.show()}j(true)}b.prev().attr({"aria-expanded":"false", -"aria-selected":"false",tabIndex:-1}).blur();a.prev().attr({"aria-expanded":"true","aria-selected":"true",tabIndex:0}).focus()},_completed:function(a){this.running=a?0:--this.running;if(!this.running){this.options.clearStyle&&this.toShow.add(this.toHide).css({height:"",overflow:""});this.toHide.removeClass("ui-accordion-content-active");if(this.toHide.length)this.toHide.parent()[0].className=this.toHide.parent()[0].className;this._trigger("change",null,this.data)}}});c.extend(c.ui.accordion,{version:"1.8.16", -animations:{slide:function(a,b){a=c.extend({easing:"swing",duration:300},a,b);if(a.toHide.size())if(a.toShow.size()){var d=a.toShow.css("overflow"),h=0,f={},g={},e;b=a.toShow;e=b[0].style.width;b.width(parseInt(b.parent().width(),10)-parseInt(b.css("paddingLeft"),10)-parseInt(b.css("paddingRight"),10)-(parseInt(b.css("borderLeftWidth"),10)||0)-(parseInt(b.css("borderRightWidth"),10)||0));c.each(["height","paddingTop","paddingBottom"],function(j,i){g[i]="hide";j=(""+c.css(a.toShow[0],i)).match(/^([\d+-.]+)(.*)$/); -f[i]={value:j[1],unit:j[2]||"px"}});a.toShow.css({height:0,overflow:"hidden"}).show();a.toHide.filter(":hidden").each(a.complete).end().filter(":visible").animate(g,{step:function(j,i){if(i.prop=="height")h=i.end-i.start===0?0:(i.now-i.start)/(i.end-i.start);a.toShow[0].style[i.prop]=h*f[i.prop].value+f[i.prop].unit},duration:a.duration,easing:a.easing,complete:function(){a.autoHeight||a.toShow.css("height","");a.toShow.css({width:e,overflow:d});a.complete()}})}else a.toHide.animate({height:"hide", -paddingTop:"hide",paddingBottom:"hide"},a);else a.toShow.animate({height:"show",paddingTop:"show",paddingBottom:"show"},a)},bounceslide:function(a){this.slide(a,{easing:a.down?"easeOutBounce":"swing",duration:a.down?1E3:200})}}})})(jQuery); -;/* - * jQuery UI Autocomplete 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Autocomplete - * - * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js - * jquery.ui.position.js - */ -(function(d){var e=0;d.widget("ui.autocomplete",{options:{appendTo:"body",autoFocus:false,delay:300,minLength:1,position:{my:"left top",at:"left bottom",collision:"none"},source:null},pending:0,_create:function(){var a=this,b=this.element[0].ownerDocument,g;this.element.addClass("ui-autocomplete-input").attr("autocomplete","off").attr({role:"textbox","aria-autocomplete":"list","aria-haspopup":"true"}).bind("keydown.autocomplete",function(c){if(!(a.options.disabled||a.element.propAttr("readOnly"))){g= -false;var f=d.ui.keyCode;switch(c.keyCode){case f.PAGE_UP:a._move("previousPage",c);break;case f.PAGE_DOWN:a._move("nextPage",c);break;case f.UP:a._move("previous",c);c.preventDefault();break;case f.DOWN:a._move("next",c);c.preventDefault();break;case f.ENTER:case f.NUMPAD_ENTER:if(a.menu.active){g=true;c.preventDefault()}case f.TAB:if(!a.menu.active)return;a.menu.select(c);break;case f.ESCAPE:a.element.val(a.term);a.close(c);break;default:clearTimeout(a.searching);a.searching=setTimeout(function(){if(a.term!= -a.element.val()){a.selectedItem=null;a.search(null,c)}},a.options.delay);break}}}).bind("keypress.autocomplete",function(c){if(g){g=false;c.preventDefault()}}).bind("focus.autocomplete",function(){if(!a.options.disabled){a.selectedItem=null;a.previous=a.element.val()}}).bind("blur.autocomplete",function(c){if(!a.options.disabled){clearTimeout(a.searching);a.closing=setTimeout(function(){a.close(c);a._change(c)},150)}});this._initSource();this.response=function(){return a._response.apply(a,arguments)}; -this.menu=d("
    ").addClass("ui-autocomplete").appendTo(d(this.options.appendTo||"body",b)[0]).mousedown(function(c){var f=a.menu.element[0];d(c.target).closest(".ui-menu-item").length||setTimeout(function(){d(document).one("mousedown",function(h){h.target!==a.element[0]&&h.target!==f&&!d.ui.contains(f,h.target)&&a.close()})},1);setTimeout(function(){clearTimeout(a.closing)},13)}).menu({focus:function(c,f){f=f.item.data("item.autocomplete");false!==a._trigger("focus",c,{item:f})&&/^key/.test(c.originalEvent.type)&& -a.element.val(f.value)},selected:function(c,f){var h=f.item.data("item.autocomplete"),i=a.previous;if(a.element[0]!==b.activeElement){a.element.focus();a.previous=i;setTimeout(function(){a.previous=i;a.selectedItem=h},1)}false!==a._trigger("select",c,{item:h})&&a.element.val(h.value);a.term=a.element.val();a.close(c);a.selectedItem=h},blur:function(){a.menu.element.is(":visible")&&a.element.val()!==a.term&&a.element.val(a.term)}}).zIndex(this.element.zIndex()+1).css({top:0,left:0}).hide().data("menu"); -d.fn.bgiframe&&this.menu.element.bgiframe()},destroy:function(){this.element.removeClass("ui-autocomplete-input").removeAttr("autocomplete").removeAttr("role").removeAttr("aria-autocomplete").removeAttr("aria-haspopup");this.menu.element.remove();d.Widget.prototype.destroy.call(this)},_setOption:function(a,b){d.Widget.prototype._setOption.apply(this,arguments);a==="source"&&this._initSource();if(a==="appendTo")this.menu.element.appendTo(d(b||"body",this.element[0].ownerDocument)[0]);a==="disabled"&& -b&&this.xhr&&this.xhr.abort()},_initSource:function(){var a=this,b,g;if(d.isArray(this.options.source)){b=this.options.source;this.source=function(c,f){f(d.ui.autocomplete.filter(b,c.term))}}else if(typeof this.options.source==="string"){g=this.options.source;this.source=function(c,f){a.xhr&&a.xhr.abort();a.xhr=d.ajax({url:g,data:c,dataType:"json",autocompleteRequest:++e,success:function(h){this.autocompleteRequest===e&&f(h)},error:function(){this.autocompleteRequest===e&&f([])}})}}else this.source= -this.options.source},search:function(a,b){a=a!=null?a:this.element.val();this.term=this.element.val();if(a.length").data("item.autocomplete",b).append(d("").text(b.label)).appendTo(a)},_move:function(a,b){if(this.menu.element.is(":visible"))if(this.menu.first()&&/^previous/.test(a)||this.menu.last()&&/^next/.test(a)){this.element.val(this.term);this.menu.deactivate()}else this.menu[a](b);else this.search(null,b)},widget:function(){return this.menu.element}});d.extend(d.ui.autocomplete,{escapeRegex:function(a){return a.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, -"\\$&")},filter:function(a,b){var g=new RegExp(d.ui.autocomplete.escapeRegex(b),"i");return d.grep(a,function(c){return g.test(c.label||c.value||c)})}})})(jQuery); -(function(d){d.widget("ui.menu",{_create:function(){var e=this;this.element.addClass("ui-menu ui-widget ui-widget-content ui-corner-all").attr({role:"listbox","aria-activedescendant":"ui-active-menuitem"}).click(function(a){if(d(a.target).closest(".ui-menu-item a").length){a.preventDefault();e.select(a)}});this.refresh()},refresh:function(){var e=this;this.element.children("li:not(.ui-menu-item):has(a)").addClass("ui-menu-item").attr("role","menuitem").children("a").addClass("ui-corner-all").attr("tabindex", --1).mouseenter(function(a){e.activate(a,d(this).parent())}).mouseleave(function(){e.deactivate()})},activate:function(e,a){this.deactivate();if(this.hasScroll()){var b=a.offset().top-this.element.offset().top,g=this.element.scrollTop(),c=this.element.height();if(b<0)this.element.scrollTop(g+b);else b>=c&&this.element.scrollTop(g+b-c+a.height())}this.active=a.eq(0).children("a").addClass("ui-state-hover").attr("id","ui-active-menuitem").end();this._trigger("focus",e,{item:a})},deactivate:function(){if(this.active){this.active.children("a").removeClass("ui-state-hover").removeAttr("id"); -this._trigger("blur");this.active=null}},next:function(e){this.move("next",".ui-menu-item:first",e)},previous:function(e){this.move("prev",".ui-menu-item:last",e)},first:function(){return this.active&&!this.active.prevAll(".ui-menu-item").length},last:function(){return this.active&&!this.active.nextAll(".ui-menu-item").length},move:function(e,a,b){if(this.active){e=this.active[e+"All"](".ui-menu-item").eq(0);e.length?this.activate(b,e):this.activate(b,this.element.children(a))}else this.activate(b, -this.element.children(a))},nextPage:function(e){if(this.hasScroll())if(!this.active||this.last())this.activate(e,this.element.children(".ui-menu-item:first"));else{var a=this.active.offset().top,b=this.element.height(),g=this.element.children(".ui-menu-item").filter(function(){var c=d(this).offset().top-a-b+d(this).height();return c<10&&c>-10});g.length||(g=this.element.children(".ui-menu-item:last"));this.activate(e,g)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active|| -this.last()?":first":":last"))},previousPage:function(e){if(this.hasScroll())if(!this.active||this.first())this.activate(e,this.element.children(".ui-menu-item:last"));else{var a=this.active.offset().top,b=this.element.height();result=this.element.children(".ui-menu-item").filter(function(){var g=d(this).offset().top-a+b-d(this).height();return g<10&&g>-10});result.length||(result=this.element.children(".ui-menu-item:first"));this.activate(e,result)}else this.activate(e,this.element.children(".ui-menu-item").filter(!this.active|| -this.first()?":last":":first"))},hasScroll:function(){return this.element.height()").addClass("ui-button-text").html(this.options.label).appendTo(a.empty()).text(),e=this.options.icons,f=e.primary&&e.secondary,d=[];if(e.primary||e.secondary){if(this.options.text)d.push("ui-button-text-icon"+(f?"s":e.primary?"-primary":"-secondary"));e.primary&&a.prepend("");e.secondary&&a.append("");if(!this.options.text){d.push(f?"ui-button-icons-only": -"ui-button-icon-only");this.hasTitle||a.attr("title",c)}}else d.push("ui-button-text-only");a.addClass(d.join(" "))}}});b.widget("ui.buttonset",{options:{items:":button, :submit, :reset, :checkbox, :radio, a, :data(button)"},_create:function(){this.element.addClass("ui-buttonset")},_init:function(){this.refresh()},_setOption:function(a,c){a==="disabled"&&this.buttons.button("option",a,c);b.Widget.prototype._setOption.apply(this,arguments)},refresh:function(){var a=this.element.css("direction")=== -"ltr";this.buttons=this.element.find(this.options.items).filter(":ui-button").button("refresh").end().not(":ui-button").button().end().map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-all ui-corner-left ui-corner-right").filter(":first").addClass(a?"ui-corner-left":"ui-corner-right").end().filter(":last").addClass(a?"ui-corner-right":"ui-corner-left").end().end()},destroy:function(){this.element.removeClass("ui-buttonset");this.buttons.map(function(){return b(this).button("widget")[0]}).removeClass("ui-corner-left ui-corner-right").end().button("destroy"); -b.Widget.prototype.destroy.call(this)}})})(jQuery); -;/* - * jQuery UI Dialog 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Dialog - * - * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js - * jquery.ui.button.js - * jquery.ui.draggable.js - * jquery.ui.mouse.js - * jquery.ui.position.js - * jquery.ui.resizable.js - */ -(function(c,l){var m={buttons:true,height:true,maxHeight:true,maxWidth:true,minHeight:true,minWidth:true,width:true},n={maxHeight:true,maxWidth:true,minHeight:true,minWidth:true},o=c.attrFn||{val:true,css:true,html:true,text:true,data:true,width:true,height:true,offset:true,click:true};c.widget("ui.dialog",{options:{autoOpen:true,buttons:{},closeOnEscape:true,closeText:"close",dialogClass:"",draggable:true,hide:null,height:"auto",maxHeight:false,maxWidth:false,minHeight:150,minWidth:150,modal:false, -position:{my:"center",at:"center",collision:"fit",using:function(a){var b=c(this).css(a).offset().top;b<0&&c(this).css("top",a.top-b)}},resizable:true,show:null,stack:true,title:"",width:300,zIndex:1E3},_create:function(){this.originalTitle=this.element.attr("title");if(typeof this.originalTitle!=="string")this.originalTitle="";this.options.title=this.options.title||this.originalTitle;var a=this,b=a.options,d=b.title||" ",e=c.ui.dialog.getTitleId(a.element),g=(a.uiDialog=c("
    ")).appendTo(document.body).hide().addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+ -b.dialogClass).css({zIndex:b.zIndex}).attr("tabIndex",-1).css("outline",0).keydown(function(i){if(b.closeOnEscape&&!i.isDefaultPrevented()&&i.keyCode&&i.keyCode===c.ui.keyCode.ESCAPE){a.close(i);i.preventDefault()}}).attr({role:"dialog","aria-labelledby":e}).mousedown(function(i){a.moveToTop(false,i)});a.element.show().removeAttr("title").addClass("ui-dialog-content ui-widget-content").appendTo(g);var f=(a.uiDialogTitlebar=c("
    ")).addClass("ui-dialog-titlebar ui-widget-header ui-corner-all ui-helper-clearfix").prependTo(g), -h=c('').addClass("ui-dialog-titlebar-close ui-corner-all").attr("role","button").hover(function(){h.addClass("ui-state-hover")},function(){h.removeClass("ui-state-hover")}).focus(function(){h.addClass("ui-state-focus")}).blur(function(){h.removeClass("ui-state-focus")}).click(function(i){a.close(i);return false}).appendTo(f);(a.uiDialogTitlebarCloseText=c("")).addClass("ui-icon ui-icon-closethick").text(b.closeText).appendTo(h);c("").addClass("ui-dialog-title").attr("id", -e).html(d).prependTo(f);if(c.isFunction(b.beforeclose)&&!c.isFunction(b.beforeClose))b.beforeClose=b.beforeclose;f.find("*").add(f).disableSelection();b.draggable&&c.fn.draggable&&a._makeDraggable();b.resizable&&c.fn.resizable&&a._makeResizable();a._createButtons(b.buttons);a._isOpen=false;c.fn.bgiframe&&g.bgiframe()},_init:function(){this.options.autoOpen&&this.open()},destroy:function(){var a=this;a.overlay&&a.overlay.destroy();a.uiDialog.hide();a.element.unbind(".dialog").removeData("dialog").removeClass("ui-dialog-content ui-widget-content").hide().appendTo("body"); -a.uiDialog.remove();a.originalTitle&&a.element.attr("title",a.originalTitle);return a},widget:function(){return this.uiDialog},close:function(a){var b=this,d,e;if(false!==b._trigger("beforeClose",a)){b.overlay&&b.overlay.destroy();b.uiDialog.unbind("keypress.ui-dialog");b._isOpen=false;if(b.options.hide)b.uiDialog.hide(b.options.hide,function(){b._trigger("close",a)});else{b.uiDialog.hide();b._trigger("close",a)}c.ui.dialog.overlay.resize();if(b.options.modal){d=0;c(".ui-dialog").each(function(){if(this!== -b.uiDialog[0]){e=c(this).css("z-index");isNaN(e)||(d=Math.max(d,e))}});c.ui.dialog.maxZ=d}return b}},isOpen:function(){return this._isOpen},moveToTop:function(a,b){var d=this,e=d.options;if(e.modal&&!a||!e.stack&&!e.modal)return d._trigger("focus",b);if(e.zIndex>c.ui.dialog.maxZ)c.ui.dialog.maxZ=e.zIndex;if(d.overlay){c.ui.dialog.maxZ+=1;d.overlay.$el.css("z-index",c.ui.dialog.overlay.maxZ=c.ui.dialog.maxZ)}a={scrollTop:d.element.scrollTop(),scrollLeft:d.element.scrollLeft()};c.ui.dialog.maxZ+=1; -d.uiDialog.css("z-index",c.ui.dialog.maxZ);d.element.attr(a);d._trigger("focus",b);return d},open:function(){if(!this._isOpen){var a=this,b=a.options,d=a.uiDialog;a.overlay=b.modal?new c.ui.dialog.overlay(a):null;a._size();a._position(b.position);d.show(b.show);a.moveToTop(true);b.modal&&d.bind("keypress.ui-dialog",function(e){if(e.keyCode===c.ui.keyCode.TAB){var g=c(":tabbable",this),f=g.filter(":first");g=g.filter(":last");if(e.target===g[0]&&!e.shiftKey){f.focus(1);return false}else if(e.target=== -f[0]&&e.shiftKey){g.focus(1);return false}}});c(a.element.find(":tabbable").get().concat(d.find(".ui-dialog-buttonpane :tabbable").get().concat(d.get()))).eq(0).focus();a._isOpen=true;a._trigger("open");return a}},_createButtons:function(a){var b=this,d=false,e=c("
    ").addClass("ui-dialog-buttonpane ui-widget-content ui-helper-clearfix"),g=c("
    ").addClass("ui-dialog-buttonset").appendTo(e);b.uiDialog.find(".ui-dialog-buttonpane").remove();typeof a==="object"&&a!==null&&c.each(a, -function(){return!(d=true)});if(d){c.each(a,function(f,h){h=c.isFunction(h)?{click:h,text:f}:h;var i=c('').click(function(){h.click.apply(b.element[0],arguments)}).appendTo(g);c.each(h,function(j,k){if(j!=="click")j in o?i[j](k):i.attr(j,k)});c.fn.button&&i.button()});e.appendTo(b.uiDialog)}},_makeDraggable:function(){function a(f){return{position:f.position,offset:f.offset}}var b=this,d=b.options,e=c(document),g;b.uiDialog.draggable({cancel:".ui-dialog-content, .ui-dialog-titlebar-close", -handle:".ui-dialog-titlebar",containment:"document",start:function(f,h){g=d.height==="auto"?"auto":c(this).height();c(this).height(c(this).height()).addClass("ui-dialog-dragging");b._trigger("dragStart",f,a(h))},drag:function(f,h){b._trigger("drag",f,a(h))},stop:function(f,h){d.position=[h.position.left-e.scrollLeft(),h.position.top-e.scrollTop()];c(this).removeClass("ui-dialog-dragging").height(g);b._trigger("dragStop",f,a(h));c.ui.dialog.overlay.resize()}})},_makeResizable:function(a){function b(f){return{originalPosition:f.originalPosition, -originalSize:f.originalSize,position:f.position,size:f.size}}a=a===l?this.options.resizable:a;var d=this,e=d.options,g=d.uiDialog.css("position");a=typeof a==="string"?a:"n,e,s,w,se,sw,ne,nw";d.uiDialog.resizable({cancel:".ui-dialog-content",containment:"document",alsoResize:d.element,maxWidth:e.maxWidth,maxHeight:e.maxHeight,minWidth:e.minWidth,minHeight:d._minHeight(),handles:a,start:function(f,h){c(this).addClass("ui-dialog-resizing");d._trigger("resizeStart",f,b(h))},resize:function(f,h){d._trigger("resize", -f,b(h))},stop:function(f,h){c(this).removeClass("ui-dialog-resizing");e.height=c(this).height();e.width=c(this).width();d._trigger("resizeStop",f,b(h));c.ui.dialog.overlay.resize()}}).css("position",g).find(".ui-resizable-se").addClass("ui-icon ui-icon-grip-diagonal-se")},_minHeight:function(){var a=this.options;return a.height==="auto"?a.minHeight:Math.min(a.minHeight,a.height)},_position:function(a){var b=[],d=[0,0],e;if(a){if(typeof a==="string"||typeof a==="object"&&"0"in a){b=a.split?a.split(" "): -[a[0],a[1]];if(b.length===1)b[1]=b[0];c.each(["left","top"],function(g,f){if(+b[g]===b[g]){d[g]=b[g];b[g]=f}});a={my:b.join(" "),at:b.join(" "),offset:d.join(" ")}}a=c.extend({},c.ui.dialog.prototype.options.position,a)}else a=c.ui.dialog.prototype.options.position;(e=this.uiDialog.is(":visible"))||this.uiDialog.show();this.uiDialog.css({top:0,left:0}).position(c.extend({of:window},a));e||this.uiDialog.hide()},_setOptions:function(a){var b=this,d={},e=false;c.each(a,function(g,f){b._setOption(g,f); -if(g in m)e=true;if(g in n)d[g]=f});e&&this._size();this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option",d)},_setOption:function(a,b){var d=this,e=d.uiDialog;switch(a){case "beforeclose":a="beforeClose";break;case "buttons":d._createButtons(b);break;case "closeText":d.uiDialogTitlebarCloseText.text(""+b);break;case "dialogClass":e.removeClass(d.options.dialogClass).addClass("ui-dialog ui-widget ui-widget-content ui-corner-all "+b);break;case "disabled":b?e.addClass("ui-dialog-disabled"): -e.removeClass("ui-dialog-disabled");break;case "draggable":var g=e.is(":data(draggable)");g&&!b&&e.draggable("destroy");!g&&b&&d._makeDraggable();break;case "position":d._position(b);break;case "resizable":(g=e.is(":data(resizable)"))&&!b&&e.resizable("destroy");g&&typeof b==="string"&&e.resizable("option","handles",b);!g&&b!==false&&d._makeResizable(b);break;case "title":c(".ui-dialog-title",d.uiDialogTitlebar).html(""+(b||" "));break}c.Widget.prototype._setOption.apply(d,arguments)},_size:function(){var a= -this.options,b,d,e=this.uiDialog.is(":visible");this.element.show().css({width:"auto",minHeight:0,height:0});if(a.minWidth>a.width)a.width=a.minWidth;b=this.uiDialog.css({height:"auto",width:a.width}).height();d=Math.max(0,a.minHeight-b);if(a.height==="auto")if(c.support.minHeight)this.element.css({minHeight:d,height:"auto"});else{this.uiDialog.show();a=this.element.css("height","auto").height();e||this.uiDialog.hide();this.element.height(Math.max(a,d))}else this.element.height(Math.max(a.height- -b,0));this.uiDialog.is(":data(resizable)")&&this.uiDialog.resizable("option","minHeight",this._minHeight())}});c.extend(c.ui.dialog,{version:"1.8.16",uuid:0,maxZ:0,getTitleId:function(a){a=a.attr("id");if(!a){this.uuid+=1;a=this.uuid}return"ui-dialog-title-"+a},overlay:function(a){this.$el=c.ui.dialog.overlay.create(a)}});c.extend(c.ui.dialog.overlay,{instances:[],oldInstances:[],maxZ:0,events:c.map("focus,mousedown,mouseup,keydown,keypress,click".split(","),function(a){return a+".dialog-overlay"}).join(" "), -create:function(a){if(this.instances.length===0){setTimeout(function(){c.ui.dialog.overlay.instances.length&&c(document).bind(c.ui.dialog.overlay.events,function(d){if(c(d.target).zIndex()").addClass("ui-widget-overlay")).appendTo(document.body).css({width:this.width(),height:this.height()});c.fn.bgiframe&&b.bgiframe();this.instances.push(b);return b},destroy:function(a){var b=c.inArray(a,this.instances);b!=-1&&this.oldInstances.push(this.instances.splice(b,1)[0]);this.instances.length===0&&c([document,window]).unbind(".dialog-overlay");a.remove();var d=0;c.each(this.instances,function(){d=Math.max(d,this.css("z-index"))});this.maxZ=d},height:function(){var a,b;if(c.browser.msie&& -c.browser.version<7){a=Math.max(document.documentElement.scrollHeight,document.body.scrollHeight);b=Math.max(document.documentElement.offsetHeight,document.body.offsetHeight);return a").appendTo(this.element).addClass("ui-slider-range ui-widget-header"+(b.range==="min"||b.range==="max"?" ui-slider-range-"+b.range:""))}for(var j=c.length;j"); -this.handles=c.add(d(e.join("")).appendTo(a.element));this.handle=this.handles.eq(0);this.handles.add(this.range).filter("a").click(function(g){g.preventDefault()}).hover(function(){b.disabled||d(this).addClass("ui-state-hover")},function(){d(this).removeClass("ui-state-hover")}).focus(function(){if(b.disabled)d(this).blur();else{d(".ui-slider .ui-state-focus").removeClass("ui-state-focus");d(this).addClass("ui-state-focus")}}).blur(function(){d(this).removeClass("ui-state-focus")});this.handles.each(function(g){d(this).data("index.ui-slider-handle", -g)});this.handles.keydown(function(g){var k=true,l=d(this).data("index.ui-slider-handle"),i,h,m;if(!a.options.disabled){switch(g.keyCode){case d.ui.keyCode.HOME:case d.ui.keyCode.END:case d.ui.keyCode.PAGE_UP:case d.ui.keyCode.PAGE_DOWN:case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:k=false;if(!a._keySliding){a._keySliding=true;d(this).addClass("ui-state-active");i=a._start(g,l);if(i===false)return}break}m=a.options.step;i=a.options.values&&a.options.values.length? -(h=a.values(l)):(h=a.value());switch(g.keyCode){case d.ui.keyCode.HOME:h=a._valueMin();break;case d.ui.keyCode.END:h=a._valueMax();break;case d.ui.keyCode.PAGE_UP:h=a._trimAlignValue(i+(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.PAGE_DOWN:h=a._trimAlignValue(i-(a._valueMax()-a._valueMin())/5);break;case d.ui.keyCode.UP:case d.ui.keyCode.RIGHT:if(i===a._valueMax())return;h=a._trimAlignValue(i+m);break;case d.ui.keyCode.DOWN:case d.ui.keyCode.LEFT:if(i===a._valueMin())return;h=a._trimAlignValue(i- -m);break}a._slide(g,l,h);return k}}).keyup(function(g){var k=d(this).data("index.ui-slider-handle");if(a._keySliding){a._keySliding=false;a._stop(g,k);a._change(g,k);d(this).removeClass("ui-state-active")}});this._refreshValue();this._animateOff=false},destroy:function(){this.handles.remove();this.range.remove();this.element.removeClass("ui-slider ui-slider-horizontal ui-slider-vertical ui-slider-disabled ui-widget ui-widget-content ui-corner-all").removeData("slider").unbind(".slider");this._mouseDestroy(); -return this},_mouseCapture:function(a){var b=this.options,c,f,e,j,g;if(b.disabled)return false;this.elementSize={width:this.element.outerWidth(),height:this.element.outerHeight()};this.elementOffset=this.element.offset();c=this._normValueFromMouse({x:a.pageX,y:a.pageY});f=this._valueMax()-this._valueMin()+1;j=this;this.handles.each(function(k){var l=Math.abs(c-j.values(k));if(f>l){f=l;e=d(this);g=k}});if(b.range===true&&this.values(1)===b.min){g+=1;e=d(this.handles[g])}if(this._start(a,g)===false)return false; -this._mouseSliding=true;j._handleIndex=g;e.addClass("ui-state-active").focus();b=e.offset();this._clickOffset=!d(a.target).parents().andSelf().is(".ui-slider-handle")?{left:0,top:0}:{left:a.pageX-b.left-e.width()/2,top:a.pageY-b.top-e.height()/2-(parseInt(e.css("borderTopWidth"),10)||0)-(parseInt(e.css("borderBottomWidth"),10)||0)+(parseInt(e.css("marginTop"),10)||0)};this.handles.hasClass("ui-state-hover")||this._slide(a,g,c);return this._animateOff=true},_mouseStart:function(){return true},_mouseDrag:function(a){var b= -this._normValueFromMouse({x:a.pageX,y:a.pageY});this._slide(a,this._handleIndex,b);return false},_mouseStop:function(a){this.handles.removeClass("ui-state-active");this._mouseSliding=false;this._stop(a,this._handleIndex);this._change(a,this._handleIndex);this._clickOffset=this._handleIndex=null;return this._animateOff=false},_detectOrientation:function(){this.orientation=this.options.orientation==="vertical"?"vertical":"horizontal"},_normValueFromMouse:function(a){var b;if(this.orientation==="horizontal"){b= -this.elementSize.width;a=a.x-this.elementOffset.left-(this._clickOffset?this._clickOffset.left:0)}else{b=this.elementSize.height;a=a.y-this.elementOffset.top-(this._clickOffset?this._clickOffset.top:0)}b=a/b;if(b>1)b=1;if(b<0)b=0;if(this.orientation==="vertical")b=1-b;a=this._valueMax()-this._valueMin();return this._trimAlignValue(this._valueMin()+b*a)},_start:function(a,b){var c={handle:this.handles[b],value:this.value()};if(this.options.values&&this.options.values.length){c.value=this.values(b); -c.values=this.values()}return this._trigger("start",a,c)},_slide:function(a,b,c){var f;if(this.options.values&&this.options.values.length){f=this.values(b?0:1);if(this.options.values.length===2&&this.options.range===true&&(b===0&&c>f||b===1&&c1){this.options.values[a]=this._trimAlignValue(b);this._refreshValue();this._change(null,a)}else if(arguments.length)if(d.isArray(arguments[0])){c=this.options.values;f=arguments[0];for(e=0;e=this._valueMax())return this._valueMax();var b=this.options.step>0?this.options.step:1,c=(a-this._valueMin())%b;a=a-c;if(Math.abs(c)*2>=b)a+=c>0?b:-b;return parseFloat(a.toFixed(5))},_valueMin:function(){return this.options.min},_valueMax:function(){return this.options.max},_refreshValue:function(){var a= -this.options.range,b=this.options,c=this,f=!this._animateOff?b.animate:false,e,j={},g,k,l,i;if(this.options.values&&this.options.values.length)this.handles.each(function(h){e=(c.values(h)-c._valueMin())/(c._valueMax()-c._valueMin())*100;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";d(this).stop(1,1)[f?"animate":"css"](j,b.animate);if(c.options.range===true)if(c.orientation==="horizontal"){if(h===0)c.range.stop(1,1)[f?"animate":"css"]({left:e+"%"},b.animate);if(h===1)c.range[f?"animate":"css"]({width:e- -g+"%"},{queue:false,duration:b.animate})}else{if(h===0)c.range.stop(1,1)[f?"animate":"css"]({bottom:e+"%"},b.animate);if(h===1)c.range[f?"animate":"css"]({height:e-g+"%"},{queue:false,duration:b.animate})}g=e});else{k=this.value();l=this._valueMin();i=this._valueMax();e=i!==l?(k-l)/(i-l)*100:0;j[c.orientation==="horizontal"?"left":"bottom"]=e+"%";this.handle.stop(1,1)[f?"animate":"css"](j,b.animate);if(a==="min"&&this.orientation==="horizontal")this.range.stop(1,1)[f?"animate":"css"]({width:e+"%"}, -b.animate);if(a==="max"&&this.orientation==="horizontal")this.range[f?"animate":"css"]({width:100-e+"%"},{queue:false,duration:b.animate});if(a==="min"&&this.orientation==="vertical")this.range.stop(1,1)[f?"animate":"css"]({height:e+"%"},b.animate);if(a==="max"&&this.orientation==="vertical")this.range[f?"animate":"css"]({height:100-e+"%"},{queue:false,duration:b.animate})}}});d.extend(d.ui.slider,{version:"1.8.16"})})(jQuery); -;/* - * jQuery UI Tabs 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Tabs - * - * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js - */ -(function(d,p){function u(){return++v}function w(){return++x}var v=0,x=0;d.widget("ui.tabs",{options:{add:null,ajaxOptions:null,cache:false,cookie:null,collapsible:false,disable:null,disabled:[],enable:null,event:"click",fx:null,idPrefix:"ui-tabs-",load:null,panelTemplate:"
    ",remove:null,select:null,show:null,spinner:"Loading…",tabTemplate:"
  • #{label}
  • "},_create:function(){this._tabify(true)},_setOption:function(b,e){if(b=="selected")this.options.collapsible&& -e==this.options.selected||this.select(e);else{this.options[b]=e;this._tabify()}},_tabId:function(b){return b.title&&b.title.replace(/\s/g,"_").replace(/[^\w\u00c0-\uFFFF-]/g,"")||this.options.idPrefix+u()},_sanitizeSelector:function(b){return b.replace(/:/g,"\\:")},_cookie:function(){var b=this.cookie||(this.cookie=this.options.cookie.name||"ui-tabs-"+w());return d.cookie.apply(null,[b].concat(d.makeArray(arguments)))},_ui:function(b,e){return{tab:b,panel:e,index:this.anchors.index(b)}},_cleanup:function(){this.lis.filter(".ui-state-processing").removeClass("ui-state-processing").find("span:data(label.tabs)").each(function(){var b= -d(this);b.html(b.data("label.tabs")).removeData("label.tabs")})},_tabify:function(b){function e(g,f){g.css("display","");!d.support.opacity&&f.opacity&&g[0].style.removeAttribute("filter")}var a=this,c=this.options,h=/^#.+/;this.list=this.element.find("ol,ul").eq(0);this.lis=d(" > li:has(a[href])",this.list);this.anchors=this.lis.map(function(){return d("a",this)[0]});this.panels=d([]);this.anchors.each(function(g,f){var i=d(f).attr("href"),l=i.split("#")[0],q;if(l&&(l===location.toString().split("#")[0]|| -(q=d("base")[0])&&l===q.href)){i=f.hash;f.href=i}if(h.test(i))a.panels=a.panels.add(a.element.find(a._sanitizeSelector(i)));else if(i&&i!=="#"){d.data(f,"href.tabs",i);d.data(f,"load.tabs",i.replace(/#.*$/,""));i=a._tabId(f);f.href="#"+i;f=a.element.find("#"+i);if(!f.length){f=d(c.panelTemplate).attr("id",i).addClass("ui-tabs-panel ui-widget-content ui-corner-bottom").insertAfter(a.panels[g-1]||a.list);f.data("destroy.tabs",true)}a.panels=a.panels.add(f)}else c.disabled.push(g)});if(b){this.element.addClass("ui-tabs ui-widget ui-widget-content ui-corner-all"); -this.list.addClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.lis.addClass("ui-state-default ui-corner-top");this.panels.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom");if(c.selected===p){location.hash&&this.anchors.each(function(g,f){if(f.hash==location.hash){c.selected=g;return false}});if(typeof c.selected!=="number"&&c.cookie)c.selected=parseInt(a._cookie(),10);if(typeof c.selected!=="number"&&this.lis.filter(".ui-tabs-selected").length)c.selected= -this.lis.index(this.lis.filter(".ui-tabs-selected"));c.selected=c.selected||(this.lis.length?0:-1)}else if(c.selected===null)c.selected=-1;c.selected=c.selected>=0&&this.anchors[c.selected]||c.selected<0?c.selected:0;c.disabled=d.unique(c.disabled.concat(d.map(this.lis.filter(".ui-state-disabled"),function(g){return a.lis.index(g)}))).sort();d.inArray(c.selected,c.disabled)!=-1&&c.disabled.splice(d.inArray(c.selected,c.disabled),1);this.panels.addClass("ui-tabs-hide");this.lis.removeClass("ui-tabs-selected ui-state-active"); -if(c.selected>=0&&this.anchors.length){a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash)).removeClass("ui-tabs-hide");this.lis.eq(c.selected).addClass("ui-tabs-selected ui-state-active");a.element.queue("tabs",function(){a._trigger("show",null,a._ui(a.anchors[c.selected],a.element.find(a._sanitizeSelector(a.anchors[c.selected].hash))[0]))});this.load(c.selected)}d(window).bind("unload",function(){a.lis.add(a.anchors).unbind(".tabs");a.lis=a.anchors=a.panels=null})}else c.selected=this.lis.index(this.lis.filter(".ui-tabs-selected")); -this.element[c.collapsible?"addClass":"removeClass"]("ui-tabs-collapsible");c.cookie&&this._cookie(c.selected,c.cookie);b=0;for(var j;j=this.lis[b];b++)d(j)[d.inArray(b,c.disabled)!=-1&&!d(j).hasClass("ui-tabs-selected")?"addClass":"removeClass"]("ui-state-disabled");c.cache===false&&this.anchors.removeData("cache.tabs");this.lis.add(this.anchors).unbind(".tabs");if(c.event!=="mouseover"){var k=function(g,f){f.is(":not(.ui-state-disabled)")&&f.addClass("ui-state-"+g)},n=function(g,f){f.removeClass("ui-state-"+ -g)};this.lis.bind("mouseover.tabs",function(){k("hover",d(this))});this.lis.bind("mouseout.tabs",function(){n("hover",d(this))});this.anchors.bind("focus.tabs",function(){k("focus",d(this).closest("li"))});this.anchors.bind("blur.tabs",function(){n("focus",d(this).closest("li"))})}var m,o;if(c.fx)if(d.isArray(c.fx)){m=c.fx[0];o=c.fx[1]}else m=o=c.fx;var r=o?function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.hide().removeClass("ui-tabs-hide").animate(o,o.duration||"normal", -function(){e(f,o);a._trigger("show",null,a._ui(g,f[0]))})}:function(g,f){d(g).closest("li").addClass("ui-tabs-selected ui-state-active");f.removeClass("ui-tabs-hide");a._trigger("show",null,a._ui(g,f[0]))},s=m?function(g,f){f.animate(m,m.duration||"normal",function(){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");e(f,m);a.element.dequeue("tabs")})}:function(g,f){a.lis.removeClass("ui-tabs-selected ui-state-active");f.addClass("ui-tabs-hide");a.element.dequeue("tabs")}; -this.anchors.bind(c.event+".tabs",function(){var g=this,f=d(g).closest("li"),i=a.panels.filter(":not(.ui-tabs-hide)"),l=a.element.find(a._sanitizeSelector(g.hash));if(f.hasClass("ui-tabs-selected")&&!c.collapsible||f.hasClass("ui-state-disabled")||f.hasClass("ui-state-processing")||a.panels.filter(":animated").length||a._trigger("select",null,a._ui(this,l[0]))===false){this.blur();return false}c.selected=a.anchors.index(this);a.abort();if(c.collapsible)if(f.hasClass("ui-tabs-selected")){c.selected= --1;c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){s(g,i)}).dequeue("tabs");this.blur();return false}else if(!i.length){c.cookie&&a._cookie(c.selected,c.cookie);a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this));this.blur();return false}c.cookie&&a._cookie(c.selected,c.cookie);if(l.length){i.length&&a.element.queue("tabs",function(){s(g,i)});a.element.queue("tabs",function(){r(g,l)});a.load(a.anchors.index(this))}else throw"jQuery UI Tabs: Mismatching fragment identifier."; -d.browser.msie&&this.blur()});this.anchors.bind("click.tabs",function(){return false})},_getIndex:function(b){if(typeof b=="string")b=this.anchors.index(this.anchors.filter("[href$="+b+"]"));return b},destroy:function(){var b=this.options;this.abort();this.element.unbind(".tabs").removeClass("ui-tabs ui-widget ui-widget-content ui-corner-all ui-tabs-collapsible").removeData("tabs");this.list.removeClass("ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all");this.anchors.each(function(){var e= -d.data(this,"href.tabs");if(e)this.href=e;var a=d(this).unbind(".tabs");d.each(["href","load","cache"],function(c,h){a.removeData(h+".tabs")})});this.lis.unbind(".tabs").add(this.panels).each(function(){d.data(this,"destroy.tabs")?d(this).remove():d(this).removeClass("ui-state-default ui-corner-top ui-tabs-selected ui-state-active ui-state-hover ui-state-focus ui-state-disabled ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide")});b.cookie&&this._cookie(null,b.cookie);return this},add:function(b, -e,a){if(a===p)a=this.anchors.length;var c=this,h=this.options;e=d(h.tabTemplate.replace(/#\{href\}/g,b).replace(/#\{label\}/g,e));b=!b.indexOf("#")?b.replace("#",""):this._tabId(d("a",e)[0]);e.addClass("ui-state-default ui-corner-top").data("destroy.tabs",true);var j=c.element.find("#"+b);j.length||(j=d(h.panelTemplate).attr("id",b).data("destroy.tabs",true));j.addClass("ui-tabs-panel ui-widget-content ui-corner-bottom ui-tabs-hide");if(a>=this.lis.length){e.appendTo(this.list);j.appendTo(this.list[0].parentNode)}else{e.insertBefore(this.lis[a]); -j.insertBefore(this.panels[a])}h.disabled=d.map(h.disabled,function(k){return k>=a?++k:k});this._tabify();if(this.anchors.length==1){h.selected=0;e.addClass("ui-tabs-selected ui-state-active");j.removeClass("ui-tabs-hide");this.element.queue("tabs",function(){c._trigger("show",null,c._ui(c.anchors[0],c.panels[0]))});this.load(0)}this._trigger("add",null,this._ui(this.anchors[a],this.panels[a]));return this},remove:function(b){b=this._getIndex(b);var e=this.options,a=this.lis.eq(b).remove(),c=this.panels.eq(b).remove(); -if(a.hasClass("ui-tabs-selected")&&this.anchors.length>1)this.select(b+(b+1=b?--h:h});this._tabify();this._trigger("remove",null,this._ui(a.find("a")[0],c[0]));return this},enable:function(b){b=this._getIndex(b);var e=this.options;if(d.inArray(b,e.disabled)!=-1){this.lis.eq(b).removeClass("ui-state-disabled");e.disabled=d.grep(e.disabled,function(a){return a!=b});this._trigger("enable",null, -this._ui(this.anchors[b],this.panels[b]));return this}},disable:function(b){b=this._getIndex(b);var e=this.options;if(b!=e.selected){this.lis.eq(b).addClass("ui-state-disabled");e.disabled.push(b);e.disabled.sort();this._trigger("disable",null,this._ui(this.anchors[b],this.panels[b]))}return this},select:function(b){b=this._getIndex(b);if(b==-1)if(this.options.collapsible&&this.options.selected!=-1)b=this.options.selected;else return this;this.anchors.eq(b).trigger(this.options.event+".tabs");return this}, -load:function(b){b=this._getIndex(b);var e=this,a=this.options,c=this.anchors.eq(b)[0],h=d.data(c,"load.tabs");this.abort();if(!h||this.element.queue("tabs").length!==0&&d.data(c,"cache.tabs"))this.element.dequeue("tabs");else{this.lis.eq(b).addClass("ui-state-processing");if(a.spinner){var j=d("span",c);j.data("label.tabs",j.html()).html(a.spinner)}this.xhr=d.ajax(d.extend({},a.ajaxOptions,{url:h,success:function(k,n){e.element.find(e._sanitizeSelector(c.hash)).html(k);e._cleanup();a.cache&&d.data(c, -"cache.tabs",true);e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.success(k,n)}catch(m){}},error:function(k,n){e._cleanup();e._trigger("load",null,e._ui(e.anchors[b],e.panels[b]));try{a.ajaxOptions.error(k,n,b,c)}catch(m){}}}));e.element.dequeue("tabs");return this}},abort:function(){this.element.queue([]);this.panels.stop(false,true);this.element.queue("tabs",this.element.queue("tabs").splice(-2,2));if(this.xhr){this.xhr.abort();delete this.xhr}this._cleanup();return this}, -url:function(b,e){this.anchors.eq(b).removeData("cache.tabs").data("load.tabs",e);return this},length:function(){return this.anchors.length}});d.extend(d.ui.tabs,{version:"1.8.16"});d.extend(d.ui.tabs.prototype,{rotation:null,rotate:function(b,e){var a=this,c=this.options,h=a._rotate||(a._rotate=function(j){clearTimeout(a.rotation);a.rotation=setTimeout(function(){var k=c.selected;a.select(++k'))}function N(a){return a.bind("mouseout", -function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");b.length&&b.removeClass("ui-state-hover ui-datepicker-prev-hover ui-datepicker-next-hover")}).bind("mouseover",function(b){b=d(b.target).closest("button, .ui-datepicker-prev, .ui-datepicker-next, .ui-datepicker-calendar td a");if(!(d.datepicker._isDisabledDatepicker(J.inline?a.parent()[0]:J.input[0])||!b.length)){b.parents(".ui-datepicker-calendar").find("a").removeClass("ui-state-hover"); -b.addClass("ui-state-hover");b.hasClass("ui-datepicker-prev")&&b.addClass("ui-datepicker-prev-hover");b.hasClass("ui-datepicker-next")&&b.addClass("ui-datepicker-next-hover")}})}function H(a,b){d.extend(a,b);for(var c in b)if(b[c]==null||b[c]==C)a[c]=b[c];return a}d.extend(d.ui,{datepicker:{version:"1.8.16"}});var B=(new Date).getTime(),J;d.extend(M.prototype,{markerClassName:"hasDatepicker",maxRows:4,log:function(){this.debug&&console.log.apply("",arguments)},_widgetDatepicker:function(){return this.dpDiv}, -setDefaults:function(a){H(this._defaults,a||{});return this},_attachDatepicker:function(a,b){var c=null;for(var e in this._defaults){var f=a.getAttribute("date:"+e);if(f){c=c||{};try{c[e]=eval(f)}catch(h){c[e]=f}}}e=a.nodeName.toLowerCase();f=e=="div"||e=="span";if(!a.id){this.uuid+=1;a.id="dp"+this.uuid}var i=this._newInst(d(a),f);i.settings=d.extend({},b||{},c||{});if(e=="input")this._connectDatepicker(a,i);else f&&this._inlineDatepicker(a,i)},_newInst:function(a,b){return{id:a[0].id.replace(/([^A-Za-z0-9_-])/g, -"\\\\$1"),input:a,selectedDay:0,selectedMonth:0,selectedYear:0,drawMonth:0,drawYear:0,inline:b,dpDiv:!b?this.dpDiv:N(d('
    '))}},_connectDatepicker:function(a,b){var c=d(a);b.append=d([]);b.trigger=d([]);if(!c.hasClass(this.markerClassName)){this._attachments(c,b);c.addClass(this.markerClassName).keydown(this._doKeyDown).keypress(this._doKeyPress).keyup(this._doKeyUp).bind("setData.datepicker", -function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});this._autoSize(b);d.data(a,"datepicker",b);b.settings.disabled&&this._disableDatepicker(a)}},_attachments:function(a,b){var c=this._get(b,"appendText"),e=this._get(b,"isRTL");b.append&&b.append.remove();if(c){b.append=d(''+c+"");a[e?"before":"after"](b.append)}a.unbind("focus",this._showDatepicker);b.trigger&&b.trigger.remove();c=this._get(b,"showOn");if(c== -"focus"||c=="both")a.focus(this._showDatepicker);if(c=="button"||c=="both"){c=this._get(b,"buttonText");var f=this._get(b,"buttonImage");b.trigger=d(this._get(b,"buttonImageOnly")?d("").addClass(this._triggerClass).attr({src:f,alt:c,title:c}):d('').addClass(this._triggerClass).html(f==""?c:d("").attr({src:f,alt:c,title:c})));a[e?"before":"after"](b.trigger);b.trigger.click(function(){d.datepicker._datepickerShowing&&d.datepicker._lastInput==a[0]?d.datepicker._hideDatepicker(): -d.datepicker._showDatepicker(a[0]);return false})}},_autoSize:function(a){if(this._get(a,"autoSize")&&!a.inline){var b=new Date(2009,11,20),c=this._get(a,"dateFormat");if(c.match(/[DM]/)){var e=function(f){for(var h=0,i=0,g=0;gh){h=f[g].length;i=g}return i};b.setMonth(e(this._get(a,c.match(/MM/)?"monthNames":"monthNamesShort")));b.setDate(e(this._get(a,c.match(/DD/)?"dayNames":"dayNamesShort"))+20-b.getDay())}a.input.attr("size",this._formatDate(a,b).length)}},_inlineDatepicker:function(a, -b){var c=d(a);if(!c.hasClass(this.markerClassName)){c.addClass(this.markerClassName).append(b.dpDiv).bind("setData.datepicker",function(e,f,h){b.settings[f]=h}).bind("getData.datepicker",function(e,f){return this._get(b,f)});d.data(a,"datepicker",b);this._setDate(b,this._getDefaultDate(b),true);this._updateDatepicker(b);this._updateAlternate(b);b.settings.disabled&&this._disableDatepicker(a);b.dpDiv.css("display","block")}},_dialogDatepicker:function(a,b,c,e,f){a=this._dialogInst;if(!a){this.uuid+= -1;this._dialogInput=d('');this._dialogInput.keydown(this._doKeyDown);d("body").append(this._dialogInput);a=this._dialogInst=this._newInst(this._dialogInput,false);a.settings={};d.data(this._dialogInput[0],"datepicker",a)}H(a.settings,e||{});b=b&&b.constructor==Date?this._formatDate(a,b):b;this._dialogInput.val(b);this._pos=f?f.length?f:[f.pageX,f.pageY]:null;if(!this._pos)this._pos=[document.documentElement.clientWidth/ -2-100+(document.documentElement.scrollLeft||document.body.scrollLeft),document.documentElement.clientHeight/2-150+(document.documentElement.scrollTop||document.body.scrollTop)];this._dialogInput.css("left",this._pos[0]+20+"px").css("top",this._pos[1]+"px");a.settings.onSelect=c;this._inDialog=true;this.dpDiv.addClass(this._dialogClass);this._showDatepicker(this._dialogInput[0]);d.blockUI&&d.blockUI(this.dpDiv);d.data(this._dialogInput[0],"datepicker",a);return this},_destroyDatepicker:function(a){var b= -d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();d.removeData(a,"datepicker");if(e=="input"){c.append.remove();c.trigger.remove();b.removeClass(this.markerClassName).unbind("focus",this._showDatepicker).unbind("keydown",this._doKeyDown).unbind("keypress",this._doKeyPress).unbind("keyup",this._doKeyUp)}else if(e=="div"||e=="span")b.removeClass(this.markerClassName).empty()}},_enableDatepicker:function(a){var b=d(a),c=d.data(a,"datepicker");if(b.hasClass(this.markerClassName)){var e= -a.nodeName.toLowerCase();if(e=="input"){a.disabled=false;c.trigger.filter("button").each(function(){this.disabled=false}).end().filter("img").css({opacity:"1.0",cursor:""})}else if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().removeClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").removeAttr("disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f==a?null:f})}},_disableDatepicker:function(a){var b=d(a),c=d.data(a, -"datepicker");if(b.hasClass(this.markerClassName)){var e=a.nodeName.toLowerCase();if(e=="input"){a.disabled=true;c.trigger.filter("button").each(function(){this.disabled=true}).end().filter("img").css({opacity:"0.5",cursor:"default"})}else if(e=="div"||e=="span"){b=b.children("."+this._inlineClass);b.children().addClass("ui-state-disabled");b.find("select.ui-datepicker-month, select.ui-datepicker-year").attr("disabled","disabled")}this._disabledInputs=d.map(this._disabledInputs,function(f){return f== -a?null:f});this._disabledInputs[this._disabledInputs.length]=a}},_isDisabledDatepicker:function(a){if(!a)return false;for(var b=0;b-1}},_doKeyUp:function(a){a=d.datepicker._getInst(a.target);if(a.input.val()!=a.lastVal)try{if(d.datepicker.parseDate(d.datepicker._get(a,"dateFormat"),a.input?a.input.val():null,d.datepicker._getFormatConfig(a))){d.datepicker._setDateFromField(a);d.datepicker._updateAlternate(a);d.datepicker._updateDatepicker(a)}}catch(b){d.datepicker.log(b)}return true},_showDatepicker:function(a){a=a.target||a;if(a.nodeName.toLowerCase()!="input")a=d("input", -a.parentNode)[0];if(!(d.datepicker._isDisabledDatepicker(a)||d.datepicker._lastInput==a)){var b=d.datepicker._getInst(a);if(d.datepicker._curInst&&d.datepicker._curInst!=b){d.datepicker._datepickerShowing&&d.datepicker._triggerOnClose(d.datepicker._curInst);d.datepicker._curInst.dpDiv.stop(true,true)}var c=d.datepicker._get(b,"beforeShow");c=c?c.apply(a,[a,b]):{};if(c!==false){H(b.settings,c);b.lastVal=null;d.datepicker._lastInput=a;d.datepicker._setDateFromField(b);if(d.datepicker._inDialog)a.value= -"";if(!d.datepicker._pos){d.datepicker._pos=d.datepicker._findPos(a);d.datepicker._pos[1]+=a.offsetHeight}var e=false;d(a).parents().each(function(){e|=d(this).css("position")=="fixed";return!e});if(e&&d.browser.opera){d.datepicker._pos[0]-=document.documentElement.scrollLeft;d.datepicker._pos[1]-=document.documentElement.scrollTop}c={left:d.datepicker._pos[0],top:d.datepicker._pos[1]};d.datepicker._pos=null;b.dpDiv.empty();b.dpDiv.css({position:"absolute",display:"block",top:"-1000px"});d.datepicker._updateDatepicker(b); -c=d.datepicker._checkOffset(b,c,e);b.dpDiv.css({position:d.datepicker._inDialog&&d.blockUI?"static":e?"fixed":"absolute",display:"none",left:c.left+"px",top:c.top+"px"});if(!b.inline){c=d.datepicker._get(b,"showAnim");var f=d.datepicker._get(b,"duration"),h=function(){var i=b.dpDiv.find("iframe.ui-datepicker-cover");if(i.length){var g=d.datepicker._getBorders(b.dpDiv);i.css({left:-g[0],top:-g[1],width:b.dpDiv.outerWidth(),height:b.dpDiv.outerHeight()})}};b.dpDiv.zIndex(d(a).zIndex()+1);d.datepicker._datepickerShowing= -true;d.effects&&d.effects[c]?b.dpDiv.show(c,d.datepicker._get(b,"showOptions"),f,h):b.dpDiv[c||"show"](c?f:null,h);if(!c||!f)h();b.input.is(":visible")&&!b.input.is(":disabled")&&b.input.focus();d.datepicker._curInst=b}}}},_updateDatepicker:function(a){this.maxRows=4;var b=d.datepicker._getBorders(a.dpDiv);J=a;a.dpDiv.empty().append(this._generateHTML(a));var c=a.dpDiv.find("iframe.ui-datepicker-cover");c.length&&c.css({left:-b[0],top:-b[1],width:a.dpDiv.outerWidth(),height:a.dpDiv.outerHeight()}); -a.dpDiv.find("."+this._dayOverClass+" a").mouseover();b=this._getNumberOfMonths(a);c=b[1];a.dpDiv.removeClass("ui-datepicker-multi-2 ui-datepicker-multi-3 ui-datepicker-multi-4").width("");c>1&&a.dpDiv.addClass("ui-datepicker-multi-"+c).css("width",17*c+"em");a.dpDiv[(b[0]!=1||b[1]!=1?"add":"remove")+"Class"]("ui-datepicker-multi");a.dpDiv[(this._get(a,"isRTL")?"add":"remove")+"Class"]("ui-datepicker-rtl");a==d.datepicker._curInst&&d.datepicker._datepickerShowing&&a.input&&a.input.is(":visible")&& -!a.input.is(":disabled")&&a.input[0]!=document.activeElement&&a.input.focus();if(a.yearshtml){var e=a.yearshtml;setTimeout(function(){e===a.yearshtml&&a.yearshtml&&a.dpDiv.find("select.ui-datepicker-year:first").replaceWith(a.yearshtml);e=a.yearshtml=null},0)}},_getBorders:function(a){var b=function(c){return{thin:1,medium:2,thick:3}[c]||c};return[parseFloat(b(a.css("border-left-width"))),parseFloat(b(a.css("border-top-width")))]},_checkOffset:function(a,b,c){var e=a.dpDiv.outerWidth(),f=a.dpDiv.outerHeight(), -h=a.input?a.input.outerWidth():0,i=a.input?a.input.outerHeight():0,g=document.documentElement.clientWidth+d(document).scrollLeft(),j=document.documentElement.clientHeight+d(document).scrollTop();b.left-=this._get(a,"isRTL")?e-h:0;b.left-=c&&b.left==a.input.offset().left?d(document).scrollLeft():0;b.top-=c&&b.top==a.input.offset().top+i?d(document).scrollTop():0;b.left-=Math.min(b.left,b.left+e>g&&g>e?Math.abs(b.left+e-g):0);b.top-=Math.min(b.top,b.top+f>j&&j>f?Math.abs(f+i):0);return b},_findPos:function(a){for(var b= -this._get(this._getInst(a),"isRTL");a&&(a.type=="hidden"||a.nodeType!=1||d.expr.filters.hidden(a));)a=a[b?"previousSibling":"nextSibling"];a=d(a).offset();return[a.left,a.top]},_triggerOnClose:function(a){var b=this._get(a,"onClose");if(b)b.apply(a.input?a.input[0]:null,[a.input?a.input.val():"",a])},_hideDatepicker:function(a){var b=this._curInst;if(!(!b||a&&b!=d.data(a,"datepicker")))if(this._datepickerShowing){a=this._get(b,"showAnim");var c=this._get(b,"duration"),e=function(){d.datepicker._tidyDialog(b); -this._curInst=null};d.effects&&d.effects[a]?b.dpDiv.hide(a,d.datepicker._get(b,"showOptions"),c,e):b.dpDiv[a=="slideDown"?"slideUp":a=="fadeIn"?"fadeOut":"hide"](a?c:null,e);a||e();d.datepicker._triggerOnClose(b);this._datepickerShowing=false;this._lastInput=null;if(this._inDialog){this._dialogInput.css({position:"absolute",left:"0",top:"-100px"});if(d.blockUI){d.unblockUI();d("body").append(this.dpDiv)}}this._inDialog=false}},_tidyDialog:function(a){a.dpDiv.removeClass(this._dialogClass).unbind(".ui-datepicker-calendar")}, -_checkExternalClick:function(a){if(d.datepicker._curInst){a=d(a.target);a[0].id!=d.datepicker._mainDivId&&a.parents("#"+d.datepicker._mainDivId).length==0&&!a.hasClass(d.datepicker.markerClassName)&&!a.hasClass(d.datepicker._triggerClass)&&d.datepicker._datepickerShowing&&!(d.datepicker._inDialog&&d.blockUI)&&d.datepicker._hideDatepicker()}},_adjustDate:function(a,b,c){a=d(a);var e=this._getInst(a[0]);if(!this._isDisabledDatepicker(a[0])){this._adjustInstDate(e,b+(c=="M"?this._get(e,"showCurrentAtPos"): -0),c);this._updateDatepicker(e)}},_gotoToday:function(a){a=d(a);var b=this._getInst(a[0]);if(this._get(b,"gotoCurrent")&&b.currentDay){b.selectedDay=b.currentDay;b.drawMonth=b.selectedMonth=b.currentMonth;b.drawYear=b.selectedYear=b.currentYear}else{var c=new Date;b.selectedDay=c.getDate();b.drawMonth=b.selectedMonth=c.getMonth();b.drawYear=b.selectedYear=c.getFullYear()}this._notifyChange(b);this._adjustDate(a)},_selectMonthYear:function(a,b,c){a=d(a);var e=this._getInst(a[0]);e["selected"+(c=="M"? -"Month":"Year")]=e["draw"+(c=="M"?"Month":"Year")]=parseInt(b.options[b.selectedIndex].value,10);this._notifyChange(e);this._adjustDate(a)},_selectDay:function(a,b,c,e){var f=d(a);if(!(d(e).hasClass(this._unselectableClass)||this._isDisabledDatepicker(f[0]))){f=this._getInst(f[0]);f.selectedDay=f.currentDay=d("a",e).html();f.selectedMonth=f.currentMonth=b;f.selectedYear=f.currentYear=c;this._selectDate(a,this._formatDate(f,f.currentDay,f.currentMonth,f.currentYear))}},_clearDate:function(a){a=d(a); -this._getInst(a[0]);this._selectDate(a,"")},_selectDate:function(a,b){a=this._getInst(d(a)[0]);b=b!=null?b:this._formatDate(a);a.input&&a.input.val(b);this._updateAlternate(a);var c=this._get(a,"onSelect");if(c)c.apply(a.input?a.input[0]:null,[b,a]);else a.input&&a.input.trigger("change");if(a.inline)this._updateDatepicker(a);else{this._hideDatepicker();this._lastInput=a.input[0];typeof a.input[0]!="object"&&a.input.focus();this._lastInput=null}},_updateAlternate:function(a){var b=this._get(a,"altField"); -if(b){var c=this._get(a,"altFormat")||this._get(a,"dateFormat"),e=this._getDate(a),f=this.formatDate(c,e,this._getFormatConfig(a));d(b).each(function(){d(this).val(f)})}},noWeekends:function(a){a=a.getDay();return[a>0&&a<6,""]},iso8601Week:function(a){a=new Date(a.getTime());a.setDate(a.getDate()+4-(a.getDay()||7));var b=a.getTime();a.setMonth(0);a.setDate(1);return Math.floor(Math.round((b-a)/864E5)/7)+1},parseDate:function(a,b,c){if(a==null||b==null)throw"Invalid arguments";b=typeof b=="object"? -b.toString():b+"";if(b=="")return null;var e=(c?c.shortYearCutoff:null)||this._defaults.shortYearCutoff;e=typeof e!="string"?e:(new Date).getFullYear()%100+parseInt(e,10);for(var f=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,h=(c?c.dayNames:null)||this._defaults.dayNames,i=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort,g=(c?c.monthNames:null)||this._defaults.monthNames,j=c=-1,l=-1,u=-1,k=false,o=function(p){(p=A+1-1){j=1;l=u;do{e=this._getDaysInMonth(c,j-1);if(l<=e)break;j++;l-=e}while(1)}v=this._daylightSavingAdjust(new Date(c,j-1,l));if(v.getFullYear()!=c||v.getMonth()+1!=j||v.getDate()!=l)throw"Invalid date";return v},ATOM:"yy-mm-dd", -COOKIE:"D, dd M yy",ISO_8601:"yy-mm-dd",RFC_822:"D, d M y",RFC_850:"DD, dd-M-y",RFC_1036:"D, d M y",RFC_1123:"D, d M yy",RFC_2822:"D, d M yy",RSS:"D, d M y",TICKS:"!",TIMESTAMP:"@",W3C:"yy-mm-dd",_ticksTo1970:(718685+Math.floor(492.5)-Math.floor(19.7)+Math.floor(4.925))*24*60*60*1E7,formatDate:function(a,b,c){if(!b)return"";var e=(c?c.dayNamesShort:null)||this._defaults.dayNamesShort,f=(c?c.dayNames:null)||this._defaults.dayNames,h=(c?c.monthNamesShort:null)||this._defaults.monthNamesShort;c=(c?c.monthNames: -null)||this._defaults.monthNames;var i=function(o){(o=k+1 -12?a.getHours()+2:0);return a},_setDate:function(a,b,c){var e=!b,f=a.selectedMonth,h=a.selectedYear;b=this._restrictMinMax(a,this._determineDate(a,b,new Date));a.selectedDay=a.currentDay=b.getDate();a.drawMonth=a.selectedMonth=a.currentMonth=b.getMonth();a.drawYear=a.selectedYear=a.currentYear=b.getFullYear();if((f!=a.selectedMonth||h!=a.selectedYear)&&!c)this._notifyChange(a);this._adjustInstDate(a);if(a.input)a.input.val(e?"":this._formatDate(a))},_getDate:function(a){return!a.currentYear||a.input&& -a.input.val()==""?null:this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay))},_generateHTML:function(a){var b=new Date;b=this._daylightSavingAdjust(new Date(b.getFullYear(),b.getMonth(),b.getDate()));var c=this._get(a,"isRTL"),e=this._get(a,"showButtonPanel"),f=this._get(a,"hideIfNoPrevNext"),h=this._get(a,"navigationAsDateFormat"),i=this._getNumberOfMonths(a),g=this._get(a,"showCurrentAtPos"),j=this._get(a,"stepMonths"),l=i[0]!=1||i[1]!=1,u=this._daylightSavingAdjust(!a.currentDay? -new Date(9999,9,9):new Date(a.currentYear,a.currentMonth,a.currentDay)),k=this._getMinMaxDate(a,"min"),o=this._getMinMaxDate(a,"max");g=a.drawMonth-g;var m=a.drawYear;if(g<0){g+=12;m--}if(o){var n=this._daylightSavingAdjust(new Date(o.getFullYear(),o.getMonth()-i[0]*i[1]+1,o.getDate()));for(n=k&&nn;){g--;if(g<0){g=11;m--}}}a.drawMonth=g;a.drawYear=m;n=this._get(a,"prevText");n=!h?n:this.formatDate(n,this._daylightSavingAdjust(new Date(m,g-j,1)),this._getFormatConfig(a)); -n=this._canAdjustMonth(a,-1,m,g)?''+n+"":f?"":''+n+"";var s=this._get(a,"nextText");s=!h?s:this.formatDate(s,this._daylightSavingAdjust(new Date(m, -g+j,1)),this._getFormatConfig(a));f=this._canAdjustMonth(a,+1,m,g)?''+s+"":f?"":''+s+"";j=this._get(a,"currentText");s=this._get(a,"gotoCurrent")&& -a.currentDay?u:b;j=!h?j:this.formatDate(j,s,this._getFormatConfig(a));h=!a.inline?'":"";e=e?'
    '+(c?h:"")+(this._isInRange(a,s)?'":"")+(c?"":h)+"
    ":"";h=parseInt(this._get(a,"firstDay"),10);h=isNaN(h)?0:h;j=this._get(a,"showWeek");s=this._get(a,"dayNames");this._get(a,"dayNamesShort");var q=this._get(a,"dayNamesMin"),A=this._get(a,"monthNames"),v=this._get(a,"monthNamesShort"),p=this._get(a,"beforeShowDay"),D=this._get(a,"showOtherMonths"),K=this._get(a,"selectOtherMonths");this._get(a,"calculateWeek");for(var E=this._getDefaultDate(a),w="",x=0;x1)switch(G){case 0:y+=" ui-datepicker-group-first";t=" ui-corner-"+(c?"right":"left");break;case i[1]-1:y+=" ui-datepicker-group-last";t=" ui-corner-"+(c?"left":"right");break;default:y+=" ui-datepicker-group-middle";t="";break}y+='">'}y+='
    '+(/all|left/.test(t)&& -x==0?c?f:n:"")+(/all|right/.test(t)&&x==0?c?n:f:"")+this._generateMonthYearHeader(a,g,m,k,o,x>0||G>0,A,v)+'
    ';var z=j?'":"";for(t=0;t<7;t++){var r=(t+h)%7;z+="=5?' class="ui-datepicker-week-end"':"")+'>'+q[r]+""}y+=z+"";z=this._getDaysInMonth(m,g);if(m==a.selectedYear&&g==a.selectedMonth)a.selectedDay=Math.min(a.selectedDay, -z);t=(this._getFirstDayOfMonth(m,g)-h+7)%7;z=Math.ceil((t+z)/7);this.maxRows=z=l?this.maxRows>z?this.maxRows:z:z;r=this._daylightSavingAdjust(new Date(m,g,1-t));for(var Q=0;Q";var R=!j?"":'";for(t=0;t<7;t++){var I=p?p.apply(a.input?a.input[0]:null,[r]):[true,""],F=r.getMonth()!=g,L=F&&!K||!I[0]||k&&ro;R+='";r.setDate(r.getDate()+1);r=this._daylightSavingAdjust(r)}y+=R+""}g++;if(g>11){g=0;m++}y+="
    '+this._get(a,"weekHeader")+"
    '+this._get(a,"calculateWeek")(r)+""+(F&&!D?" ":L?''+ -r.getDate()+"":''+r.getDate()+"")+"
    "+(l?""+(i[0]>0&&G==i[1]-1?'
    ':""):"");O+=y}w+=O}w+=e+(d.browser.msie&&parseInt(d.browser.version,10)<7&&!a.inline?'': -"");a._keyEvent=false;return w},_generateMonthYearHeader:function(a,b,c,e,f,h,i,g){var j=this._get(a,"changeMonth"),l=this._get(a,"changeYear"),u=this._get(a,"showMonthAfterYear"),k='
    ',o="";if(h||!j)o+=''+i[b]+"";else{i=e&&e.getFullYear()==c;var m=f&&f.getFullYear()==c;o+='"}u||(k+=o+(h||!(j&&l)?" ":""));if(!a.yearshtml){a.yearshtml="";if(h||!l)k+=''+c+"";else{g=this._get(a,"yearRange").split(":");var s=(new Date).getFullYear();i=function(q){q=q.match(/c[+-].*/)?c+parseInt(q.substring(1),10):q.match(/[+-].*/)?s+parseInt(q,10):parseInt(q,10);return isNaN(q)?s:q};b=i(g[0]);g=Math.max(b,i(g[1]||""));b=e?Math.max(b, -e.getFullYear()):b;g=f?Math.min(g,f.getFullYear()):g;for(a.yearshtml+='";k+=a.yearshtml;a.yearshtml=null}}k+=this._get(a,"yearSuffix");if(u)k+=(h||!(j&&l)?" ":"")+o;k+="
    ";return k},_adjustInstDate:function(a,b,c){var e=a.drawYear+(c=="Y"?b:0),f=a.drawMonth+ -(c=="M"?b:0);b=Math.min(a.selectedDay,this._getDaysInMonth(e,f))+(c=="D"?b:0);e=this._restrictMinMax(a,this._daylightSavingAdjust(new Date(e,f,b)));a.selectedDay=e.getDate();a.drawMonth=a.selectedMonth=e.getMonth();a.drawYear=a.selectedYear=e.getFullYear();if(c=="M"||c=="Y")this._notifyChange(a)},_restrictMinMax:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");b=c&&ba?a:b},_notifyChange:function(a){var b=this._get(a,"onChangeMonthYear");if(b)b.apply(a.input? -a.input[0]:null,[a.selectedYear,a.selectedMonth+1,a])},_getNumberOfMonths:function(a){a=this._get(a,"numberOfMonths");return a==null?[1,1]:typeof a=="number"?[1,a]:a},_getMinMaxDate:function(a,b){return this._determineDate(a,this._get(a,b+"Date"),null)},_getDaysInMonth:function(a,b){return 32-this._daylightSavingAdjust(new Date(a,b,32)).getDate()},_getFirstDayOfMonth:function(a,b){return(new Date(a,b,1)).getDay()},_canAdjustMonth:function(a,b,c,e){var f=this._getNumberOfMonths(a);c=this._daylightSavingAdjust(new Date(c, -e+(b<0?b:f[0]*f[1]),1));b<0&&c.setDate(this._getDaysInMonth(c.getFullYear(),c.getMonth()));return this._isInRange(a,c)},_isInRange:function(a,b){var c=this._getMinMaxDate(a,"min");a=this._getMinMaxDate(a,"max");return(!c||b.getTime()>=c.getTime())&&(!a||b.getTime()<=a.getTime())},_getFormatConfig:function(a){var b=this._get(a,"shortYearCutoff");b=typeof b!="string"?b:(new Date).getFullYear()%100+parseInt(b,10);return{shortYearCutoff:b,dayNamesShort:this._get(a,"dayNamesShort"),dayNames:this._get(a, -"dayNames"),monthNamesShort:this._get(a,"monthNamesShort"),monthNames:this._get(a,"monthNames")}},_formatDate:function(a,b,c,e){if(!b){a.currentDay=a.selectedDay;a.currentMonth=a.selectedMonth;a.currentYear=a.selectedYear}b=b?typeof b=="object"?b:this._daylightSavingAdjust(new Date(e,c,b)):this._daylightSavingAdjust(new Date(a.currentYear,a.currentMonth,a.currentDay));return this.formatDate(this._get(a,"dateFormat"),b,this._getFormatConfig(a))}});d.fn.datepicker=function(a){if(!this.length)return this; -if(!d.datepicker.initialized){d(document).mousedown(d.datepicker._checkExternalClick).find("body").append(d.datepicker.dpDiv);d.datepicker.initialized=true}var b=Array.prototype.slice.call(arguments,1);if(typeof a=="string"&&(a=="isDisabled"||a=="getDate"||a=="widget"))return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));if(a=="option"&&arguments.length==2&&typeof arguments[1]=="string")return d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this[0]].concat(b));return this.each(function(){typeof a== -"string"?d.datepicker["_"+a+"Datepicker"].apply(d.datepicker,[this].concat(b)):d.datepicker._attachDatepicker(this,a)})};d.datepicker=new M;d.datepicker.initialized=false;d.datepicker.uuid=(new Date).getTime();d.datepicker.version="1.8.16";window["DP_jQuery_"+B]=d})(jQuery); -;/* - * jQuery UI Progressbar 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Progressbar - * - * Depends: - * jquery.ui.core.js - * jquery.ui.widget.js - */ -(function(b,d){b.widget("ui.progressbar",{options:{value:0,max:100},min:0,_create:function(){this.element.addClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").attr({role:"progressbar","aria-valuemin":this.min,"aria-valuemax":this.options.max,"aria-valuenow":this._value()});this.valueDiv=b("
    ").appendTo(this.element);this.oldValue=this._value();this._refreshValue()},destroy:function(){this.element.removeClass("ui-progressbar ui-widget ui-widget-content ui-corner-all").removeAttr("role").removeAttr("aria-valuemin").removeAttr("aria-valuemax").removeAttr("aria-valuenow"); -this.valueDiv.remove();b.Widget.prototype.destroy.apply(this,arguments)},value:function(a){if(a===d)return this._value();this._setOption("value",a);return this},_setOption:function(a,c){if(a==="value"){this.options.value=c;this._refreshValue();this._value()===this.options.max&&this._trigger("complete")}b.Widget.prototype._setOption.apply(this,arguments)},_value:function(){var a=this.options.value;if(typeof a!=="number")a=0;return Math.min(this.options.max,Math.max(this.min,a))},_percentage:function(){return 100* -this._value()/this.options.max},_refreshValue:function(){var a=this.value(),c=this._percentage();if(this.oldValue!==a){this.oldValue=a;this._trigger("change")}this.valueDiv.toggle(a>this.min).toggleClass("ui-corner-right",a===this.options.max).width(c.toFixed(0)+"%");this.element.attr("aria-valuenow",a)}});b.extend(b.ui.progressbar,{version:"1.8.16"})})(jQuery); -;/* - * jQuery UI Effects 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Effects/ - */ -jQuery.effects||function(f,j){function m(c){var a;if(c&&c.constructor==Array&&c.length==3)return c;if(a=/rgb\(\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*,\s*([0-9]{1,3})\s*\)/.exec(c))return[parseInt(a[1],10),parseInt(a[2],10),parseInt(a[3],10)];if(a=/rgb\(\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*,\s*([0-9]+(?:\.[0-9]+)?)\%\s*\)/.exec(c))return[parseFloat(a[1])*2.55,parseFloat(a[2])*2.55,parseFloat(a[3])*2.55];if(a=/#([a-fA-F0-9]{2})([a-fA-F0-9]{2})([a-fA-F0-9]{2})/.exec(c))return[parseInt(a[1], -16),parseInt(a[2],16),parseInt(a[3],16)];if(a=/#([a-fA-F0-9])([a-fA-F0-9])([a-fA-F0-9])/.exec(c))return[parseInt(a[1]+a[1],16),parseInt(a[2]+a[2],16),parseInt(a[3]+a[3],16)];if(/rgba\(0, 0, 0, 0\)/.exec(c))return n.transparent;return n[f.trim(c).toLowerCase()]}function s(c,a){var b;do{b=f.curCSS(c,a);if(b!=""&&b!="transparent"||f.nodeName(c,"body"))break;a="backgroundColor"}while(c=c.parentNode);return m(b)}function o(){var c=document.defaultView?document.defaultView.getComputedStyle(this,null):this.currentStyle, -a={},b,d;if(c&&c.length&&c[0]&&c[c[0]])for(var e=c.length;e--;){b=c[e];if(typeof c[b]=="string"){d=b.replace(/\-(\w)/g,function(g,h){return h.toUpperCase()});a[d]=c[b]}}else for(b in c)if(typeof c[b]==="string")a[b]=c[b];return a}function p(c){var a,b;for(a in c){b=c[a];if(b==null||f.isFunction(b)||a in t||/scrollbar/.test(a)||!/color/i.test(a)&&isNaN(parseFloat(b)))delete c[a]}return c}function u(c,a){var b={_:0},d;for(d in a)if(c[d]!=a[d])b[d]=a[d];return b}function k(c,a,b,d){if(typeof c=="object"){d= -a;b=null;a=c;c=a.effect}if(f.isFunction(a)){d=a;b=null;a={}}if(typeof a=="number"||f.fx.speeds[a]){d=b;b=a;a={}}if(f.isFunction(b)){d=b;b=null}a=a||{};b=b||a.duration;b=f.fx.off?0:typeof b=="number"?b:b in f.fx.speeds?f.fx.speeds[b]:f.fx.speeds._default;d=d||a.complete;return[c,a,b,d]}function l(c){if(!c||typeof c==="number"||f.fx.speeds[c])return true;if(typeof c==="string"&&!f.effects[c])return true;return false}f.effects={};f.each(["backgroundColor","borderBottomColor","borderLeftColor","borderRightColor", -"borderTopColor","borderColor","color","outlineColor"],function(c,a){f.fx.step[a]=function(b){if(!b.colorInit){b.start=s(b.elem,a);b.end=m(b.end);b.colorInit=true}b.elem.style[a]="rgb("+Math.max(Math.min(parseInt(b.pos*(b.end[0]-b.start[0])+b.start[0],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[1]-b.start[1])+b.start[1],10),255),0)+","+Math.max(Math.min(parseInt(b.pos*(b.end[2]-b.start[2])+b.start[2],10),255),0)+")"}});var n={aqua:[0,255,255],azure:[240,255,255],beige:[245,245,220],black:[0, -0,0],blue:[0,0,255],brown:[165,42,42],cyan:[0,255,255],darkblue:[0,0,139],darkcyan:[0,139,139],darkgrey:[169,169,169],darkgreen:[0,100,0],darkkhaki:[189,183,107],darkmagenta:[139,0,139],darkolivegreen:[85,107,47],darkorange:[255,140,0],darkorchid:[153,50,204],darkred:[139,0,0],darksalmon:[233,150,122],darkviolet:[148,0,211],fuchsia:[255,0,255],gold:[255,215,0],green:[0,128,0],indigo:[75,0,130],khaki:[240,230,140],lightblue:[173,216,230],lightcyan:[224,255,255],lightgreen:[144,238,144],lightgrey:[211, -211,211],lightpink:[255,182,193],lightyellow:[255,255,224],lime:[0,255,0],magenta:[255,0,255],maroon:[128,0,0],navy:[0,0,128],olive:[128,128,0],orange:[255,165,0],pink:[255,192,203],purple:[128,0,128],violet:[128,0,128],red:[255,0,0],silver:[192,192,192],white:[255,255,255],yellow:[255,255,0],transparent:[255,255,255]},q=["add","remove","toggle"],t={border:1,borderBottom:1,borderColor:1,borderLeft:1,borderRight:1,borderTop:1,borderWidth:1,margin:1,padding:1};f.effects.animateClass=function(c,a,b, -d){if(f.isFunction(b)){d=b;b=null}return this.queue(function(){var e=f(this),g=e.attr("style")||" ",h=p(o.call(this)),r,v=e.attr("class");f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});r=p(o.call(this));e.attr("class",v);e.animate(u(h,r),{queue:false,duration:a,easing:b,complete:function(){f.each(q,function(w,i){c[i]&&e[i+"Class"](c[i])});if(typeof e.attr("style")=="object"){e.attr("style").cssText="";e.attr("style").cssText=g}else e.attr("style",g);d&&d.apply(this,arguments);f.dequeue(this)}})})}; -f.fn.extend({_addClass:f.fn.addClass,addClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{add:c},a,b,d]):this._addClass(c)},_removeClass:f.fn.removeClass,removeClass:function(c,a,b,d){return a?f.effects.animateClass.apply(this,[{remove:c},a,b,d]):this._removeClass(c)},_toggleClass:f.fn.toggleClass,toggleClass:function(c,a,b,d,e){return typeof a=="boolean"||a===j?b?f.effects.animateClass.apply(this,[a?{add:c}:{remove:c},b,d,e]):this._toggleClass(c,a):f.effects.animateClass.apply(this, -[{toggle:c},a,b,d])},switchClass:function(c,a,b,d,e){return f.effects.animateClass.apply(this,[{add:a,remove:c},b,d,e])}});f.extend(f.effects,{version:"1.8.16",save:function(c,a){for(var b=0;b").addClass("ui-effects-wrapper").css({fontSize:"100%",background:"transparent",border:"none",margin:0,padding:0}), -d=document.activeElement;c.wrap(b);if(c[0]===d||f.contains(c[0],d))f(d).focus();b=c.parent();if(c.css("position")=="static"){b.css({position:"relative"});c.css({position:"relative"})}else{f.extend(a,{position:c.css("position"),zIndex:c.css("z-index")});f.each(["top","left","bottom","right"],function(e,g){a[g]=c.css(g);if(isNaN(parseInt(a[g],10)))a[g]="auto"});c.css({position:"relative",top:0,left:0,right:"auto",bottom:"auto"})}return b.css(a).show()},removeWrapper:function(c){var a,b=document.activeElement; -if(c.parent().is(".ui-effects-wrapper")){a=c.parent().replaceWith(c);if(c[0]===b||f.contains(c[0],b))f(b).focus();return a}return c},setTransition:function(c,a,b,d){d=d||{};f.each(a,function(e,g){unit=c.cssUnit(g);if(unit[0]>0)d[g]=unit[0]*b+unit[1]});return d}});f.fn.extend({effect:function(c){var a=k.apply(this,arguments),b={options:a[1],duration:a[2],callback:a[3]};a=b.options.mode;var d=f.effects[c];if(f.fx.off||!d)return a?this[a](b.duration,b.callback):this.each(function(){b.callback&&b.callback.call(this)}); -return d.call(this,b)},_show:f.fn.show,show:function(c){if(l(c))return this._show.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="show";return this.effect.apply(this,a)}},_hide:f.fn.hide,hide:function(c){if(l(c))return this._hide.apply(this,arguments);else{var a=k.apply(this,arguments);a[1].mode="hide";return this.effect.apply(this,a)}},__toggle:f.fn.toggle,toggle:function(c){if(l(c)||typeof c==="boolean"||f.isFunction(c))return this.__toggle.apply(this,arguments);else{var a=k.apply(this, -arguments);a[1].mode="toggle";return this.effect.apply(this,a)}},cssUnit:function(c){var a=this.css(c),b=[];f.each(["em","px","%","pt"],function(d,e){if(a.indexOf(e)>0)b=[parseFloat(a),e]});return b}});f.easing.jswing=f.easing.swing;f.extend(f.easing,{def:"easeOutQuad",swing:function(c,a,b,d,e){return f.easing[f.easing.def](c,a,b,d,e)},easeInQuad:function(c,a,b,d,e){return d*(a/=e)*a+b},easeOutQuad:function(c,a,b,d,e){return-d*(a/=e)*(a-2)+b},easeInOutQuad:function(c,a,b,d,e){if((a/=e/2)<1)return d/ -2*a*a+b;return-d/2*(--a*(a-2)-1)+b},easeInCubic:function(c,a,b,d,e){return d*(a/=e)*a*a+b},easeOutCubic:function(c,a,b,d,e){return d*((a=a/e-1)*a*a+1)+b},easeInOutCubic:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a+b;return d/2*((a-=2)*a*a+2)+b},easeInQuart:function(c,a,b,d,e){return d*(a/=e)*a*a*a+b},easeOutQuart:function(c,a,b,d,e){return-d*((a=a/e-1)*a*a*a-1)+b},easeInOutQuart:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a+b;return-d/2*((a-=2)*a*a*a-2)+b},easeInQuint:function(c,a,b, -d,e){return d*(a/=e)*a*a*a*a+b},easeOutQuint:function(c,a,b,d,e){return d*((a=a/e-1)*a*a*a*a+1)+b},easeInOutQuint:function(c,a,b,d,e){if((a/=e/2)<1)return d/2*a*a*a*a*a+b;return d/2*((a-=2)*a*a*a*a+2)+b},easeInSine:function(c,a,b,d,e){return-d*Math.cos(a/e*(Math.PI/2))+d+b},easeOutSine:function(c,a,b,d,e){return d*Math.sin(a/e*(Math.PI/2))+b},easeInOutSine:function(c,a,b,d,e){return-d/2*(Math.cos(Math.PI*a/e)-1)+b},easeInExpo:function(c,a,b,d,e){return a==0?b:d*Math.pow(2,10*(a/e-1))+b},easeOutExpo:function(c, -a,b,d,e){return a==e?b+d:d*(-Math.pow(2,-10*a/e)+1)+b},easeInOutExpo:function(c,a,b,d,e){if(a==0)return b;if(a==e)return b+d;if((a/=e/2)<1)return d/2*Math.pow(2,10*(a-1))+b;return d/2*(-Math.pow(2,-10*--a)+2)+b},easeInCirc:function(c,a,b,d,e){return-d*(Math.sqrt(1-(a/=e)*a)-1)+b},easeOutCirc:function(c,a,b,d,e){return d*Math.sqrt(1-(a=a/e-1)*a)+b},easeInOutCirc:function(c,a,b,d,e){if((a/=e/2)<1)return-d/2*(Math.sqrt(1-a*a)-1)+b;return d/2*(Math.sqrt(1-(a-=2)*a)+1)+b},easeInElastic:function(c,a,b, -d,e){c=1.70158;var g=0,h=d;if(a==0)return b;if((a/=e)==1)return b+d;g||(g=e*0.3);if(h").css({position:"absolute",visibility:"visible",left:-f*(h/d),top:-e*(i/c)}).parent().addClass("ui-effects-explode").css({position:"absolute",overflow:"hidden",width:h/d,height:i/c,left:g.left+f*(h/d)+(a.options.mode=="show"?(f-Math.floor(d/2))*(h/d):0),top:g.top+e*(i/c)+(a.options.mode=="show"?(e-Math.floor(c/2))*(i/c):0),opacity:a.options.mode=="show"?0:1}).animate({left:g.left+f*(h/d)+(a.options.mode=="show"?0:(f-Math.floor(d/2))*(h/d)),top:g.top+ -e*(i/c)+(a.options.mode=="show"?0:(e-Math.floor(c/2))*(i/c)),opacity:a.options.mode=="show"?1:0},a.duration||500);setTimeout(function(){a.options.mode=="show"?b.css({visibility:"visible"}):b.css({visibility:"visible"}).hide();a.callback&&a.callback.apply(b[0]);b.dequeue();j("div.ui-effects-explode").remove()},a.duration||500)})}})(jQuery); -;/* - * jQuery UI Effects Fade 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Effects/Fade - * - * Depends: - * jquery.effects.core.js - */ -(function(b){b.effects.fade=function(a){return this.queue(function(){var c=b(this),d=b.effects.setMode(c,a.options.mode||"hide");c.animate({opacity:d},{queue:false,duration:a.duration,easing:a.options.easing,complete:function(){a.callback&&a.callback.apply(this,arguments);c.dequeue()}})})}})(jQuery); -;/* - * jQuery UI Effects Fold 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Effects/Fold - * - * Depends: - * jquery.effects.core.js - */ -(function(c){c.effects.fold=function(a){return this.queue(function(){var b=c(this),j=["position","top","bottom","left","right"],d=c.effects.setMode(b,a.options.mode||"hide"),g=a.options.size||15,h=!!a.options.horizFirst,k=a.duration?a.duration/2:c.fx.speeds._default/2;c.effects.save(b,j);b.show();var e=c.effects.createWrapper(b).css({overflow:"hidden"}),f=d=="show"!=h,l=f?["width","height"]:["height","width"];f=f?[e.width(),e.height()]:[e.height(),e.width()];var i=/([0-9]+)%/.exec(g);if(i)g=parseInt(i[1], -10)/100*f[d=="hide"?0:1];if(d=="show")e.css(h?{height:0,width:g}:{height:g,width:0});h={};i={};h[l[0]]=d=="show"?f[0]:g;i[l[1]]=d=="show"?f[1]:0;e.animate(h,k,a.options.easing).animate(i,k,a.options.easing,function(){d=="hide"&&b.hide();c.effects.restore(b,j);c.effects.removeWrapper(b);a.callback&&a.callback.apply(b[0],arguments);b.dequeue()})})}})(jQuery); -;/* - * jQuery UI Effects Highlight 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Effects/Highlight - * - * Depends: - * jquery.effects.core.js - */ -(function(b){b.effects.highlight=function(c){return this.queue(function(){var a=b(this),e=["backgroundImage","backgroundColor","opacity"],d=b.effects.setMode(a,c.options.mode||"show"),f={backgroundColor:a.css("backgroundColor")};if(d=="hide")f.opacity=0;b.effects.save(a,e);a.show().css({backgroundImage:"none",backgroundColor:c.options.color||"#ffff99"}).animate(f,{queue:false,duration:c.duration,easing:c.options.easing,complete:function(){d=="hide"&&a.hide();b.effects.restore(a,e);d=="show"&&!b.support.opacity&& -this.style.removeAttribute("filter");c.callback&&c.callback.apply(this,arguments);a.dequeue()}})})}})(jQuery); -;/* - * jQuery UI Effects Pulsate 1.8.16 - * - * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about) - * Dual licensed under the MIT or GPL Version 2 licenses. - * http://jquery.org/license - * - * http://docs.jquery.com/UI/Effects/Pulsate - * - * Depends: - * jquery.effects.core.js - */ -(function(d){d.effects.pulsate=function(a){return this.queue(function(){var b=d(this),c=d.effects.setMode(b,a.options.mode||"show");times=(a.options.times||5)*2-1;duration=a.duration?a.duration/2:d.fx.speeds._default/2;isVisible=b.is(":visible");animateTo=0;if(!isVisible){b.css("opacity",0).show();animateTo=1}if(c=="hide"&&isVisible||c=="show"&&!isVisible)times--;for(c=0;c').appendTo(document.body).addClass(a.options.className).css({top:d.top,left:d.left,height:b.innerHeight(),width:b.innerWidth(),position:"absolute"}).animate(c,a.duration,a.options.easing,function(){f.remove();a.callback&&a.callback.apply(b[0],arguments); -b.dequeue()})})}})(jQuery); -; \ No newline at end of file diff --git a/ext/pavlov-0.3.0pre.js b/ext/pavlov-0.3.0pre.js new file mode 100644 index 0000000..002d7f2 --- /dev/null +++ b/ext/pavlov-0.3.0pre.js @@ -0,0 +1,740 @@ +/** + * Pavlov - Test framework-independent behavioral API + * + * version 0.3.0pre + * + * http://github.com/mmonteleone/pavlov + * + * Copyright (c) 2009-2011 Michael Monteleone + * Licensed under terms of the MIT License (README.markdown) + */ +(function (global) { + + // =========== + // = Helpers = + // =========== + + var util = { + /** + * Iterates over an object or array + * @param {Object|Array} object object or array to iterate + * @param {Function} callback callback for each iterated item + */ + each: function (object, callback) { + if (typeof object === 'undefined' || typeof callback === 'undefined' + || object === null || callback === null) { + throw "both 'target' and 'callback' arguments are required"; + } + var name, + i = 0, + length = object.length, + value; + + if (length === undefined) { + for (name in object) { + if (object.hasOwnProperty(name)) { + if (callback.call( object[name], name, object[name]) === false) { + break; + } + } + } + } else { + for (value = object[0]; + i < length && callback.call(value, i, value) !== false; + value = object[++i]) { + } + } + + return object; + }, + /** + * converts an array-like object to an array + * @param {Object} array array-like object + * @returns array + */ + makeArray: function (array) { + return Array.prototype.slice.call(array); + }, + /** + * returns whether or not an object is an array + * @param {Object} obj object to test + * @returns whether or not object is array + */ + isArray: function (obj) { + return Object.prototype.toString.call(obj) === "[object Array]"; + }, + /** + * merges properties form one object to another + * @param {Object} dest object to receive merged properties + * @param {Object} src object containing properies to merge + */ + extend: function (dest, src) { + if (typeof dest === 'undefined' || typeof src === 'undefined' || + dest === null || src === null) { + throw "both 'source' and 'target' arguments are required"; + } + var prop; + for (prop in src) { + if (src.hasOwnProperty(prop)) { + dest[prop] = src[prop]; + } + } + }, + /** + * Naive display serializer for objects which wraps the objects' + * own toString() value with type-specific delimiters. + * [] for array + * "" for string + * Does not currently go nearly detailed enough for JSON use, + * just enough to show small values within test results + * @param {Object} obj object to serialize + * @returns naive display-serialized string representation of the object + */ + serialize: function (obj) { + if (typeof obj === 'undefined') { + return ""; + } else if (Object.prototype.toString.call(obj) === "[object Array]") { + return '[' + obj.toString() + ']'; + } else if (Object.prototype.toString.call(obj) === "[object Function]") { + return "function()"; + } else if (typeof obj === "string") { + return '"' + obj + '"'; + } else { + return obj; + } + }, + /** + * transforms a camel or pascal case string + * to all lower-case space-separated phrase + * @param {string} value pascal or camel-cased string + * @returns all-lower-case space-separated phrase + */ + phraseCase: function (value) { + return value.replace(/([A-Z])/g, ' $1').toLowerCase(); + } + }; + + + // ==================== + // = Example Building = + // ==================== + + var examples = [], + currentExample, + /** + * Rolls up list of current and ancestors values for given prop name + * @param {String} prop Name of property to roll up + * @returns array of values corresponding to prop name + */ + rollup = function (example, prop) { + var items = []; + while (example !== null) { + items.push(example[prop]); + example = example.parent; + } + return items; + }; + + /** + * Example Class + * Represents an instance of an example (a describe) + * contains references to parent and nested examples + * exposes methods for returning combined lists of before, after, and names + * @constructor + * @param {example} parent example to append self as child to (optional) + */ + function Example(parent) { + if (parent) { + // if there's a parent, append self as nested example + this.parent = parent; + this.parent.children.push(this); + } else { + // otherwise, add this as a new root example + examples.push(this); + } + + this.children = []; + this.specs = []; + } + util.extend(Example.prototype, { + name: '', // name of this description + parent: null, // parent example + children: [], // nested examples + specs: [], // array of it() tests/specs + before: function () {}, // called before all contained specs + after: function () {}, // called after all contained specs + /** + * rolls up this and ancestor's before functions + * @returns array of functions + */ + befores: function () { + return rollup(this, 'before').reverse(); + }, + /** + * Rolls up this and ancestor's after functions + * @returns array of functions + */ + afters: function () { + return rollup(this, 'after'); + }, + /** + * Rolls up this and ancestor's description names, joined + * @returns string of joined description names + */ + names: function () { + return rollup(this, 'name').reverse().join(', '); + } + }); + + + + // ============== + // = Assertions = + // ============== + + /** + * AssertionHandler + * represents instance of an assertion regarding a particular + * actual value, and provides an api around asserting that value + * against any of the bundled assertion handlers and custom ones. + * @constructor + * @param {Object} value A test-produced value to assert against + */ + function AssertionHandler(value) { + this.value = value; + } + + /** + * Appends assertion methods to the AssertionHandler prototype + * For each provided assertion implementation, adds an identically named + * assertion function to assertionHandler prototype which can run implementation + * @param {Object} asserts Object containing assertion implementations + */ + var addAssertions = function (asserts) { + util.each(asserts, function (name, fn) { + AssertionHandler.prototype[name] = function () { + // implement this handler against backend + // by pre-pending AssertionHandler's current value to args + var args = util.makeArray(arguments); + args.unshift(this.value); + + // if no explicit message was given with the assertion, + // then let's build our own friendly one + if (fn.length === 2) { + args[1] = args[1] || 'asserting ' + util.serialize(args[0]) + ' ' + util.phraseCase(name); + } else if (fn.length === 3) { + var expected = util.serialize(args[1]); + args[2] = args[2] || 'asserting ' + util.serialize(args[0]) + ' ' + util.phraseCase(name) + (expected ? ' ' + expected : expected); + } + + fn.apply(this, args); + }; + }); + }; + + /** + * Add default assertions + */ + addAssertions({ + equals: function (actual, expected, message) { + adapter.assert(actual == expected, message); + }, + isEqualTo: function (actual, expected, message) { + adapter.assert(actual == expected, message); + }, + isNotEqualTo: function (actual, expected, message) { + adapter.assert(actual != expected, message); + }, + isStrictlyEqualTo: function (actual, expected, message) { + adapter.assert(actual === expected, message); + }, + isNotStrictlyEqualTo: function (actual, expected, message) { + adapter.assert(actual !== expected, message); + }, + isTrue: function (actual, message) { + adapter.assert(actual, message); + }, + isFalse: function (actual, message) { + adapter.assert(!actual, message); + }, + isNull: function (actual, message) { + adapter.assert(actual === null, message); + }, + isNotNull: function (actual, message) { + adapter.assert(actual !== null, message); + }, + isDefined: function (actual, message) { + adapter.assert(typeof actual !== 'undefined', message); + }, + isUndefined: function (actual, message) { + adapter.assert(typeof actual === 'undefined', message); + }, + pass: function (actual, message) { + adapter.assert(true, message); + }, + fail: function (actual, message) { + adapter.assert(false, message); + }, + isFunction: function(actual, message) { + return adapter.assert(typeof actual === "function", message); + }, + isNotFunction: function (actual, message) { + return adapter.assert(typeof actual !== "function", message); + }, + throwsException: function (actual, expectedErrorDescription, message) { + // can optionally accept expected error message + try { + actual(); + adapter.assert(false, message); + } catch (e) { + // so, this bit of weirdness is basically a way to allow for the fact + // that the test may have specified a particular type of error to catch, or not. + // and if not, e would always === e. + adapter.assert(e === (expectedErrorDescription || e), message); + } + } + }); + + + // ===================== + // = pavlov Public API = + // ===================== + + + /** + * Object containing methods to be made available as public API + */ + var api = { + /** + * Initiates a new Example context + * @param {String} description Name of what's being "described" + * @param {Function} fn Function containing description (before, after, specs, nested examples) + */ + describe: function (description, fn) { + if (arguments.length < 2) { + throw "both 'description' and 'fn' arguments are required"; + } + + // capture reference to current example before construction + var originalExample = currentExample; + try { + // create new current example for construction + currentExample = new Example(currentExample); + currentExample.name = description; + fn(); + } finally { + // restore original reference after construction + currentExample = originalExample; + } + }, + + /** + * Sets a function to occur before all contained specs and nested examples' specs + * @param {Function} fn Function to be executed + */ + before: function (fn) { + if (arguments.length === 0) { + throw "'fn' argument is required"; + } + currentExample.before = fn; + }, + + /** + * Sets a function to occur after all contained tests and nested examples' tests + * @param {Function} fn Function to be executed + */ + after: function (fn) { + if (arguments.length === 0) { + throw "'fn' argument is required"; + } + currentExample.after = fn; + }, + + /** + * Creates a spec (test) to occur within an example + * When not passed fn, creates a spec-stubbing fn which asserts fail "Not Implemented" + * @param {String} specification Description of what "it" "should do" + * @param {Function} fn Function containing a test to assert that it does indeed do it (optional) + */ + it: function (specification, fn) { + if (arguments.length === 0) { + throw "'specification' argument is required"; + } + if (fn) { + if (fn.async) { + specification += " asynchronously"; + } + currentExample.specs.push([specification, fn]); + } else { + // if not passed an implementation, create an implementation that simply asserts fail + api.it(specification, function () {api.assert.fail('Not Implemented');}); + } + }, + + /** + * wraps a spec (test) implementation with an initial call to pause() the test runner + * The spec must call resume() when ready + * @param {Function} fn Function containing a test to assert that it does indeed do it (optional) + */ + async: function (fn) { + var implementation = function () { + adapter.pause(); + fn.apply(this, arguments); + }; + implementation.async = true; + return implementation; + }, + + /** + * Generates a row spec for each argument passed, applying + * each argument to a new call against the spec + * @returns an object with an it() function for defining + * function to be called for each of given's arguments + * @param {Array} arguments either list of values or list of arrays of values + */ + given: function () { + if (arguments.length === 0) { + throw "at least one argument is required"; + } + var args = util.makeArray(arguments); + if (arguments.length === 1 && util.isArray(arguments[0])) { + args = args[0]; + } + + return { + /** + * Defines a row spec (test) which is applied against each + * of the given's arguments. + */ + it: function (specification, fn) { + util.each(args, function () { + var arg = this; + api.it("given " + arg + ", " + specification, function () { + fn.apply(this, util.isArray(arg) ? arg : [arg]); + }); + }); + } + }; + }, + + /** + * Assert a value against any of the bundled or custom assertions + * @param {Object} value A value to be asserted + * @returns an AssertionHandler instance to fluently perform an assertion with + */ + assert: function (value) { + return new AssertionHandler(value); + }, + + /** + * specifies test runner to synchronously wait + * @param {Number} ms Milliseconds to wait + * @param {Function} fn Function to execute after ms has + * passed before resuming + */ + wait: function (ms, fn) { + if (arguments.length < 2) { + throw "both 'ms' and 'fn' arguments are required"; + } + adapter.pause(); + global.setTimeout(function () { + fn(); + adapter.resume(); + }, ms); + }, + + /** + * specifies test framework to pause test runner + */ + pause: function () { + adapter.pause(); + }, + + /** + * specifies test framework to resume test runner + */ + resume: function () { + adapter.resume(); + } + }; + + // extend api's assert function for easier access to + // parameter-less assert.pass() and assert.fail() calls + util.each(['pass', 'fail'], function (i, method) { + api.assert[method] = function (message) { + api.assert()[method](message); + }; + }); + + /** + * Extends a function's scope + * applies the extra scope to the function returns un-run new version of fn + * inspired by Yehuda Katz's metaprogramming Screw.Unit + * different in that new function can still accept all parameters original function could + * @param {Function} fn Target function for extending + * @param {Object} thisArg Object for the function's "this" to refer + * @param {Object} extraScope object whose members will be added to fn's scope + * @returns Modified version of original function with extra scope. Can still + * accept parameters of original function + */ + var extendScope = function (fn, thisArg, extraScope) { + + // get a string of the fn's parameters + var params = fn.toString().match(/\(([^\)]*)\)/)[1], + // get a string of fn's body + source = fn.toString().match(/^[^\{]*\{((.*\s*)*)\}/m)[1]; + + // create a new function with same parameters and + // body wrapped in a with(extraScope) { } + fn = new Function ( + "extraScope" + (params ? ", " + params : ""), + "with(extraScope) {" + source + "}"); + + // returns a fn wrapper which takes passed args, + // pre-pends extraScope arg, and applies to modified fn + return function () { + var args = [extraScope]; + util.each(arguments,function () { + args.push(this); + }); + fn.apply(thisArg, args); + }; + }; + + /** + * Top-level Specify method. Declares a new pavlov context + * @param {String} name Name of what's being specified + * @param {Function} fn Function containing exmaples and specs + */ + var specify = function (name, fn) { + if (arguments.length < 2) { + throw "both 'name' and 'fn' arguments are required"; + } + examples = []; + currentExample = null; + + // set the test suite title + name += " Specifications"; + if (typeof document !== 'undefined') { + document.title = name + ' - Pavlov - ' + adapter.name; + } + + // run the adapter initiation + adapter.initiate(name); + + if (specify.globalApi) { + // if set to extend global api, + // extend global api and run example builder + util.extend(global, api); + fn(); + } else { + // otherwise, extend example builder's scope with api + // and run example builder + extendScope(fn, this, api)(); + } + + // compile examples against the adapter and then run them + adapter.compile(name, examples)(); + }; + + // ==================================== + // = Test Framework Adapter Interface = + // ==================================== + + // abstracts functionality of underlying testing framework + var adapter = { + /** + * adapter-specific initialization code + * which is called once before any tests are run + * @param {String} suiteName name of the pavlov suite name + */ + initiate: function (suiteName) { }, + /** + * adapter-specific assertion method + * @param {bool} expr Boolean expression to assert against + * @param {String} message message to pass along with assertion + */ + assert: function (expr, message) { + throw "'assert' must be implemented by a test framework adapter"; + }, + /** + * adapter-specific compilation method. Translates a nested set of + * pre-constructed Pavlov example objects into a callable function which, when run + * will execute the tests within the backend test framework + * @param {String} suiteName name of overall test suite + * @param {Array} examples Array of example object instances, possibly nesteds + */ + compile: function (suiteName, examples) { + throw "'compile' must be implemented by a test framework adapter"; + }, + /** + * adapter-specific pause method. When an adapter implements, + * allows for its test runner to pause its execution + */ + pause: function () { + throw "'pause' not implemented by current test framework adapter"; + }, + /** + * adapter-specific resume method. When an adapter implements, + * allows for its test runner to resume after a pause + */ + resume: function () { + throw "'resume' not implemented by current test framework adapter"; + } + }; + + + // ===================== + // = Expose Public API = + // ===================== + + // add global settings onto pavlov + global.pavlov = { + version: '0.3.0pre', + specify: specify, + adapter: adapter, + adapt: function (frameworkName, testFrameworkAdapter) { + if ( typeof frameworkName === "undefined" || + typeof testFrameworkAdapter === "undefined" || + frameworkName === null || + testFrameworkAdapter === null) { + throw "both 'frameworkName' and 'testFrameworkAdapter' arguments are required"; + } + adapter.name = frameworkName; + util.extend(adapter, testFrameworkAdapter); + }, + util: { + each: util.each, + extend: util.extend + }, + api: api, + globalApi: false, // when true, adds api to global scope + extendAssertions: addAssertions // function for adding custom assertions + }; +}(window)); + + +// ========================= +// = Default QUnit Adapter = +// ========================= + +(function () { + if (typeof QUnit === 'undefined') { return; } + + pavlov.adapt("QUnit", { + initiate: function (name) { + var addEvent = function (elem, type, fn) { + if (elem.addEventListener) { + elem.addEventListener(type, fn, false); + } else if (elem.attachEvent) { + elem.attachEvent("on" + type, fn); + } + }; + + // after suite loads, set the header on the report page + addEvent(window,'load',function () { + // document.getElementsByTag('h1').innerHTML = name; + var h1s = document.getElementsByTagName('h1'); + if (h1s.length > 0) { + h1s[0].innerHTML = name; + } + }); + }, + /** + * Implements assert against QUnit's `ok` + */ + assert: function (expr, msg) { + ok(expr, msg); + }, + /** + * Implements pause against QUnit's stop() + */ + pause: function () { + stop(); + }, + /** + * Implements resume against QUnit's start() + */ + resume: function () { + start(); + }, + /** + * Compiles nested set of examples into flat array of QUnit statements + * returned bound up in a single callable function + * @param {Array} examples Array of possibly nested Example instances + * @returns function of which, when called, will execute all translated QUnit statements + */ + compile: function (name, examples) { + var statements = [], + each = pavlov.util.each; + + /** + * Comples a single example and its children into QUnit statements + * @param {Example} example Single example instance + * possibly with nested instances + */ + var compileDescription = function (example) { + + // get before and after rollups + var befores = example.befores(), + afters = example.afters(); + + // create a module with setup and teardown + // that executes all current befores/afters + statements.push(function () { + module(example.names(), { + setup: function () { + each(befores, function () { this(); }); + }, + teardown: function () { + each(afters, function () { this(); }); + } + }); + }); + + // create a test for each spec/"it" in the example + each(example.specs, function () { + var spec = this; + statements.push(function () { + test(spec[0],spec[1]); + }); + }); + + // recurse through example's nested examples + each(example.children, function () { + compileDescription(this); + }); + }; + + // compile all root examples + each(examples, function () { + compileDescription(this, statements); + }); + + // return a single function which, when called, + // executes all qunit statements + return function () { + each(statements, function () { this(); }); + }; + } + }); + + pavlov.extendAssertions({ + /** + * Asserts two objects are deeply equivalent, proxying QUnit's deepEqual assertion + */ + isSameAs: function (actual, expected, message) { + deepEqual(actual, expected, message); + }, + /* + * Asserts two objects are deeply in-equivalent, proxying QUnit's notDeepEqual assertion + */ + isNotSameAs: function (actual, expected, message) { + notDeepEqual(actual, expected, message); + } + }); + + // alias pavlov.specify as QUnit.specify for legacy support + QUnit.specify = pavlov.specify; + pavlov.util.extend(QUnit.specify, pavlov); +}()); \ No newline at end of file diff --git a/ext/postal-0.4.0.js b/ext/postal-0.4.0.js new file mode 100644 index 0000000..3cb0b39 --- /dev/null +++ b/ext/postal-0.4.0.js @@ -0,0 +1,347 @@ +define(['underscore'], function(_) { + /* + postal.js + Author: Jim Cowart + License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) + Version 0.4.0 + */ + + var DEFAULT_EXCHANGE = "/", + DEFAULT_PRIORITY = 50, + DEFAULT_DISPOSEAFTER = 0, + SYSTEM_EXCHANGE = "postal", + NO_OP = function() { }, + parsePublishArgs = function(args) { + var parsed = { envelope: { } }, env; + switch(args.length) { + case 3: + if(typeof args[1] === "Object" && typeof args[2] === "Object") { + parsed.envelope.exchange = DEFAULT_EXCHANGE; + parsed.envelope.topic = args[0]; + parsed.payload = args[1]; + env = parsed.envelope; + parsed.envelope = _.extend(env, args[2]); + } + else { + parsed.envelope.exchange = args[0]; + parsed.envelope.topic = args[1]; + parsed.payload = args[2]; + } + break; + case 4: + parsed.envelope.exchange = args[0]; + parsed.envelope.topic = args[1]; + parsed.payload = args[2]; + env = parsed.envelope; + parsed.envelope = _.extend(env, args[3]); + break; + default: + parsed.envelope.exchange = DEFAULT_EXCHANGE; + parsed.envelope.topic = args[0]; + parsed.payload = args[1]; + break; + } + return parsed; + }; + + var DistinctPredicate = function() { + var previous; + return function(data) { + var eq = false; + if(_.isString(data)) { + eq = data === previous; + previous = data; + } + else { + eq = _.isEqual(data, previous); + previous = _.clone(data); + } + return !eq; + }; + }; + + var ChannelDefinition = function(exchange, topic) { + this.exchange = exchange; + this.topic = topic; + }; + + ChannelDefinition.prototype = { + subscribe: function(callback) { + var subscription = new SubscriptionDefinition(this.exchange, this.topic, callback); + postal.configuration.bus.subscribe(subscription); + return subscription; + }, + + publish: function(data, envelope) { + var env = _.extend({ + exchange: this.exchange, + timeStamp: new Date(), + topic: this.topic + }, envelope); + postal.configuration.bus.publish(data, env); + } + }; + + var SubscriptionDefinition = function(exchange, topic, callback) { + this.exchange = exchange; + this.topic = topic; + this.callback = callback; + this.priority = DEFAULT_PRIORITY; + this.constraints = []; + this.maxCalls = DEFAULT_DISPOSEAFTER; + this.onHandled = NO_OP; + this.context = null; + + postal.publish(SYSTEM_EXCHANGE, "subscription.created", + { + event: "subscription.created", + exchange: exchange, + topic: topic + }); + }; + + SubscriptionDefinition.prototype = { + unsubscribe: function() { + postal.configuration.bus.unsubscribe(this); + postal.publish(SYSTEM_EXCHANGE, "subscription.removed", + { + event: "subscription.removed", + exchange: this.exchange, + topic: this.topic + }); + }, + + defer: function() { + var fn = this.callback; + this.callback = function(data) { + setTimeout(fn,0,data); + }; + return this; + }, + + disposeAfter: function(maxCalls) { + if(_.isNaN(maxCalls) || maxCalls <= 0) { + throw "The value provided to disposeAfter (maxCalls) must be a number greater than zero."; + } + + var fn = this.onHandled; + var dispose = _.after(maxCalls, _.bind(function() { + this.unsubscribe(this); + }, this)); + + this.onHandled = function() { + fn.apply(this.context, arguments); + dispose(); + }; + return this; + }, + + ignoreDuplicates: function() { + this.withConstraint(new DistinctPredicate()); + return this; + }, + + whenHandledThenExecute: function(callback) { + if(! _.isFunction(callback)) { + throw "Value provided to 'whenHandledThenExecute' must be a function"; + } + this.onHandled = callback; + return this; + }, + + withConstraint: function(predicate) { + if(! _.isFunction(predicate)) { + throw "Predicate constraint must be a function"; + } + this.constraints.push(predicate); + return this; + }, + + withConstraints: function(predicates) { + var self = this; + if(_.isArray(predicates)) { + _.each(predicates, function(predicate) { self.withConstraint(predicate); } ); + } + return self; + }, + + withContext: function(context) { + this.context = context; + return this; + }, + + withDebounce: function(milliseconds) { + if(_.isNaN(milliseconds)) { + throw "Milliseconds must be a number"; + } + var fn = this.callback; + this.callback = _.debounce(fn, milliseconds); + return this; + }, + + withDelay: function(milliseconds) { + if(_.isNaN(milliseconds)) { + throw "Milliseconds must be a number"; + } + var fn = this.callback; + this.callback = function(data) { + setTimeout(fn, milliseconds, data); + }; + return this; + }, + + withPriority: function(priority) { + if(_.isNaN(priority)) { + throw "Priority must be a number"; + } + this.priority = priority; + return this; + }, + + withThrottle: function(milliseconds) { + if(_.isNaN(milliseconds)) { + throw "Milliseconds must be a number"; + } + var fn = this.callback; + this.callback = _.throttle(fn, milliseconds); + return this; + } + }; + + var bindingsResolver = { + cache: { }, + + compare: function(binding, topic) { + if(this.cache[topic] && this.cache[topic][binding]) { + return true; + } + var rgx = new RegExp("^" + this.regexify(binding) + "$"), // match from start to end of string + result = rgx.test(topic); + if(result) { + if(!this.cache[topic]) { + this.cache[topic] = {}; + } + this.cache[topic][binding] = true; + } + return result; + }, + + regexify: function(binding) { + return binding.replace(/\./g,"\\.") // escape actual periods + .replace(/\*/g, ".*") // asterisks match any value + .replace(/#/g, "[A-Z,a-z,0-9]*"); // hash matches any alpha-numeric 'word' + } + }; + + var localBus = { + + subscriptions: {}, + + wireTaps: [], + + publish: function(data, envelope) { + this.notifyTaps(data, envelope); + + _.each(this.subscriptions[envelope.exchange], function(topic) { + _.each(topic, function(binding){ + if(postal.configuration.resolver.compare(binding.topic, envelope.topic)) { + if(_.all(binding.constraints, function(constraint) { return constraint(data); })) { + if(typeof binding.callback === 'function') { + binding.callback.apply(binding.context, [data, envelope]); + binding.onHandled(); + } + } + } + }); + }); + }, + + subscribe: function(subDef) { + var idx, found, fn; + + if(!this.subscriptions[subDef.exchange]) { + this.subscriptions[subDef.exchange] = {}; + } + if(!this.subscriptions[subDef.exchange][subDef.topic]) { + this.subscriptions[subDef.exchange][subDef.topic] = []; + } + + idx = this.subscriptions[subDef.exchange][subDef.topic].length - 1; + if(!_.any(this.subscriptions[subDef.exchange][subDef.topic], function(cfg) { return cfg === subDef; })) { + for(; idx >= 0; idx--) { + if(this.subscriptions[subDef.exchange][subDef.topic][idx].priority <= subDef.priority) { + this.subscriptions[subDef.exchange][subDef.topic].splice(idx + 1, 0, subDef); + found = true; + break; + } + } + if(!found) { + this.subscriptions[subDef.exchange][subDef.topic].unshift(subDef); + } + } + + return _.bind(function() { this.unsubscribe(subDef); }, this); + }, + + notifyTaps: function(data, envelope) { + _.each(this.wireTaps,function(tap) { + tap(data, envelope); + }); + }, + + unsubscribe: function(config) { + if(this.subscriptions[config.exchange][config.topic]) { + var len = this.subscriptions[config.exchange][config.topic].length, + idx = 0; + for ( ; idx < len; idx++ ) { + if (this.subscriptions[config.exchange][config.topic][idx] === config) { + this.subscriptions[config.exchange][config.topic].splice( idx, 1 ); + break; + } + } + } + }, + + addWireTap: function(callback) { + this.wireTaps.push(callback); + return function() { + var idx = this.wireTaps.indexOf(callback); + if(idx !== -1) { + this.wireTaps.splice(idx,1); + } + }; + } + }; + + var postal = { + configuration: { + bus: localBus, + resolver: bindingsResolver + }, + + channel: function(exchange, topic) { + var exch = arguments.length === 2 ? exchange : DEFAULT_EXCHANGE, + tpc = arguments.length === 2 ? topic : exchange; + return new ChannelDefinition(exch, tpc); + }, + + subscribe: function(exchange, topic, callback) { + var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE, + tpc = arguments.length === 3 ? topic : exchange, + callbk = arguments.length === 3 ? callback : topic; + var channel = this.channel(exch, tpc); + return channel.subscribe(callbk); + }, + + publish: function(exchange, topic, payload, envelopeOptions) { + var parsedArgs = parsePublishArgs([].slice.call(arguments,0)); + var channel = this.channel(parsedArgs.envelope.exchange, parsedArgs.envelope.topic); + channel.publish(parsedArgs.payload, parsedArgs.envelope); + }, + + addWireTap: function(callback) { + this.configuration.bus.addWireTap(callback); + } + }; + + return postal; }); \ No newline at end of file diff --git a/ext/postal.js b/ext/postal.js new file mode 100644 index 0000000..b6e6048 --- /dev/null +++ b/ext/postal.js @@ -0,0 +1,361 @@ +var factory = function() { + /* + postal.js + Author: Jim Cowart + License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) + Version 0.4.0 + */ + + _ = _ || arguments[0]; + + var DEFAULT_EXCHANGE = "/", + DEFAULT_PRIORITY = 50, + DEFAULT_DISPOSEAFTER = 0, + SYSTEM_EXCHANGE = "postal", + NO_OP = function() { }, + parsePublishArgs = function(args) { + var parsed = { envelope: { } }, env; + switch(args.length) { + case 3: + if(typeof args[1] === "Object" && typeof args[2] === "Object") { + parsed.envelope.exchange = DEFAULT_EXCHANGE; + parsed.envelope.topic = args[0]; + parsed.payload = args[1]; + env = parsed.envelope; + parsed.envelope = _.extend(env, args[2]); + } + else { + parsed.envelope.exchange = args[0]; + parsed.envelope.topic = args[1]; + parsed.payload = args[2]; + } + break; + case 4: + parsed.envelope.exchange = args[0]; + parsed.envelope.topic = args[1]; + parsed.payload = args[2]; + env = parsed.envelope; + parsed.envelope = _.extend(env, args[3]); + break; + default: + parsed.envelope.exchange = DEFAULT_EXCHANGE; + parsed.envelope.topic = args[0]; + parsed.payload = args[1]; + break; + } + return parsed; + }; + + var DistinctPredicate = function() { + var previous; + return function(data) { + var eq = false; + if(_.isString(data)) { + eq = data === previous; + previous = data; + } + else { + eq = _.isEqual(data, previous); + previous = _.clone(data); + } + return !eq; + }; + }; + + var ChannelDefinition = function(exchange, topic) { + this.exchange = exchange; + this.topic = topic; + }; + + ChannelDefinition.prototype = { + subscribe: function(callback) { + var subscription = new SubscriptionDefinition(this.exchange, this.topic, callback); + postal.configuration.bus.subscribe(subscription); + return subscription; + }, + + publish: function(data, envelope) { + var env = _.extend({ + exchange: this.exchange, + timeStamp: new Date(), + topic: this.topic + }, envelope); + postal.configuration.bus.publish(data, env); + } + }; + + var SubscriptionDefinition = function(exchange, topic, callback) { + this.exchange = exchange; + this.topic = topic; + this.callback = callback; + this.priority = DEFAULT_PRIORITY; + this.constraints = []; + this.maxCalls = DEFAULT_DISPOSEAFTER; + this.onHandled = NO_OP; + this.context = null; + + postal.publish(SYSTEM_EXCHANGE, "subscription.created", + { + event: "subscription.created", + exchange: exchange, + topic: topic + }); + }; + + SubscriptionDefinition.prototype = { + unsubscribe: function() { + postal.configuration.bus.unsubscribe(this); + postal.publish(SYSTEM_EXCHANGE, "subscription.removed", + { + event: "subscription.removed", + exchange: this.exchange, + topic: this.topic + }); + }, + + defer: function() { + var fn = this.callback; + this.callback = function(data) { + setTimeout(fn,0,data); + }; + return this; + }, + + disposeAfter: function(maxCalls) { + if(_.isNaN(maxCalls) || maxCalls <= 0) { + throw "The value provided to disposeAfter (maxCalls) must be a number greater than zero."; + } + + var fn = this.onHandled; + var dispose = _.after(maxCalls, _.bind(function() { + this.unsubscribe(this); + }, this)); + + this.onHandled = function() { + fn.apply(this.context, arguments); + dispose(); + }; + return this; + }, + + ignoreDuplicates: function() { + this.withConstraint(new DistinctPredicate()); + return this; + }, + + whenHandledThenExecute: function(callback) { + if(! _.isFunction(callback)) { + throw "Value provided to 'whenHandledThenExecute' must be a function"; + } + this.onHandled = callback; + return this; + }, + + withConstraint: function(predicate) { + if(! _.isFunction(predicate)) { + throw "Predicate constraint must be a function"; + } + this.constraints.push(predicate); + return this; + }, + + withConstraints: function(predicates) { + var self = this; + if(_.isArray(predicates)) { + _.each(predicates, function(predicate) { self.withConstraint(predicate); } ); + } + return self; + }, + + withContext: function(context) { + this.context = context; + return this; + }, + + withDebounce: function(milliseconds) { + if(_.isNaN(milliseconds)) { + throw "Milliseconds must be a number"; + } + var fn = this.callback; + this.callback = _.debounce(fn, milliseconds); + return this; + }, + + withDelay: function(milliseconds) { + if(_.isNaN(milliseconds)) { + throw "Milliseconds must be a number"; + } + var fn = this.callback; + this.callback = function(data) { + setTimeout(fn, milliseconds, data); + }; + return this; + }, + + withPriority: function(priority) { + if(_.isNaN(priority)) { + throw "Priority must be a number"; + } + this.priority = priority; + return this; + }, + + withThrottle: function(milliseconds) { + if(_.isNaN(milliseconds)) { + throw "Milliseconds must be a number"; + } + var fn = this.callback; + this.callback = _.throttle(fn, milliseconds); + return this; + } + }; + + var bindingsResolver = { + cache: { }, + + compare: function(binding, topic) { + if(this.cache[topic] && this.cache[topic][binding]) { + return true; + } + var rgx = new RegExp("^" + this.regexify(binding) + "$"), // match from start to end of string + result = rgx.test(topic); + if(result) { + if(!this.cache[topic]) { + this.cache[topic] = {}; + } + this.cache[topic][binding] = true; + } + return result; + }, + + regexify: function(binding) { + return binding.replace(/\./g,"\\.") // escape actual periods + .replace(/\*/g, ".*") // asterisks match any value + .replace(/#/g, "[A-Z,a-z,0-9]*"); // hash matches any alpha-numeric 'word' + } + }; + + var localBus = { + + subscriptions: {}, + + wireTaps: [], + + publish: function(data, envelope) { + this.notifyTaps(data, envelope); + + _.each(this.subscriptions[envelope.exchange], function(topic) { + _.each(topic, function(binding){ + if(postal.configuration.resolver.compare(binding.topic, envelope.topic)) { + if(_.all(binding.constraints, function(constraint) { return constraint(data); })) { + if(typeof binding.callback === 'function') { + binding.callback.apply(binding.context, [data, envelope]); + binding.onHandled(); + } + } + } + }); + }); + }, + + subscribe: function(subDef) { + var idx, found, fn; + + if(!this.subscriptions[subDef.exchange]) { + this.subscriptions[subDef.exchange] = {}; + } + if(!this.subscriptions[subDef.exchange][subDef.topic]) { + this.subscriptions[subDef.exchange][subDef.topic] = []; + } + + idx = this.subscriptions[subDef.exchange][subDef.topic].length - 1; + if(!_.any(this.subscriptions[subDef.exchange][subDef.topic], function(cfg) { return cfg === subDef; })) { + for(; idx >= 0; idx--) { + if(this.subscriptions[subDef.exchange][subDef.topic][idx].priority <= subDef.priority) { + this.subscriptions[subDef.exchange][subDef.topic].splice(idx + 1, 0, subDef); + found = true; + break; + } + } + if(!found) { + this.subscriptions[subDef.exchange][subDef.topic].unshift(subDef); + } + } + + return _.bind(function() { this.unsubscribe(subDef); }, this); + }, + + notifyTaps: function(data, envelope) { + _.each(this.wireTaps,function(tap) { + tap(data, envelope); + }); + }, + + unsubscribe: function(config) { + if(this.subscriptions[config.exchange][config.topic]) { + var len = this.subscriptions[config.exchange][config.topic].length, + idx = 0; + for ( ; idx < len; idx++ ) { + if (this.subscriptions[config.exchange][config.topic][idx] === config) { + this.subscriptions[config.exchange][config.topic].splice( idx, 1 ); + break; + } + } + } + }, + + addWireTap: function(callback) { + this.wireTaps.push(callback); + return function() { + var idx = this.wireTaps.indexOf(callback); + if(idx !== -1) { + this.wireTaps.splice(idx,1); + } + }; + } + }; + + var postal = { + configuration: { + bus: localBus, + resolver: bindingsResolver + }, + + channel: function(exchange, topic) { + var exch = arguments.length === 2 ? exchange : DEFAULT_EXCHANGE, + tpc = arguments.length === 2 ? topic : exchange; + return new ChannelDefinition(exch, tpc); + }, + + subscribe: function(exchange, topic, callback) { + var exch = arguments.length === 3 ? exchange : DEFAULT_EXCHANGE, + tpc = arguments.length === 3 ? topic : exchange, + callbk = arguments.length === 3 ? callback : topic; + var channel = this.channel(exch, tpc); + return channel.subscribe(callbk); + }, + + publish: function(exchange, topic, payload, envelopeOptions) { + var parsedArgs = parsePublishArgs([].slice.call(arguments,0)); + var channel = this.channel(parsedArgs.envelope.exchange, parsedArgs.envelope.topic); + channel.publish(parsedArgs.payload, parsedArgs.envelope); + }, + + addWireTap: function(callback) { + this.configuration.bus.addWireTap(callback); + } + }; + + return postal; +}; + +if( window.define ) { + define(['underscore'], function(_) { + var postal = factory(_); + window.postal = postal; + return postal; + }); +} +else { + window.postal = factory(); +} \ No newline at end of file diff --git a/ext/qunit-1.3.0pre.js b/ext/qunit-1.3.0pre.js new file mode 100644 index 0000000..127775b --- /dev/null +++ b/ext/qunit-1.3.0pre.js @@ -0,0 +1,1600 @@ +/** + * QUnit v1.3.0pre - A JavaScript Unit Testing Framework + * + * http://docs.jquery.com/QUnit + * + * Copyright (c) 2011 John Resig, Jörn Zaefferer + * Dual licensed under the MIT (MIT-LICENSE.txt) + * or GPL (GPL-LICENSE.txt) licenses. + * Pulled Live from Git Sat Feb 11 19:20:01 UTC 2012 + * Last Commit: 0712230bb203c262211649b32bd712ec7df5f857 + */ + +(function(window) { + + var defined = { + setTimeout: typeof window.setTimeout !== "undefined", + sessionStorage: (function() { + try { + return !!sessionStorage.getItem; + } catch(e) { + return false; + } + })() + }; + + var testId = 0, + toString = Object.prototype.toString, + hasOwn = Object.prototype.hasOwnProperty; + + var Test = function(name, testName, expected, testEnvironmentArg, async, callback) { + this.name = name; + this.testName = testName; + this.expected = expected; + this.testEnvironmentArg = testEnvironmentArg; + this.async = async; + this.callback = callback; + this.assertions = []; + }; + Test.prototype = { + init: function() { + var tests = id("qunit-tests"); + if (tests) { + var b = document.createElement("strong"); + b.innerHTML = "Running " + this.name; + var li = document.createElement("li"); + li.appendChild( b ); + li.className = "running"; + li.id = this.id = "test-output" + testId++; + tests.appendChild( li ); + } + }, + setup: function() { + if (this.module != config.previousModule) { + if ( config.previousModule ) { + runLoggingCallbacks('moduleDone', QUnit, { + name: config.previousModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + } ); + } + config.previousModule = this.module; + config.moduleStats = { all: 0, bad: 0 }; + runLoggingCallbacks( 'moduleStart', QUnit, { + name: this.module + } ); + } + + config.current = this; + this.testEnvironment = extend({ + setup: function() {}, + teardown: function() {} + }, this.moduleTestEnvironment); + if (this.testEnvironmentArg) { + extend(this.testEnvironment, this.testEnvironmentArg); + } + + runLoggingCallbacks( 'testStart', QUnit, { + name: this.testName, + module: this.module + }); + + // allow utility functions to access the current test environment + // TODO why?? + QUnit.current_testEnvironment = this.testEnvironment; + + try { + if ( !config.pollution ) { + saveGlobal(); + } + + this.testEnvironment.setup.call(this.testEnvironment); + } catch(e) { + QUnit.ok( false, "Setup failed on " + this.testName + ": " + e.message ); + } + }, + run: function() { + config.current = this; + if ( this.async ) { + QUnit.stop(); + } + + if ( config.notrycatch ) { + this.callback.call(this.testEnvironment); + return; + } + try { + this.callback.call(this.testEnvironment); + } catch(e) { + fail("Test " + this.testName + " died, exception and test follows", e, this.callback); + QUnit.ok( false, "Died on test #" + (this.assertions.length + 1) + ": " + e.message + " - " + QUnit.jsDump.parse(e) ); + // else next test will carry the responsibility + saveGlobal(); + + // Restart the tests if they're blocking + if ( config.blocking ) { + QUnit.start(); + } + } + }, + teardown: function() { + config.current = this; + try { + this.testEnvironment.teardown.call(this.testEnvironment); + checkPollution(); + } catch(e) { + QUnit.ok( false, "Teardown failed on " + this.testName + ": " + e.message ); + } + }, + finish: function() { + config.current = this; + if ( this.expected != null && this.expected != this.assertions.length ) { + QUnit.ok( false, "Expected " + this.expected + " assertions, but " + this.assertions.length + " were run" ); + } + + var good = 0, bad = 0, + tests = id("qunit-tests"); + + config.stats.all += this.assertions.length; + config.moduleStats.all += this.assertions.length; + + if ( tests ) { + var ol = document.createElement("ol"); + + for ( var i = 0; i < this.assertions.length; i++ ) { + var assertion = this.assertions[i]; + + var li = document.createElement("li"); + li.className = assertion.result ? "pass" : "fail"; + li.innerHTML = assertion.message || (assertion.result ? "okay" : "failed"); + ol.appendChild( li ); + + if ( assertion.result ) { + good++; + } else { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + + // store result when possible + if ( QUnit.config.reorder && defined.sessionStorage ) { + if (bad) { + sessionStorage.setItem("qunit-" + this.module + "-" + this.testName, bad); + } else { + sessionStorage.removeItem("qunit-" + this.module + "-" + this.testName); + } + } + + if (bad == 0) { + ol.style.display = "none"; + } + + var b = document.createElement("strong"); + b.innerHTML = this.name + " (" + bad + ", " + good + ", " + this.assertions.length + ")"; + + var a = document.createElement("a"); + a.innerHTML = "Rerun"; + a.href = QUnit.url({ filter: getText([b]).replace(/\([^)]+\)$/, "").replace(/(^\s*|\s*$)/g, "") }); + + addEvent(b, "click", function() { + var next = b.nextSibling.nextSibling, + display = next.style.display; + next.style.display = display === "none" ? "block" : "none"; + }); + + addEvent(b, "dblclick", function(e) { + var target = e && e.target ? e.target : window.event.srcElement; + if ( target.nodeName.toLowerCase() == "span" || target.nodeName.toLowerCase() == "b" ) { + target = target.parentNode; + } + if ( window.location && target.nodeName.toLowerCase() === "strong" ) { + window.location = QUnit.url({ filter: getText([target]).replace(/\([^)]+\)$/, "").replace(/(^\s*|\s*$)/g, "") }); + } + }); + + var li = id(this.id); + li.className = bad ? "fail" : "pass"; + li.removeChild( li.firstChild ); + li.appendChild( b ); + li.appendChild( a ); + li.appendChild( ol ); + + } else { + for ( var i = 0; i < this.assertions.length; i++ ) { + if ( !this.assertions[i].result ) { + bad++; + config.stats.bad++; + config.moduleStats.bad++; + } + } + } + + try { + QUnit.reset(); + } catch(e) { + fail("reset() failed, following Test " + this.testName + ", exception and reset fn follows", e, QUnit.reset); + } + + runLoggingCallbacks( 'testDone', QUnit, { + name: this.testName, + module: this.module, + failed: bad, + passed: this.assertions.length - bad, + total: this.assertions.length + } ); + }, + + queue: function() { + var test = this; + synchronize(function() { + test.init(); + }); + function run() { + // each of these can by async + synchronize(function() { + test.setup(); + }); + synchronize(function() { + test.run(); + }); + synchronize(function() { + test.teardown(); + }); + synchronize(function() { + test.finish(); + }); + } + // defer when previous test run passed, if storage is available + var bad = QUnit.config.reorder && defined.sessionStorage && +sessionStorage.getItem("qunit-" + this.module + "-" + this.testName); + if (bad) { + run(); + } else { + synchronize(run, true); + }; + } + + }; + + var QUnit = { + + // call on start of module test to prepend name to all tests + module: function(name, testEnvironment) { + config.currentModule = name; + config.currentModuleTestEnviroment = testEnvironment; + }, + + asyncTest: function(testName, expected, callback) { + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + + QUnit.test(testName, expected, callback, true); + }, + + test: function(testName, expected, callback, async) { + var name = '' + escapeInnerText(testName) + '', testEnvironmentArg; + + if ( arguments.length === 2 ) { + callback = expected; + expected = null; + } + // is 2nd argument a testEnvironment? + if ( expected && typeof expected === 'object') { + testEnvironmentArg = expected; + expected = null; + } + + if ( config.currentModule ) { + name = '' + config.currentModule + ": " + name; + } + + if ( !validTest(config.currentModule + ": " + testName) ) { + return; + } + + var test = new Test(name, testName, expected, testEnvironmentArg, async, callback); + test.module = config.currentModule; + test.moduleTestEnvironment = config.currentModuleTestEnviroment; + test.queue(); + }, + + /** + * Specify the number of expected assertions to gurantee that failed test (no assertions are run at all) don't slip through. + */ + expect: function(asserts) { + config.current.expected = asserts; + }, + + /** + * Asserts true. + * @example ok( "asdfasdf".length > 5, "There must be at least 5 chars" ); + */ + ok: function(a, msg) { + a = !!a; + var details = { + result: a, + message: msg + }; + msg = escapeInnerText(msg); + runLoggingCallbacks( 'log', QUnit, details ); + config.current.assertions.push({ + result: a, + message: msg + }); + }, + + /** + * Checks that the first two arguments are equal, with an optional message. + * Prints out both actual and expected values. + * + * Prefered to ok( actual == expected, message ) + * + * @example equal( format("Received {0} bytes.", 2), "Received 2 bytes." ); + * + * @param Object actual + * @param Object expected + * @param String message (optional) + */ + equal: function(actual, expected, message) { + QUnit.push(expected == actual, actual, expected, message); + }, + + notEqual: function(actual, expected, message) { + QUnit.push(expected != actual, actual, expected, message); + }, + + deepEqual: function(actual, expected, message) { + QUnit.push(QUnit.equiv(actual, expected), actual, expected, message); + }, + + notDeepEqual: function(actual, expected, message) { + QUnit.push(!QUnit.equiv(actual, expected), actual, expected, message); + }, + + strictEqual: function(actual, expected, message) { + QUnit.push(expected === actual, actual, expected, message); + }, + + notStrictEqual: function(actual, expected, message) { + QUnit.push(expected !== actual, actual, expected, message); + }, + + raises: function(block, expected, message) { + var actual, ok = false; + + if (typeof expected === 'string') { + message = expected; + expected = null; + } + + try { + block(); + } catch (e) { + actual = e; + } + + if (actual) { + // we don't want to validate thrown error + if (!expected) { + ok = true; + // expected is a regexp + } else if (QUnit.objectType(expected) === "regexp") { + ok = expected.test(actual); + // expected is a constructor + } else if (actual instanceof expected) { + ok = true; + // expected is a validation function which returns true is validation passed + } else if (expected.call({}, actual) === true) { + ok = true; + } + } + + QUnit.ok(ok, message); + }, + + start: function(count) { + config.semaphore -= count || 1; + if (config.semaphore > 0) { + // don't start until equal number of stop-calls + return; + } + if (config.semaphore < 0) { + // ignore if start is called more often then stop + config.semaphore = 0; + } + // A slight delay, to avoid any current callbacks + if ( defined.setTimeout ) { + window.setTimeout(function() { + if (config.semaphore > 0) { + return; + } + if ( config.timeout ) { + clearTimeout(config.timeout); + } + + config.blocking = false; + process(true); + }, 13); + } else { + config.blocking = false; + process(true); + } + }, + + stop: function(count) { + config.semaphore += count || 1; + config.blocking = true; + + if ( config.testTimeout && defined.setTimeout ) { + clearTimeout(config.timeout); + config.timeout = window.setTimeout(function() { + QUnit.ok( false, "Test timed out" ); + config.semaphore = 1; + QUnit.start(); + }, config.testTimeout); + } + } + }; + +//We want access to the constructor's prototype + (function() { + function F(){}; + F.prototype = QUnit; + QUnit = new F(); + //Make F QUnit's constructor so that we can add to the prototype later + QUnit.constructor = F; + })(); + +// Backwards compatibility, deprecated + QUnit.equals = QUnit.equal; + QUnit.same = QUnit.deepEqual; + +// Maintain internal state + var config = { + // The queue of tests to run + queue: [], + + // block until document ready + blocking: true, + + // when enabled, show only failing tests + // gets persisted through sessionStorage and can be changed in UI via checkbox + hidepassed: false, + + // by default, run previously failed tests first + // very useful in combination with "Hide passed tests" checked + reorder: true, + + // by default, modify document.title when suite is done + altertitle: true, + + urlConfig: ['noglobals', 'notrycatch'], + + //logging callback queues + begin: [], + done: [], + log: [], + testStart: [], + testDone: [], + moduleStart: [], + moduleDone: [] + }; + +// Load paramaters + (function() { + var location = window.location || { search: "", protocol: "file:" }, + params = location.search.slice( 1 ).split( "&" ), + length = params.length, + urlParams = {}, + current; + + if ( params[ 0 ] ) { + for ( var i = 0; i < length; i++ ) { + current = params[ i ].split( "=" ); + current[ 0 ] = decodeURIComponent( current[ 0 ] ); + // allow just a key to turn on a flag, e.g., test.html?noglobals + current[ 1 ] = current[ 1 ] ? decodeURIComponent( current[ 1 ] ) : true; + urlParams[ current[ 0 ] ] = current[ 1 ]; + } + } + + QUnit.urlParams = urlParams; + config.filter = urlParams.filter; + + // Figure out if we're running the tests from a server or not + QUnit.isLocal = !!(location.protocol === 'file:'); + })(); + +// Expose the API as global variables, unless an 'exports' +// object exists, in that case we assume we're in CommonJS + if ( typeof exports === "undefined" || typeof require === "undefined" ) { + extend(window, QUnit); + window.QUnit = QUnit; + } else { + extend(exports, QUnit); + exports.QUnit = QUnit; + } + +// define these after exposing globals to keep them in these QUnit namespace only + extend(QUnit, { + config: config, + + // Initialize the configuration options + init: function() { + extend(config, { + stats: { all: 0, bad: 0 }, + moduleStats: { all: 0, bad: 0 }, + started: +new Date, + updateRate: 1000, + blocking: false, + autostart: true, + autorun: false, + filter: "", + queue: [], + semaphore: 0 + }); + + var tests = id( "qunit-tests" ), + banner = id( "qunit-banner" ), + result = id( "qunit-testresult" ); + + if ( tests ) { + tests.innerHTML = ""; + } + + if ( banner ) { + banner.className = ""; + } + + if ( result ) { + result.parentNode.removeChild( result ); + } + + if ( tests ) { + result = document.createElement( "p" ); + result.id = "qunit-testresult"; + result.className = "result"; + tests.parentNode.insertBefore( result, tests ); + result.innerHTML = 'Running...
     '; + } + }, + + /** + * Resets the test setup. Useful for tests that modify the DOM. + * + * If jQuery is available, uses jQuery's html(), otherwise just innerHTML. + */ + reset: function() { + if ( window.jQuery ) { + jQuery( "#qunit-fixture" ).html( config.fixture ); + } else { + var main = id( 'qunit-fixture' ); + if ( main ) { + main.innerHTML = config.fixture; + } + } + }, + + /** + * Trigger an event on an element. + * + * @example triggerEvent( document.body, "click" ); + * + * @param DOMElement elem + * @param String type + */ + triggerEvent: function( elem, type, event ) { + if ( document.createEvent ) { + event = document.createEvent("MouseEvents"); + event.initMouseEvent(type, true, true, elem.ownerDocument.defaultView, + 0, 0, 0, 0, 0, false, false, false, false, 0, null); + elem.dispatchEvent( event ); + + } else if ( elem.fireEvent ) { + elem.fireEvent("on"+type); + } + }, + + // Safe object type checking + is: function( type, obj ) { + return QUnit.objectType( obj ) == type; + }, + + objectType: function( obj ) { + if (typeof obj === "undefined") { + return "undefined"; + + // consider: typeof null === object + } + if (obj === null) { + return "null"; + } + + var type = toString.call( obj ).match(/^\[object\s(.*)\]$/)[1] || ''; + + switch (type) { + case 'Number': + if (isNaN(obj)) { + return "nan"; + } else { + return "number"; + } + case 'String': + case 'Boolean': + case 'Array': + case 'Date': + case 'RegExp': + case 'Function': + return type.toLowerCase(); + } + if (typeof obj === "object") { + return "object"; + } + return undefined; + }, + + push: function(result, actual, expected, message) { + var details = { + result: result, + message: message, + actual: actual, + expected: expected + }; + + message = escapeInnerText(message) || (result ? "okay" : "failed"); + message = '' + message + ""; + expected = escapeInnerText(QUnit.jsDump.parse(expected)); + actual = escapeInnerText(QUnit.jsDump.parse(actual)); + var output = message + ''; + if (actual != expected) { + output += ''; + output += ''; + } + if (!result) { + var source = sourceFromStacktrace(); + if (source) { + details.source = source; + output += ''; + } + } + output += "
    Expected:
    ' + expected + '
    Result:
    ' + actual + '
    Diff:
    ' + QUnit.diff(expected, actual) +'
    Source:
    ' + escapeInnerText(source) + '
    "; + + runLoggingCallbacks( 'log', QUnit, details ); + + config.current.assertions.push({ + result: !!result, + message: output + }); + }, + + url: function( params ) { + params = extend( extend( {}, QUnit.urlParams ), params ); + var querystring = "?", + key; + for ( key in params ) { + if ( !hasOwn.call( params, key ) ) { + continue; + } + querystring += encodeURIComponent( key ) + "=" + + encodeURIComponent( params[ key ] ) + "&"; + } + return window.location.pathname + querystring.slice( 0, -1 ); + }, + + extend: extend, + id: id, + addEvent: addEvent + }); + +//QUnit.constructor is set to the empty F() above so that we can add to it's prototype later +//Doing this allows us to tell if the following methods have been overwritten on the actual +//QUnit object, which is a deprecated way of using the callbacks. + extend(QUnit.constructor.prototype, { + // Logging callbacks; all receive a single argument with the listed properties + // run test/logs.html for any related changes + begin: registerLoggingCallback('begin'), + // done: { failed, passed, total, runtime } + done: registerLoggingCallback('done'), + // log: { result, actual, expected, message } + log: registerLoggingCallback('log'), + // testStart: { name } + testStart: registerLoggingCallback('testStart'), + // testDone: { name, failed, passed, total } + testDone: registerLoggingCallback('testDone'), + // moduleStart: { name } + moduleStart: registerLoggingCallback('moduleStart'), + // moduleDone: { name, failed, passed, total } + moduleDone: registerLoggingCallback('moduleDone') + }); + + if ( typeof document === "undefined" || document.readyState === "complete" ) { + config.autorun = true; + } + + QUnit.load = function() { + runLoggingCallbacks( 'begin', QUnit, {} ); + + // Initialize the config, saving the execution queue + var oldconfig = extend({}, config); + QUnit.init(); + extend(config, oldconfig); + + config.blocking = false; + + var urlConfigHtml = '', len = config.urlConfig.length; + for ( var i = 0, val; i < len, val = config.urlConfig[i]; i++ ) { + config[val] = QUnit.urlParams[val]; + urlConfigHtml += ''; + } + + var userAgent = id("qunit-userAgent"); + if ( userAgent ) { + userAgent.innerHTML = navigator.userAgent; + } + var banner = id("qunit-header"); + if ( banner ) { + banner.innerHTML = ' ' + banner.innerHTML + ' ' + urlConfigHtml; + addEvent( banner, "change", function( event ) { + var params = {}; + params[ event.target.name ] = event.target.checked ? true : undefined; + window.location = QUnit.url( params ); + }); + } + + var toolbar = id("qunit-testrunner-toolbar"); + if ( toolbar ) { + var filter = document.createElement("input"); + filter.type = "checkbox"; + filter.id = "qunit-filter-pass"; + addEvent( filter, "click", function() { + var ol = document.getElementById("qunit-tests"); + if ( filter.checked ) { + ol.className = ol.className + " hidepass"; + } else { + var tmp = " " + ol.className.replace( /[\n\t\r]/g, " " ) + " "; + ol.className = tmp.replace(/ hidepass /, " "); + } + if ( defined.sessionStorage ) { + if (filter.checked) { + sessionStorage.setItem("qunit-filter-passed-tests", "true"); + } else { + sessionStorage.removeItem("qunit-filter-passed-tests"); + } + } + }); + if ( config.hidepassed || defined.sessionStorage && sessionStorage.getItem("qunit-filter-passed-tests") ) { + filter.checked = true; + var ol = document.getElementById("qunit-tests"); + ol.className = ol.className + " hidepass"; + } + toolbar.appendChild( filter ); + + var label = document.createElement("label"); + label.setAttribute("for", "qunit-filter-pass"); + label.innerHTML = "Hide passed tests"; + toolbar.appendChild( label ); + } + + var main = id('qunit-fixture'); + if ( main ) { + config.fixture = main.innerHTML; + } + + if (config.autostart) { + QUnit.start(); + } + }; + + addEvent(window, "load", QUnit.load); + +// addEvent(window, "error") gives us a useless event object + window.onerror = function( message, file, line ) { + if ( QUnit.config.current ) { + ok( false, message + ", " + file + ":" + line ); + } else { + test( "global failure", function() { + ok( false, message + ", " + file + ":" + line ); + }); + } + }; + + function done() { + config.autorun = true; + + // Log the last module results + if ( config.currentModule ) { + runLoggingCallbacks( 'moduleDone', QUnit, { + name: config.currentModule, + failed: config.moduleStats.bad, + passed: config.moduleStats.all - config.moduleStats.bad, + total: config.moduleStats.all + } ); + } + + var banner = id("qunit-banner"), + tests = id("qunit-tests"), + runtime = +new Date - config.started, + passed = config.stats.all - config.stats.bad, + html = [ + 'Tests completed in ', + runtime, + ' milliseconds.
    ', + '', + passed, + ' tests of ', + config.stats.all, + ' passed, ', + config.stats.bad, + ' failed.' + ].join(''); + + if ( banner ) { + banner.className = (config.stats.bad ? "qunit-fail" : "qunit-pass"); + } + + if ( tests ) { + id( "qunit-testresult" ).innerHTML = html; + } + + if ( config.altertitle && typeof document !== "undefined" && document.title ) { + // show ✖ for good, ✔ for bad suite result in title + // use escape sequences in case file gets loaded with non-utf-8-charset + document.title = [ + (config.stats.bad ? "\u2716" : "\u2714"), + document.title.replace(/^[\u2714\u2716] /i, "") + ].join(" "); + } + + runLoggingCallbacks( 'done', QUnit, { + failed: config.stats.bad, + passed: passed, + total: config.stats.all, + runtime: runtime + } ); + } + + function validTest( name ) { + var filter = config.filter, + run = false; + + if ( !filter ) { + return true; + } + + var not = filter.charAt( 0 ) === "!"; + if ( not ) { + filter = filter.slice( 1 ); + } + + if ( name.indexOf( filter ) !== -1 ) { + return !not; + } + + if ( not ) { + run = true; + } + + return run; + } + +// so far supports only Firefox, Chrome and Opera (buggy) +// could be extended in the future to use something like https://github.com/csnover/TraceKit + function sourceFromStacktrace() { + try { + throw new Error(); + } catch ( e ) { + if (e.stacktrace) { + // Opera + return e.stacktrace.split("\n")[6]; + } else if (e.stack) { + // Firefox, Chrome + return e.stack.split("\n")[4]; + } else if (e.sourceURL) { + // Safari, PhantomJS + // TODO sourceURL points at the 'throw new Error' line above, useless + //return e.sourceURL + ":" + e.line; + } + } + } + + function escapeInnerText(s) { + if (!s) { + return ""; + } + s = s + ""; + return s.replace(/[\&<>]/g, function(s) { + switch(s) { + case "&": return "&"; + case "<": return "<"; + case ">": return ">"; + default: return s; + } + }); + } + + function synchronize( callback, last ) { + config.queue.push( callback ); + + if ( config.autorun && !config.blocking ) { + process(last); + } + } + + function process( last ) { + var start = new Date().getTime(); + config.depth = config.depth ? config.depth + 1 : 1; + + while ( config.queue.length && !config.blocking ) { + if ( !defined.setTimeout || config.updateRate <= 0 || ( ( new Date().getTime() - start ) < config.updateRate ) ) { + config.queue.shift()(); + } else { + window.setTimeout( function(){ + process( last ); + }, 13 ); + break; + } + } + config.depth--; + if ( last && !config.blocking && !config.queue.length && config.depth === 0 ) { + done(); + } + } + + function saveGlobal() { + config.pollution = []; + + if ( config.noglobals ) { + for ( var key in window ) { + if ( !hasOwn.call( window, key ) ) { + continue; + } + config.pollution.push( key ); + } + } + } + + function checkPollution( name ) { + var old = config.pollution; + saveGlobal(); + + var newGlobals = diff( config.pollution, old ); + if ( newGlobals.length > 0 ) { + ok( false, "Introduced global variable(s): " + newGlobals.join(", ") ); + } + + var deletedGlobals = diff( old, config.pollution ); + if ( deletedGlobals.length > 0 ) { + ok( false, "Deleted global variable(s): " + deletedGlobals.join(", ") ); + } + } + +// returns a new Array with the elements that are in a but not in b + function diff( a, b ) { + var result = a.slice(); + for ( var i = 0; i < result.length; i++ ) { + for ( var j = 0; j < b.length; j++ ) { + if ( result[i] === b[j] ) { + result.splice(i, 1); + i--; + break; + } + } + } + return result; + } + + function fail(message, exception, callback) { + if ( typeof console !== "undefined" && console.error && console.warn ) { + console.error(message); + console.error(exception); + console.error(exception.stack); + console.warn(callback.toString()); + + } else if ( window.opera && opera.postError ) { + opera.postError(message, exception, callback.toString); + } + } + + function extend(a, b) { + for ( var prop in b ) { + if ( b[prop] === undefined ) { + delete a[prop]; + + // Avoid "Member not found" error in IE8 caused by setting window.constructor + } else if ( prop !== "constructor" || a !== window ) { + a[prop] = b[prop]; + } + } + + return a; + } + + function addEvent(elem, type, fn) { + if ( elem.addEventListener ) { + elem.addEventListener( type, fn, false ); + } else if ( elem.attachEvent ) { + elem.attachEvent( "on" + type, fn ); + } else { + fn(); + } + } + + function id(name) { + return !!(typeof document !== "undefined" && document && document.getElementById) && + document.getElementById( name ); + } + + function registerLoggingCallback(key){ + return function(callback){ + config[key].push( callback ); + }; + } + +// Supports deprecated method of completely overwriting logging callbacks + function runLoggingCallbacks(key, scope, args) { + //debugger; + var callbacks; + if ( QUnit.hasOwnProperty(key) ) { + QUnit[key].call(scope, args); + } else { + callbacks = config[key]; + for( var i = 0; i < callbacks.length; i++ ) { + callbacks[i].call( scope, args ); + } + } + } + +// Test for equality any JavaScript type. +// Author: Philippe Rathé + QUnit.equiv = function () { + + var innerEquiv; // the real equiv function + var callers = []; // stack to decide between skip/abort functions + var parents = []; // stack to avoiding loops from circular referencing + + // Call the o related callback with the given arguments. + function bindCallbacks(o, callbacks, args) { + var prop = QUnit.objectType(o); + if (prop) { + if (QUnit.objectType(callbacks[prop]) === "function") { + return callbacks[prop].apply(callbacks, args); + } else { + return callbacks[prop]; // or undefined + } + } + } + + var getProto = Object.getPrototypeOf || function (obj) { + return obj.__proto__; + }; + + var callbacks = function () { + + // for string, boolean, number and null + function useStrictEquality(b, a) { + if (b instanceof a.constructor || a instanceof b.constructor) { + // to catch short annotaion VS 'new' annotation of a + // declaration + // e.g. var i = 1; + // var j = new Number(1); + return a == b; + } else { + return a === b; + } + } + + return { + "string" : useStrictEquality, + "boolean" : useStrictEquality, + "number" : useStrictEquality, + "null" : useStrictEquality, + "undefined" : useStrictEquality, + + "nan" : function(b) { + return isNaN(b); + }, + + "date" : function(b, a) { + return QUnit.objectType(b) === "date" + && a.valueOf() === b.valueOf(); + }, + + "regexp" : function(b, a) { + return QUnit.objectType(b) === "regexp" + && a.source === b.source && // the regex itself + a.global === b.global && // and its modifers + // (gmi) ... + a.ignoreCase === b.ignoreCase + && a.multiline === b.multiline; + }, + + // - skip when the property is a method of an instance (OOP) + // - abort otherwise, + // initial === would have catch identical references anyway + "function" : function() { + var caller = callers[callers.length - 1]; + return caller !== Object && typeof caller !== "undefined"; + }, + + "array" : function(b, a) { + var i, j, loop; + var len; + + // b could be an object literal here + if (!(QUnit.objectType(b) === "array")) { + return false; + } + + len = a.length; + if (len !== b.length) { // safe and faster + return false; + } + + // track reference to avoid circular references + parents.push(a); + for (i = 0; i < len; i++) { + loop = false; + for (j = 0; j < parents.length; j++) { + if (parents[j] === a[i]) { + loop = true;// dont rewalk array + } + } + if (!loop && !innerEquiv(a[i], b[i])) { + parents.pop(); + return false; + } + } + parents.pop(); + return true; + }, + + "object" : function(b, a) { + var i, j, loop; + var eq = true; // unless we can proove it + var aProperties = [], bProperties = []; // collection of + // strings + + // comparing constructors is more strict than using + // instanceof + if (a.constructor !== b.constructor) { + // Allow objects with no prototype to be equivalent to + // objects with Object as their constructor. + if (!((getProto(a) === null && getProto(b) === Object.prototype) || + (getProto(b) === null && getProto(a) === Object.prototype))) + { + return false; + } + } + + // stack constructor before traversing properties + callers.push(a.constructor); + // track reference to avoid circular references + parents.push(a); + + for (i in a) { // be strict: don't ensures hasOwnProperty + // and go deep + loop = false; + for (j = 0; j < parents.length; j++) { + if (parents[j] === a[i]) + loop = true; // don't go down the same path + // twice + } + aProperties.push(i); // collect a's properties + + if (!loop && !innerEquiv(a[i], b[i])) { + eq = false; + break; + } + } + + callers.pop(); // unstack, we are done + parents.pop(); + + for (i in b) { + bProperties.push(i); // collect b's properties + } + + // Ensures identical properties name + return eq + && innerEquiv(aProperties.sort(), bProperties + .sort()); + } + }; + }(); + + innerEquiv = function() { // can take multiple arguments + var args = Array.prototype.slice.apply(arguments); + if (args.length < 2) { + return true; // end transition + } + + return (function(a, b) { + if (a === b) { + return true; // catch the most you can + } else if (a === null || b === null || typeof a === "undefined" + || typeof b === "undefined" + || QUnit.objectType(a) !== QUnit.objectType(b)) { + return false; // don't lose time with error prone cases + } else { + return bindCallbacks(a, callbacks, [ b, a ]); + } + + // apply transition with (1..n) arguments + })(args[0], args[1]) + && arguments.callee.apply(this, args.splice(1, + args.length - 1)); + }; + + return innerEquiv; + + }(); + + /** + * jsDump Copyright (c) 2008 Ariel Flesler - aflesler(at)gmail(dot)com | + * http://flesler.blogspot.com Licensed under BSD + * (http://www.opensource.org/licenses/bsd-license.php) Date: 5/15/2008 + * + * @projectDescription Advanced and extensible data dumping for Javascript. + * @version 1.0.0 + * @author Ariel Flesler + * @link {http://flesler.blogspot.com/2008/05/jsdump-pretty-dump-of-any-javascript.html} + */ + QUnit.jsDump = (function() { + function quote( str ) { + return '"' + str.toString().replace(/"/g, '\\"') + '"'; + }; + function literal( o ) { + return o + ''; + }; + function join( pre, arr, post ) { + var s = jsDump.separator(), + base = jsDump.indent(), + inner = jsDump.indent(1); + if ( arr.join ) + arr = arr.join( ',' + s + inner ); + if ( !arr ) + return pre + post; + return [ pre, inner + arr, base + post ].join(s); + }; + function array( arr, stack ) { + var i = arr.length, ret = Array(i); + this.up(); + while ( i-- ) + ret[i] = this.parse( arr[i] , undefined , stack); + this.down(); + return join( '[', ret, ']' ); + }; + + var reName = /^function (\w+)/; + + var jsDump = { + parse:function( obj, type, stack ) { //type is used mostly internally, you can fix a (custom)type in advance + stack = stack || [ ]; + var parser = this.parsers[ type || this.typeOf(obj) ]; + type = typeof parser; + var inStack = inArray(obj, stack); + if (inStack != -1) { + return 'recursion('+(inStack - stack.length)+')'; + } + //else + if (type == 'function') { + stack.push(obj); + var res = parser.call( this, obj, stack ); + stack.pop(); + return res; + } + // else + return (type == 'string') ? parser : this.parsers.error; + }, + typeOf:function( obj ) { + var type; + if ( obj === null ) { + type = "null"; + } else if (typeof obj === "undefined") { + type = "undefined"; + } else if (QUnit.is("RegExp", obj)) { + type = "regexp"; + } else if (QUnit.is("Date", obj)) { + type = "date"; + } else if (QUnit.is("Function", obj)) { + type = "function"; + } else if (typeof obj.setInterval !== undefined && typeof obj.document !== "undefined" && typeof obj.nodeType === "undefined") { + type = "window"; + } else if (obj.nodeType === 9) { + type = "document"; + } else if (obj.nodeType) { + type = "node"; + } else if ( + // native arrays + toString.call( obj ) === "[object Array]" || + // NodeList objects + ( typeof obj.length === "number" && typeof obj.item !== "undefined" && ( obj.length ? obj.item(0) === obj[0] : ( obj.item( 0 ) === null && typeof obj[0] === "undefined" ) ) ) + ) { + type = "array"; + } else { + type = typeof obj; + } + return type; + }, + separator:function() { + return this.multiline ? this.HTML ? '
    ' : '\n' : this.HTML ? ' ' : ' '; + }, + indent:function( extra ) {// extra can be a number, shortcut for increasing-calling-decreasing + if ( !this.multiline ) + return ''; + var chr = this.indentChar; + if ( this.HTML ) + chr = chr.replace(/\t/g,' ').replace(/ /g,' '); + return Array( this._depth_ + (extra||0) ).join(chr); + }, + up:function( a ) { + this._depth_ += a || 1; + }, + down:function( a ) { + this._depth_ -= a || 1; + }, + setParser:function( name, parser ) { + this.parsers[name] = parser; + }, + // The next 3 are exposed so you can use them + quote:quote, + literal:literal, + join:join, + // + _depth_: 1, + // This is the list of parsers, to modify them, use jsDump.setParser + parsers:{ + window: '[Window]', + document: '[Document]', + error:'[ERROR]', //when no parser is found, shouldn't happen + unknown: '[Unknown]', + 'null':'null', + 'undefined':'undefined', + 'function':function( fn ) { + var ret = 'function', + name = 'name' in fn ? fn.name : (reName.exec(fn)||[])[1];//functions never have name in IE + if ( name ) + ret += ' ' + name; + ret += '('; + + ret = [ ret, QUnit.jsDump.parse( fn, 'functionArgs' ), '){'].join(''); + return join( ret, QUnit.jsDump.parse(fn,'functionCode'), '}' ); + }, + array: array, + nodelist: array, + arguments: array, + object:function( map, stack ) { + var ret = [ ]; + QUnit.jsDump.up(); + for ( var key in map ) { + var val = map[key]; + ret.push( QUnit.jsDump.parse(key,'key') + ': ' + QUnit.jsDump.parse(val, undefined, stack)); + } + QUnit.jsDump.down(); + return join( '{', ret, '}' ); + }, + node:function( node ) { + var open = QUnit.jsDump.HTML ? '<' : '<', + close = QUnit.jsDump.HTML ? '>' : '>'; + + var tag = node.nodeName.toLowerCase(), + ret = open + tag; + + for ( var a in QUnit.jsDump.DOMAttrs ) { + var val = node[QUnit.jsDump.DOMAttrs[a]]; + if ( val ) + ret += ' ' + a + '=' + QUnit.jsDump.parse( val, 'attribute' ); + } + return ret + close + open + '/' + tag + close; + }, + functionArgs:function( fn ) {//function calls it internally, it's the arguments part of the function + var l = fn.length; + if ( !l ) return ''; + + var args = Array(l); + while ( l-- ) + args[l] = String.fromCharCode(97+l);//97 is 'a' + return ' ' + args.join(', ') + ' '; + }, + key:quote, //object calls it internally, the key part of an item in a map + functionCode:'[code]', //function calls it internally, it's the content of the function + attribute:quote, //node calls it internally, it's an html attribute value + string:quote, + date:quote, + regexp:literal, //regex + number:literal, + 'boolean':literal + }, + DOMAttrs:{//attributes to dump from nodes, name=>realName + id:'id', + name:'name', + 'class':'className' + }, + HTML:false,//if true, entities are escaped ( <, >, \t, space and \n ) + indentChar:' ',//indentation unit + multiline:true //if true, items in a collection, are separated by a \n, else just a space. + }; + + return jsDump; + })(); + +// from Sizzle.js + function getText( elems ) { + var ret = "", elem; + + for ( var i = 0; elems[i]; i++ ) { + elem = elems[i]; + + // Get the text from text nodes and CDATA nodes + if ( elem.nodeType === 3 || elem.nodeType === 4 ) { + ret += elem.nodeValue; + + // Traverse everything else, except comment nodes + } else if ( elem.nodeType !== 8 ) { + ret += getText( elem.childNodes ); + } + } + + return ret; + }; + +//from jquery.js + function inArray( elem, array ) { + if ( array.indexOf ) { + return array.indexOf( elem ); + } + + for ( var i = 0, length = array.length; i < length; i++ ) { + if ( array[ i ] === elem ) { + return i; + } + } + + return -1; + } + + /* + * Javascript Diff Algorithm + * By John Resig (http://ejohn.org/) + * Modified by Chu Alan "sprite" + * + * Released under the MIT license. + * + * More Info: + * http://ejohn.org/projects/javascript-diff-algorithm/ + * + * Usage: QUnit.diff(expected, actual) + * + * QUnit.diff("the quick brown fox jumped over", "the quick fox jumps over") == "the quick brown fox jumped jumps over" + */ + QUnit.diff = (function() { + function diff(o, n) { + var ns = {}; + var os = {}; + + for (var i = 0; i < n.length; i++) { + if (ns[n[i]] == null) + ns[n[i]] = { + rows: [], + o: null + }; + ns[n[i]].rows.push(i); + } + + for (var i = 0; i < o.length; i++) { + if (os[o[i]] == null) + os[o[i]] = { + rows: [], + n: null + }; + os[o[i]].rows.push(i); + } + + for (var i in ns) { + if ( !hasOwn.call( ns, i ) ) { + continue; + } + if (ns[i].rows.length == 1 && typeof(os[i]) != "undefined" && os[i].rows.length == 1) { + n[ns[i].rows[0]] = { + text: n[ns[i].rows[0]], + row: os[i].rows[0] + }; + o[os[i].rows[0]] = { + text: o[os[i].rows[0]], + row: ns[i].rows[0] + }; + } + } + + for (var i = 0; i < n.length - 1; i++) { + if (n[i].text != null && n[i + 1].text == null && n[i].row + 1 < o.length && o[n[i].row + 1].text == null && + n[i + 1] == o[n[i].row + 1]) { + n[i + 1] = { + text: n[i + 1], + row: n[i].row + 1 + }; + o[n[i].row + 1] = { + text: o[n[i].row + 1], + row: i + 1 + }; + } + } + + for (var i = n.length - 1; i > 0; i--) { + if (n[i].text != null && n[i - 1].text == null && n[i].row > 0 && o[n[i].row - 1].text == null && + n[i - 1] == o[n[i].row - 1]) { + n[i - 1] = { + text: n[i - 1], + row: n[i].row - 1 + }; + o[n[i].row - 1] = { + text: o[n[i].row - 1], + row: i - 1 + }; + } + } + + return { + o: o, + n: n + }; + } + + return function(o, n) { + o = o.replace(/\s+$/, ''); + n = n.replace(/\s+$/, ''); + var out = diff(o == "" ? [] : o.split(/\s+/), n == "" ? [] : n.split(/\s+/)); + + var str = ""; + + var oSpace = o.match(/\s+/g); + if (oSpace == null) { + oSpace = [" "]; + } + else { + oSpace.push(" "); + } + var nSpace = n.match(/\s+/g); + if (nSpace == null) { + nSpace = [" "]; + } + else { + nSpace.push(" "); + } + + if (out.n.length == 0) { + for (var i = 0; i < out.o.length; i++) { + str += '' + out.o[i] + oSpace[i] + ""; + } + } + else { + if (out.n[0].text == null) { + for (n = 0; n < out.o.length && out.o[n].text == null; n++) { + str += '' + out.o[n] + oSpace[n] + ""; + } + } + + for (var i = 0; i < out.n.length; i++) { + if (out.n[i].text == null) { + str += '' + out.n[i] + nSpace[i] + ""; + } + else { + var pre = ""; + + for (n = out.n[i].row + 1; n < out.o.length && out.o[n].text == null; n++) { + pre += '' + out.o[n] + oSpace[n] + ""; + } + str += " " + out.n[i].text + nSpace[i] + pre; + } + } + } + + return str; + }; + })(); + +})(this); \ No newline at end of file diff --git a/ext/requirejs-1.0.5.js b/ext/requirejs-1.0.5.js new file mode 100644 index 0000000..7828e06 --- /dev/null +++ b/ext/requirejs-1.0.5.js @@ -0,0 +1,33 @@ +/* + RequireJS 1.0.5 Copyright (c) 2010-2012, The Dojo Foundation All Rights Reserved. + Available via the MIT or new BSD license. + see: http://github.com/jrburke/requirejs for details +*/ +var requirejs,require,define; +(function(){function J(a){return N.call(a)==="[object Function]"}function F(a){return N.call(a)==="[object Array]"}function Z(a,c,l){for(var j in c)if(!(j in K)&&(!(j in a)||l))a[j]=c[j];return d}function O(a,c,d){a=Error(c+"\nhttp://requirejs.org/docs/errors.html#"+a);if(d)a.originalError=d;return a}function $(a,c,d){var j,k,s;for(j=0;s=c[j];j++){s=typeof s==="string"?{name:s}:s;k=s.location;if(d&&(!k||k.indexOf("/")!==0&&k.indexOf(":")===-1))k=d+"/"+(k||s.name);a[s.name]={name:s.name,location:k|| +s.name,main:(s.main||"main").replace(ea,"").replace(aa,"")}}}function U(a,c){a.holdReady?a.holdReady(c):c?a.readyWait+=1:a.ready(!0)}function fa(a){function c(b,f){var g,m;if(b&&b.charAt(0)===".")if(f){q.pkgs[f]?f=[f]:(f=f.split("/"),f=f.slice(0,f.length-1));g=b=f.concat(b.split("/"));var a;for(m=0;a=g[m];m++)if(a===".")g.splice(m,1),m-=1;else if(a==="..")if(m===1&&(g[2]===".."||g[0]===".."))break;else m>0&&(g.splice(m-1,2),m-=2);m=q.pkgs[g=b[0]];b=b.join("/");m&&b===g+"/"+m.main&&(b=g)}else b.indexOf("./")=== +0&&(b=b.substring(2));return b}function l(b,f){var g=b?b.indexOf("!"):-1,m=null,a=f?f.name:null,h=b,e,d;g!==-1&&(m=b.substring(0,g),b=b.substring(g+1,b.length));m&&(m=c(m,a));b&&(m?e=(g=n[m])&&g.normalize?g.normalize(b,function(b){return c(b,a)}):c(b,a):(e=c(b,a),d=F[e],d||(d=i.nameToUrl(b,null,f),F[e]=d)));return{prefix:m,name:e,parentMap:f,url:d,originalName:h,fullName:m?m+"!"+(e||""):e}}function j(){var b=!0,f=q.priorityWait,g,a;if(f){for(a=0;g=f[a];a++)if(!r[g]){b=!1;break}b&&delete q.priorityWait}return b} +function k(b,f,g){return function(){var a=ga.call(arguments,0),c;if(g&&J(c=a[a.length-1]))c.__requireJsBuild=!0;a.push(f);return b.apply(null,a)}}function s(b,f,g){f=k(g||i.require,b,f);Z(f,{nameToUrl:k(i.nameToUrl,b),toUrl:k(i.toUrl,b),defined:k(i.requireDefined,b),specified:k(i.requireSpecified,b),isBrowser:d.isBrowser});return f}function p(b){var f,g,a,c=b.callback,h=b.map,e=h.fullName,ba=b.deps;a=b.listeners;if(c&&J(c)){if(q.catchError.define)try{g=d.execCb(e,b.callback,ba,n[e])}catch(j){f=j}else g= +d.execCb(e,b.callback,ba,n[e]);if(e)(c=b.cjsModule)&&c.exports!==void 0&&c.exports!==n[e]?g=n[e]=b.cjsModule.exports:g===void 0&&b.usingExports?g=n[e]:(n[e]=g,G[e]&&(S[e]=!0))}else e&&(g=n[e]=c,G[e]&&(S[e]=!0));if(w[b.id])delete w[b.id],b.isDone=!0,i.waitCount-=1,i.waitCount===0&&(I=[]);delete L[e];if(d.onResourceLoad&&!b.placeholder)d.onResourceLoad(i,h,b.depArray);if(f)return g=(e?l(e).url:"")||f.fileName||f.sourceURL,a=f.moduleTree,f=O("defineerror",'Error evaluating module "'+e+'" at location "'+ +g+'":\n'+f+"\nfileName:"+g+"\nlineNumber: "+(f.lineNumber||f.line),f),f.moduleName=e,f.moduleTree=a,d.onError(f);for(f=0;c=a[f];f++)c(g)}function t(b,f){return function(g){b.depDone[f]||(b.depDone[f]=!0,b.deps[f]=g,b.depCount-=1,b.depCount||p(b))}}function o(b,f){var g=f.map,a=g.fullName,c=g.name,h=M[b]||(M[b]=n[b]),e;if(!f.loading)f.loading=!0,e=function(b){f.callback=function(){return b};p(f);r[f.id]=!0;z()},e.fromText=function(b,f){var g=P;r[b]=!1;i.scriptCount+=1;i.fake[b]=!0;g&&(P=!1);d.exec(f); +g&&(P=!0);i.completeLoad(b)},a in n?e(n[a]):h.load(c,s(g.parentMap,!0,function(b,a){var c=[],e,m;for(e=0;m=b[e];e++)m=l(m,g.parentMap),b[e]=m.fullName,m.prefix||c.push(b[e]);f.moduleDeps=(f.moduleDeps||[]).concat(c);return i.require(b,a)}),e,q)}function x(b){w[b.id]||(w[b.id]=b,I.push(b),i.waitCount+=1)}function C(b){this.listeners.push(b)}function u(b,f){var g=b.fullName,a=b.prefix,c=a?M[a]||(M[a]=n[a]):null,h,e;g&&(h=L[g]);if(!h&&(e=!0,h={id:(a&&!c?N++ +"__p@:":"")+(g||"__r@"+N++),map:b,depCount:0, +depDone:[],depCallbacks:[],deps:[],listeners:[],add:C},A[h.id]=!0,g&&(!a||M[a])))L[g]=h;a&&!c?(g=l(a),a in n&&!n[a]&&(delete n[a],delete Q[g.url]),a=u(g,!0),a.add(function(){var f=l(b.originalName,b.parentMap),f=u(f,!0);h.placeholder=!0;f.add(function(b){h.callback=function(){return b};p(h)})})):e&&f&&(r[h.id]=!1,i.paused.push(h),x(h));return h}function B(b,f,a,c){var b=l(b,c),d=b.name,h=b.fullName,e=u(b),j=e.id,k=e.deps,o;if(h){if(h in n||r[j]===!0||h==="jquery"&&q.jQuery&&q.jQuery!==a().fn.jquery)return; +A[j]=!0;r[j]=!0;h==="jquery"&&a&&V(a())}e.depArray=f;e.callback=a;for(a=0;a0)){if(q.priorityWait)if(j())z();else return;for(h in r)if(!(h in K)&&(c=!0,!r[h]))if(b)a+=h+" ";else if(l=!0,h.indexOf("!")===-1){k=[];break}else(e=L[h]&&L[h].moduleDeps)&&k.push.apply(k,e);if(c||i.waitCount){if(b&&a)return b=O("timeout","Load timeout for modules: "+a),b.requireType="timeout",b.requireModules=a,d.onError(b);if(l&&k.length)for(a=0;h=w[k[a]];a++)if(h= +E(h,{})){y(h,{});break}if(!b&&(l||i.scriptCount)){if((H||ca)&&!W)W=setTimeout(function(){W=0;D()},50)}else{if(i.waitCount){for(a=0;h=I[a];a++)y(h,{});i.paused.length&&z();X<5&&(X+=1,D())}X=0;d.checkReadyState()}}}}var i,z,q={waitSeconds:7,baseUrl:"./",paths:{},pkgs:{},catchError:{}},R=[],A={require:!0,exports:!0,module:!0},F={},n={},r={},w={},I=[],Q={},N=0,L={},M={},G={},S={},Y=0;V=function(b){if(!i.jQuery&&(b=b||(typeof jQuery!=="undefined"?jQuery:null))&&!(q.jQuery&&b.fn.jquery!==q.jQuery)&&("holdReady"in +b||"readyWait"in b))if(i.jQuery=b,v(["jquery",[],function(){return jQuery}]),i.scriptCount)U(b,!0),i.jQueryIncremented=!0};z=function(){var b,a,c,l,k,h;i.takeGlobalQueue();Y+=1;if(i.scriptCount<=0)i.scriptCount=0;for(;R.length;)if(b=R.shift(),b[0]===null)return d.onError(O("mismatch","Mismatched anonymous define() module: "+b[b.length-1]));else v(b);if(!q.priorityWait||j())for(;i.paused.length;){k=i.paused;i.pausedCount+=k.length;i.paused=[];for(l=0;b=k[l];l++)a=b.map,c=a.url,h=a.fullName,a.prefix? +o(a.prefix,b):!Q[c]&&!r[h]&&(d.load(i,h,c),c.indexOf("empty:")!==0&&(Q[c]=!0));i.startTime=(new Date).getTime();i.pausedCount-=k.length}Y===1&&D();Y-=1};i={contextName:a,config:q,defQueue:R,waiting:w,waitCount:0,specified:A,loaded:r,urlMap:F,urlFetched:Q,scriptCount:0,defined:n,paused:[],pausedCount:0,plugins:M,needFullExec:G,fake:{},fullExec:S,managerCallbacks:L,makeModuleMap:l,normalize:c,configure:function(b){var a,c,d;b.baseUrl&&b.baseUrl.charAt(b.baseUrl.length-1)!=="/"&&(b.baseUrl+="/");a=q.paths; +d=q.pkgs;Z(q,b,!0);if(b.paths){for(c in b.paths)c in K||(a[c]=b.paths[c]);q.paths=a}if((a=b.packagePaths)||b.packages){if(a)for(c in a)c in K||$(d,a[c],c);b.packages&&$(d,b.packages);q.pkgs=d}if(b.priority)c=i.requireWait,i.requireWait=!1,z(),i.require(b.priority),z(),i.requireWait=c,q.priorityWait=b.priority;if(b.deps||b.callback)i.require(b.deps||[],b.callback)},requireDefined:function(b,a){return l(b,a).fullName in n},requireSpecified:function(b,a){return l(b,a).fullName in A},require:function(b, +c,g){if(typeof b==="string"){if(J(c))return d.onError(O("requireargs","Invalid require call"));if(d.get)return d.get(i,b,c);c=l(b,c);b=c.fullName;return!(b in n)?d.onError(O("notloaded","Module name '"+c.fullName+"' has not been loaded yet for context: "+a)):n[b]}(b&&b.length||c)&&B(null,b,c,g);if(!i.requireWait)for(;!i.scriptCount&&i.paused.length;)z();return i.require},takeGlobalQueue:function(){T.length&&(ia.apply(i.defQueue,[i.defQueue.length-1,0].concat(T)),T=[])},completeLoad:function(b){var a; +for(i.takeGlobalQueue();R.length;)if(a=R.shift(),a[0]===null){a[0]=b;break}else if(a[0]===b)break;else v(a),a=null;a?v(a):v([b,[],b==="jquery"&&typeof jQuery!=="undefined"?function(){return jQuery}:null]);d.isAsync&&(i.scriptCount-=1);z();d.isAsync||(i.scriptCount-=1)},toUrl:function(b,a){var c=b.lastIndexOf("."),d=null;c!==-1&&(d=b.substring(c,b.length),b=b.substring(0,c));return i.nameToUrl(b,d,a)},nameToUrl:function(b,a,g){var l,k,h,e,j=i.config,b=c(b,g&&g.fullName);if(d.jsExtRegExp.test(b))a= +b+(a?a:"");else{l=j.paths;k=j.pkgs;g=b.split("/");for(e=g.length;e>0;e--)if(h=g.slice(0,e).join("/"),l[h]){g.splice(0,e,l[h]);break}else if(h=k[h]){b=b===h.name?h.location+"/"+h.main:h.location;g.splice(0,e,b);break}a=g.join("/")+(a||".js");a=(a.charAt(0)==="/"||a.match(/^\w+:/)?"":j.baseUrl)+a}return j.urlArgs?a+((a.indexOf("?")===-1?"?":"&")+j.urlArgs):a}};i.jQueryCheck=V;i.resume=z;return i}function ja(){var a,c,d;if(B&&B.readyState==="interactive")return B;a=document.getElementsByTagName("script"); +for(c=a.length-1;c>-1&&(d=a[c]);c--)if(d.readyState==="interactive")return B=d;return null}var ka=/(\/\*([\s\S]*?)\*\/|([^:]|^)\/\/(.*)$)/mg,la=/require\(\s*["']([^'"\s]+)["']\s*\)/g,ea=/^\.\//,aa=/\.js$/,N=Object.prototype.toString,t=Array.prototype,ga=t.slice,ia=t.splice,H=!!(typeof window!=="undefined"&&navigator&&document),ca=!H&&typeof importScripts!=="undefined",ma=H&&navigator.platform==="PLAYSTATION 3"?/^complete$/:/^(complete|loaded)$/,da=typeof opera!=="undefined"&&opera.toString()==="[object Opera]", +K={},C={},T=[],B=null,X=0,P=!1,ha={require:!0,module:!0,exports:!0},d,t={},I,x,u,D,o,v,E,A,y,V,W;if(typeof define==="undefined"){if(typeof requirejs!=="undefined")if(J(requirejs))return;else t=requirejs,requirejs=void 0;typeof require!=="undefined"&&!J(require)&&(t=require,require=void 0);d=requirejs=function(a,c,d){var j="_",k;!F(a)&&typeof a!=="string"&&(k=a,F(c)?(a=c,c=d):a=[]);if(k&&k.context)j=k.context;d=C[j]||(C[j]=fa(j));k&&d.configure(k);return d.require(a,c)};d.config=function(a){return d(a)}; +require||(require=d);d.toUrl=function(a){return C._.toUrl(a)};d.version="1.0.5";d.jsExtRegExp=/^\/|:|\?|\.js$/;x=d.s={contexts:C,skipAsync:{}};if(d.isAsync=d.isBrowser=H)if(u=x.head=document.getElementsByTagName("head")[0],D=document.getElementsByTagName("base")[0])u=x.head=D.parentNode;d.onError=function(a){throw a;};d.load=function(a,c,l){d.resourcesReady(!1);a.scriptCount+=1;d.attach(l,a,c);if(a.jQuery&&!a.jQueryIncremented)U(a.jQuery,!0),a.jQueryIncremented=!0};define=function(a,c,d){var j,k; +typeof a!=="string"&&(d=c,c=a,a=null);F(c)||(d=c,c=[]);!c.length&&J(d)&&d.length&&(d.toString().replace(ka,"").replace(la,function(a,d){c.push(d)}),c=(d.length===1?["require"]:["require","exports","module"]).concat(c));if(P&&(j=I||ja()))a||(a=j.getAttribute("data-requiremodule")),k=C[j.getAttribute("data-requirecontext")];(k?k.defQueue:T).push([a,c,d])};define.amd={multiversion:!0,plugins:!0,jQuery:!0};d.exec=function(a){return eval(a)};d.execCb=function(a,c,d,j){return c.apply(j,d)};d.addScriptToDom= +function(a){I=a;D?u.insertBefore(a,D):u.appendChild(a);I=null};d.onScriptLoad=function(a){var c=a.currentTarget||a.srcElement,l;if(a.type==="load"||c&&ma.test(c.readyState))B=null,a=c.getAttribute("data-requirecontext"),l=c.getAttribute("data-requiremodule"),C[a].completeLoad(l),c.detachEvent&&!da?c.detachEvent("onreadystatechange",d.onScriptLoad):c.removeEventListener("load",d.onScriptLoad,!1)};d.attach=function(a,c,l,j,k,o){var p;if(H)return j=j||d.onScriptLoad,p=c&&c.config&&c.config.xhtml?document.createElementNS("http://www.w3.org/1999/xhtml", +"html:script"):document.createElement("script"),p.type=k||c&&c.config.scriptType||"text/javascript",p.charset="utf-8",p.async=!x.skipAsync[a],c&&p.setAttribute("data-requirecontext",c.contextName),p.setAttribute("data-requiremodule",l),p.attachEvent&&!da?(P=!0,o?p.onreadystatechange=function(){if(p.readyState==="loaded")p.onreadystatechange=null,p.attachEvent("onreadystatechange",j),o(p)}:p.attachEvent("onreadystatechange",j)):p.addEventListener("load",j,!1),p.src=a,o||d.addScriptToDom(p),p;else ca&& +(importScripts(a),c.completeLoad(l));return null};if(H){o=document.getElementsByTagName("script");for(A=o.length-1;A>-1&&(v=o[A]);A--){if(!u)u=v.parentNode;if(E=v.getAttribute("data-main")){if(!t.baseUrl)o=E.split("/"),v=o.pop(),o=o.length?o.join("/")+"/":"./",t.baseUrl=o,E=v.replace(aa,"");t.deps=t.deps?t.deps.concat(E):[E];break}}}d.checkReadyState=function(){var a=x.contexts,c;for(c in a)if(!(c in K)&&a[c].waitCount)return;d.resourcesReady(!0)};d.resourcesReady=function(a){var c,l;d.resourcesDone= +a;if(d.resourcesDone)for(l in a=x.contexts,a)if(!(l in K)&&(c=a[l],c.jQueryIncremented))U(c.jQuery,!1),c.jQueryIncremented=!1};d.pageLoaded=function(){if(document.readyState!=="complete")document.readyState="complete"};if(H&&document.addEventListener&&!document.readyState)document.readyState="loading",window.addEventListener("load",d.pageLoaded,!1);d(t);if(d.isAsync&&typeof setTimeout!=="undefined")y=x.contexts[t.context||"_"],y.requireWait=!0,setTimeout(function(){y.requireWait=!1;y.scriptCount|| +y.resume();d.checkReadyState()},0)}})(); \ No newline at end of file diff --git a/ext/trafficCop-0.3.0.js b/ext/trafficCop-0.3.0.js new file mode 100644 index 0000000..cb74991 --- /dev/null +++ b/ext/trafficCop-0.3.0.js @@ -0,0 +1,36 @@ +var factory = function() { + /* + TrafficCop + Author: Jim Cowart + License: Dual licensed MIT (http://www.opensource.org/licenses/mit-license) & GPL (http://www.opensource.org/licenses/gpl-license) + Version 0.3.0 + */ + + var inProgress = {}; + $ = window.$ || arguments[0]; + $.trafficCop = function(url, options) { + var reqOptions = url, key; + if(arguments.length === 2) { + reqOptions = $.extend(true, options, { url: url }); + } + key = JSON.stringify(reqOptions); + if (key in inProgress) { + for (i in {success: 1, error: 1, complete: 1}) { + inProgress[key][i](reqOptions[i]); + } + } else { + inProgress[key] = $.ajax(reqOptions).always(function () { delete inProgress[key]; }); + } + return inProgress[key]; + }; + + return $.trafficCop; +}; + +if( window.define ) { + define(['jquery'], function($) { + factory($); + }); +} else { + factory(); +} \ No newline at end of file diff --git a/ext/trafficCop.js b/ext/trafficCop.js new file mode 100644 index 0000000..defe92e --- /dev/null +++ b/ext/trafficCop.js @@ -0,0 +1,38 @@ +(function($, global, undefined) { +(function($, undefined) { + +var inProgress = {}; + +$.trafficCop = function(url, options) { + var reqOptions = url, key; + if(arguments.length === 2) { + reqOptions = $.extend(true, options, { url: url }); + } + key = JSON.stringify(reqOptions); + if(inProgress[key]) { + inProgress[key].successCallbacks.push(reqOptions.success); + inProgress[key].errorCallbacks.push(reqOptions.error); + return; + } + + var remove = function() { + delete inProgress[key]; + }, + traffic = { + successCallbacks: [reqOptions.success], + errorCallbacks: [reqOptions.error], + success: function(response) { + $.each($(inProgress[key].successCallbacks), function(idx,item){ item(response); }); + remove(); + }, + error: function(exception) { + $.each($(inProgress[key].errorCallbacks), function(idx,item){ item(exception); }); + remove(); + } + }; + inProgress[key] = $.extend(true, {}, reqOptions, traffic); + $.ajax(inProgress[key]); +}; + +})(jQuery); +global.infuser = infuser; })(jQuery, window); \ No newline at end of file diff --git a/ext/underscore-1.3.1.js b/ext/underscore-1.3.1.js new file mode 100644 index 0000000..dd5e33e --- /dev/null +++ b/ext/underscore-1.3.1.js @@ -0,0 +1,31 @@ +// Underscore.js 1.3.1 +// (c) 2009-2012 Jeremy Ashkenas, DocumentCloud Inc. +// Underscore is freely distributable under the MIT license. +// Portions of Underscore are inspired or borrowed from Prototype, +// Oliver Steele's Functional, and John Resig's Micro-Templating. +// For all details and documentation: +// http://documentcloud.github.com/underscore +(function(){function q(a,c,d){if(a===c)return a!==0||1/a==1/c;if(a==null||c==null)return a===c;if(a._chain)a=a._wrapped;if(c._chain)c=c._wrapped;if(a.isEqual&&b.isFunction(a.isEqual))return a.isEqual(c);if(c.isEqual&&b.isFunction(c.isEqual))return c.isEqual(a);var e=l.call(a);if(e!=l.call(c))return false;switch(e){case "[object String]":return a==String(c);case "[object Number]":return a!=+a?c!=+c:a==0?1/a==1/c:a==+c;case "[object Date]":case "[object Boolean]":return+a==+c;case "[object RegExp]":return a.source== +c.source&&a.global==c.global&&a.multiline==c.multiline&&a.ignoreCase==c.ignoreCase}if(typeof a!="object"||typeof c!="object")return false;for(var f=d.length;f--;)if(d[f]==a)return true;d.push(a);var f=0,g=true;if(e=="[object Array]"){if(f=a.length,g=f==c.length)for(;f--;)if(!(g=f in a==f in c&&q(a[f],c[f],d)))break}else{if("constructor"in a!="constructor"in c||a.constructor!=c.constructor)return false;for(var h in a)if(b.has(a,h)&&(f++,!(g=b.has(c,h)&&q(a[h],c[h],d))))break;if(g){for(h in c)if(b.has(c, +h)&&!f--)break;g=!f}}d.pop();return g}var r=this,G=r._,n={},k=Array.prototype,o=Object.prototype,i=k.slice,H=k.unshift,l=o.toString,I=o.hasOwnProperty,w=k.forEach,x=k.map,y=k.reduce,z=k.reduceRight,A=k.filter,B=k.every,C=k.some,p=k.indexOf,D=k.lastIndexOf,o=Array.isArray,J=Object.keys,s=Function.prototype.bind,b=function(a){return new m(a)};if(typeof exports!=="undefined"){if(typeof module!=="undefined"&&module.exports)exports=module.exports=b;exports._=b}else typeof define==="function"&&define.amd&& +define("underscore",function(){return b}),r._=b;b.VERSION="1.3.1";var j=b.each=b.forEach=function(a,c,d){if(a!=null)if(w&&a.forEach===w)a.forEach(c,d);else if(a.length===+a.length)for(var e=0,f=a.length;e2;a==null&&(a=[]);if(y&&a.reduce===y)return e&&(c=b.bind(c,e)),f?a.reduce(c,d):a.reduce(c);j(a,function(a,b,i){f?d=c.call(e,d,a,b,i):(d=a,f=true)});if(!f)throw new TypeError("Reduce of empty array with no initial value");return d};b.reduceRight=b.foldr=function(a,c,d,e){var f=arguments.length>2;a==null&&(a=[]);if(z&&a.reduceRight===z)return e&&(c=b.bind(c,e)),f?a.reduceRight(c,d):a.reduceRight(c);var g=b.toArray(a).reverse();e&&!f&& +(c=b.bind(c,e));return f?b.reduce(g,c,d,e):b.reduce(g,c)};b.find=b.detect=function(a,c,b){var e;E(a,function(a,g,h){if(c.call(b,a,g,h))return e=a,true});return e};b.filter=b.select=function(a,c,b){var e=[];if(a==null)return e;if(A&&a.filter===A)return a.filter(c,b);j(a,function(a,g,h){c.call(b,a,g,h)&&(e[e.length]=a)});return e};b.reject=function(a,c,b){var e=[];if(a==null)return e;j(a,function(a,g,h){c.call(b,a,g,h)||(e[e.length]=a)});return e};b.every=b.all=function(a,c,b){var e=true;if(a==null)return e; +if(B&&a.every===B)return a.every(c,b);j(a,function(a,g,h){if(!(e=e&&c.call(b,a,g,h)))return n});return e};var E=b.some=b.any=function(a,c,d){c||(c=b.identity);var e=false;if(a==null)return e;if(C&&a.some===C)return a.some(c,d);j(a,function(a,b,h){if(e||(e=c.call(d,a,b,h)))return n});return!!e};b.include=b.contains=function(a,c){var b=false;if(a==null)return b;return p&&a.indexOf===p?a.indexOf(c)!=-1:b=E(a,function(a){return a===c})};b.invoke=function(a,c){var d=i.call(arguments,2);return b.map(a, +function(a){return(b.isFunction(c)?c||a:a[c]).apply(a,d)})};b.pluck=function(a,c){return b.map(a,function(a){return a[c]})};b.max=function(a,c,d){if(!c&&b.isArray(a))return Math.max.apply(Math,a);if(!c&&b.isEmpty(a))return-Infinity;var e={computed:-Infinity};j(a,function(a,b,h){b=c?c.call(d,a,b,h):a;b>=e.computed&&(e={value:a,computed:b})});return e.value};b.min=function(a,c,d){if(!c&&b.isArray(a))return Math.min.apply(Math,a);if(!c&&b.isEmpty(a))return Infinity;var e={computed:Infinity};j(a,function(a, +b,h){b=c?c.call(d,a,b,h):a;bd?1:0}),"value")};b.groupBy=function(a,c){var d={},e=b.isFunction(c)?c:function(a){return a[c]};j(a,function(a,b){var c= +e(a,b);(d[c]||(d[c]=[])).push(a)});return d};b.sortedIndex=function(a,c,d){d||(d=b.identity);for(var e=0,f=a.length;e>1;d(a[g])=0})})};b.difference=function(a){var c=b.flatten(i.call(arguments,1));return b.filter(a,function(a){return!b.include(c,a)})};b.zip=function(){for(var a=i.call(arguments),c=b.max(b.pluck(a,"length")),d=Array(c),e= +0;e= +0;d--)b=[a[d].apply(this,b)];return b[0]}};b.after=function(a,b){return a<=0?b():function(){if(--a<1)return b.apply(this,arguments)}};b.keys=J||function(a){if(a!==Object(a))throw new TypeError("Invalid object");var c=[],d;for(d in a)b.has(a,d)&&(c[c.length]=d);return c};b.values=function(a){return b.map(a,b.identity)};b.functions=b.methods=function(a){var c=[],d;for(d in a)b.isFunction(a[d])&&c.push(d);return c.sort()};b.extend=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]=b[d]}); +return a};b.defaults=function(a){j(i.call(arguments,1),function(b){for(var d in b)a[d]==null&&(a[d]=b[d])});return a};b.clone=function(a){return!b.isObject(a)?a:b.isArray(a)?a.slice():b.extend({},a)};b.tap=function(a,b){b(a);return a};b.isEqual=function(a,b){return q(a,b,[])};b.isEmpty=function(a){if(b.isArray(a)||b.isString(a))return a.length===0;for(var c in a)if(b.has(a,c))return false;return true};b.isElement=function(a){return!!(a&&a.nodeType==1)};b.isArray=o||function(a){return l.call(a)=="[object Array]"}; +b.isObject=function(a){return a===Object(a)};b.isArguments=function(a){return l.call(a)=="[object Arguments]"};if(!b.isArguments(arguments))b.isArguments=function(a){return!(!a||!b.has(a,"callee"))};b.isFunction=function(a){return l.call(a)=="[object Function]"};b.isString=function(a){return l.call(a)=="[object String]"};b.isNumber=function(a){return l.call(a)=="[object Number]"};b.isNaN=function(a){return a!==a};b.isBoolean=function(a){return a===true||a===false||l.call(a)=="[object Boolean]"};b.isDate= +function(a){return l.call(a)=="[object Date]"};b.isRegExp=function(a){return l.call(a)=="[object RegExp]"};b.isNull=function(a){return a===null};b.isUndefined=function(a){return a===void 0};b.has=function(a,b){return I.call(a,b)};b.noConflict=function(){r._=G;return this};b.identity=function(a){return a};b.times=function(a,b,d){for(var e=0;e/g,">").replace(/"/g,""").replace(/'/g,"'").replace(/\//g, +"/")};b.mixin=function(a){j(b.functions(a),function(c){K(c,b[c]=a[c])})};var L=0;b.uniqueId=function(a){var b=L++;return a?a+b:b};b.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var t=/.^/,u=function(a){return a.replace(/\\\\/g,"\\").replace(/\\'/g,"'")};b.template=function(a,c){var d=b.templateSettings,d="var __p=[],print=function(){__p.push.apply(__p,arguments);};with(obj||{}){__p.push('"+a.replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(d.escape|| +t,function(a,b){return"',_.escape("+u(b)+"),'"}).replace(d.interpolate||t,function(a,b){return"',"+u(b)+",'"}).replace(d.evaluate||t,function(a,b){return"');"+u(b).replace(/[\r\n\t]/g," ")+";__p.push('"}).replace(/\r/g,"\\r").replace(/\n/g,"\\n").replace(/\t/g,"\\t")+"');}return __p.join('');",e=new Function("obj","_",d);return c?e(c,b):function(a){return e.call(this,a,b)}};b.chain=function(a){return b(a).chain()};var m=function(a){this._wrapped=a};b.prototype=m.prototype;var v=function(a,c){return c? +b(a).chain():a},K=function(a,c){m.prototype[a]=function(){var a=i.call(arguments);H.call(a,this._wrapped);return v(c.apply(b,a),this._chain)}};b.mixin(b);j("pop,push,reverse,shift,sort,splice,unshift".split(","),function(a){var b=k[a];m.prototype[a]=function(){var d=this._wrapped;b.apply(d,arguments);var e=d.length;(a=="shift"||a=="splice")&&e===0&&delete d[0];return v(d,this._chain)}});j(["concat","join","slice"],function(a){var b=k[a];m.prototype[a]=function(){return v(b.apply(this._wrapped,arguments), +this._chain)}});m.prototype.chain=function(){this._chain=true;return this};m.prototype.value=function(){return this._wrapped}}).call(this); \ No newline at end of file diff --git a/header.txt b/header.txt new file mode 100644 index 0000000..2440acc --- /dev/null +++ b/header.txt @@ -0,0 +1,6 @@ +/* + Cartographer.js + Author: Alex Robson <@A_Robson> + License: MIT ( http://www.opensource.org/licenses/mit-license ) + Version: 0.2.0 +*/ \ No newline at end of file diff --git a/lib/cartographer.amd.js b/lib/cartographer.amd.js new file mode 100644 index 0000000..ce25779 --- /dev/null +++ b/lib/cartographer.amd.js @@ -0,0 +1,530 @@ +define(['jquery', 'underscore', 'infuser', 'DOMBuilder'], function($, _, infuser) { + var configuration, createChildren, createFqn, elementTemplate, getActualValue, getHtmlFromList, getNestedValue; +configuration = { + elementIdentifier: 'data-id', + templateIdentifier: 'data-template' +}; +createChildren = function(iterations, templateInstance, model, modelFqn, id, context, onChildren) { + var callList, childFqn, childId, childModel, children, fx, isCollection, iteration, _i, _len, _ref; + children = context.childrenToCreate; + isCollection = iterations > 0; + if (!iterations) { + iterations = 1; + } + childId = id; + childModel = model; + childFqn = modelFqn; + callList = []; + for (iteration = 0, _ref = iterations - 1; 0 <= _ref ? iteration <= _ref : iteration >= _ref; 0 <= _ref ? iteration++ : iteration--) { + if (id === void 0 && isCollection) { + childId = iteration; + childModel = model[childId]; + childFqn = "" + modelFqn + "." + childId; + } + for (_i = 0, _len = children.length; _i < _len; _i++) { + fx = children[_i]; + callList.push(createCallback(self, fx, [templateInstance, childModel, childFqn, childId])); + } + } + return forkJoin(callList, onChildren); +}; +createFqn = function(namespace, id, name, filterName) { + var delimiter, newId, newNs, result; + newNs = namespace || ""; + newId = id === void 0 ? "" : id; + delimiter = newNs !== "" && newId !== "" ? "." : ""; + result = "" + newNs + delimiter + newId; + return result; +}; +elementTemplate = function(element) { + var _ref; + return element != null ? (_ref = element.attributes[configuration.templateIdentifier]) != null ? _ref.value : void 0 : void 0; +}; +getActualValue = function(value, context) { + if (_.isFunction(value)) { + return value.call(context); + } else { + return value; + } +}; +getHtmlFromList = function(list, html) { + return $(html["DIV"]({}, list)).html(); +}; +getNestedValue = function(value, property) { + if (value && value[property]) { + return value[property]; + } else { + return; + } +}; +var createCallback, forkJoin, queueByArgList, queueByFunctionList; +forkJoin = function(work, done, iterations) { + var callCounter, count, fx, iteration, list, onList, total, _ref, _results; + if (!iterations) { + iterations = 1; + } + total = work.length * iterations; + list = new Array(total); + count = 0; + onList = function(index, result) { + count++; + list[index] = result; + if (count === total) { + return done(list); + } + }; + callCounter = 0; + _results = []; + for (iteration = 0, _ref = iterations - 1; 0 <= _ref ? iteration <= _ref : iteration >= _ref; 0 <= _ref ? iteration++ : iteration--) { + _results.push((function() { + var _i, _len, _results2; + _results2 = []; + for (_i = 0, _len = work.length; _i < _len; _i++) { + fx = work[_i]; + fx(function(y) { + return onList(callCounter, y); + }); + _results2.push(callCounter++); + } + return _results2; + })()); + } + return _results; +}; +queueByArgList = function(context, worker, argList) { + var count, index, list, _ref; + count = argList.length; + list = new Array(count); + for (index = 0, _ref = count - 1; 0 <= _ref ? index <= _ref : index >= _ref; 0 <= _ref ? index++ : index--) { + list[index] = createCallback(context, worker, argList[index]); + } + return list; +}; +queueByFunctionList = function(context, workers, args) { + var count, index, list, _ref; + count = workers.length; + list = new Array(count); + for (index = 0, _ref = count - 1; 0 <= _ref ? index <= _ref : index >= _ref; 0 <= _ref ? index++ : index--) { + list[index] = createCallback(context, workers[index], args); + } + return list; +}; +createCallback = function(context, callback, args) { + return function(x) { + return callback.apply(context, args.concat(x)); + }; +}; +var SourceResolver, infuser, resolver; +SourceResolver = (function() { + function SourceResolver() { + this.sources = []; + } + SourceResolver.prototype.appendSource = function(source) { + return this.sources.push(source); + }; + SourceResolver.prototype.prependSource = function(source) { + return this.sources.unshift(source); + }; + SourceResolver.prototype.resolve = function(name, onFound, notFound) { + var finder, index, self; + self = this; + index = 0; + finder = function() {}; + finder = function() { + var call; + call = self.sources[index]; + if (call) { + return call(name, function(x) { + return onFound($(x)); + }, function() { + index++; + return finder(); + }); + } else { + return notFound(); + } + }; + return finder(); + }; + return SourceResolver; +})(); +resolver = new SourceResolver(); +resolver.appendSource(function(name, success, fail) { + var template; + template = $('#' + name + '-template'); + if (template.length > 0) { + return success(template[0]); + } else { + return fail(); + } +}); +infuser = infuser || window.infuser; +if (infuser) { + resolver.appendSource(function(name, success, fail) { + return infuser.get(name, function(x) { + return success(x); + }, function(x) { + return fail(); + }); + }); +} +var Cartographer, cartographer; +Cartographer = (function() { + function Cartographer() { + this.config = configuration; + this.templates = {}; + this.containerLookup = {}; + this.instanceCache = {}; + this.resolver = resolver; + } + Cartographer.prototype.map = function(name) { + var template; + template = new Template(name); + this.templates[name] = template; + return true; + }; + Cartographer.prototype.render = function(name, id, model, onMarkup, onError) { + var self, template, templateName; + self = this; + this.containerLookup[id] = this.templates[name]; + if (this.templates[name]) { + template = this.templates[name]; + return template.render(id, model, function(id, op, result) { + self.instanceCache[id] = result; + return onMarkup(id, op, result); + }); + } else if (model.__template__ && id) { + templateName = model.__template__; + this.map(templateName); + return this.render(templateName, id, model, onMarkup, onError); + } else { + return onError(id, "render", "No template with " + name + " has been mapped"); + } + }; + Cartographer.prototype.add = function(id, listId, model, onMarkup) { + var template; + if (this.containerLookup[id]) { + template = this.containerLookup[id]; + return template.add(listId, model, onMarkup); + } + }; + Cartographer.prototype.update = function(id, controlId, model, onMarkup) { + var template; + if (this.containerLookup[id]) { + template = this.containerLookup[id]; + return template.update(controlId, model, onMarkup); + } + }; + return Cartographer; +})(); +cartographer = new Cartographer(); +cartographer; +var Template; +Template = (function() { + function Template(name) { + var self; + this.name = name; + self = this; + this.name = name; + this.fqn = ""; + this.html = DOMBuilder.dom; + this.templates = {}; + this.deferredApplyCalls = []; + this.renderTemplate = function() {}; + this.ready = false; + this.factories = {}; + this.crawl(this.name, void 0, {}, function(x) { + var call, _i, _len, _ref, _results; + self.renderTemplate = x; + self.ready = true; + if (self.deferredApplyCalls.length > 0) { + _ref = self.deferredApplyCalls; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + call = _ref[_i]; + _results.push(call()); + } + return _results; + } + }); + } + Template.prototype.handleTemplate = function(template, templateId, onTemplate) { + var self; + self = this; + if (self.templates[templateId]) { + onTemplate(self.templates[templateId]); + return true; + } else { + resolver.resolve(template, function(x) { + return onTemplate(x); + }, function() { + return console.log("Could not resolve tempalte " + template); + }); + return true; + } + }; + Template.prototype.buildCreateCall = function(element, elementId, elementFqn, childrenToCreate, templates) { + var context, self, tag; + self = this; + tag = element.tagName.toUpperCase(); + context = { + tag: tag, + element: element, + elementId: elementId, + elementFqn: elementFqn, + childrenToCreate: childrenToCreate, + templates: templates + }; + return function(instance, model, fqn, id, onElement) { + return self.create(instance, model, fqn, id, context, onElement); + }; + }; + Template.prototype.crawl = function(namespace, markup, templates, onDone) { + var argList, child, childFunctionsExpected, children, continueProcessing, elementFqn, elementId, i, queue1, self, template, total, workQueue, _ref; + self = this; + if ((markup != null ? markup.length : void 0) && (!markup.nodeType || markup.nodeType === 1)) { + if (markup.length > 1) { + total = markup.length; + argList = (function() { + var _ref, _results; + _results = []; + for (i = 0, _ref = total - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) { + _results.push([namespace, markup[i], templates]); + } + return _results; + })(); + workQueue = queueByArgList(self, self.crawl, argList); + return forkJoin(workQueue, function(callList) { + return onDone(function(instance, model, fqn, id, onElement) { + var crawlQueue; + crawlQueue = queueByFunctionList(self, callList, [instance, model, fqn, id]); + return forkJoin(crawlQueue, function(result) { + return onElement(result); + }); + }); + }); + } else { + return self.crawl(namespace, markup[0], templates, onDone); + } + } else { + if ((markup != null ? markup.nodeType : void 0) && markup.nodeType !== 1) { + return onDone(function() { + return arguments[4](markup.nodeValue); + }); + } else { + template = markup ? template = elementTemplate(markup) : namespace; + elementId = markup != null ? (_ref = markup.attributes[configuration.elementIdentifier]) != null ? _ref.value : void 0 : void 0; + elementFqn = namespace + (elementId ? "." + elementId : ''); + if (template) { + if (!templates[template]) { + templates[template] = template; + return self.handleTemplate(template, elementFqn + "." + template, function(x) { + return self.crawl(namespace, x, templates, function(f) { + self.factories[template] = f; + return onDone(f); + }); + }); + } else { + return onDone(function() { + return self.factories[template].apply(self, [].slice.call(arguments, 0)); + }); + } + } else { + children = markup.childNodes; + childFunctionsExpected = children.length; + continueProcessing = function(contentList) { + var factory; + factory = self.buildCreateCall(markup, elementId, elementFqn, contentList, templates); + self.factories[elementFqn] = factory; + return onDone(factory); + }; + if (children.length > 0) { + argList = (function() { + var _i, _len, _results; + _results = []; + for (_i = 0, _len = children.length; _i < _len; _i++) { + child = children[_i]; + _results.push([elementFqn, child, templates]); + } + return _results; + })(); + queue1 = queueByArgList(self, self.crawl, argList); + return forkJoin(queue1, continueProcessing); + } else { + return continueProcessing([]); + } + } + } + } + }; + Template.prototype.handleModelTemplate = function(template, templateInstance, model, modelFqn, id, context, onElement) { + var self; + self = this; + if (self.templates[template]) { + return self.templates[template](templateInstance, model, modelFqn, id, onElement); + } else { + return self.handleTemplate(template, template, function(x) { + return self.crawl(context.elementFqn, x, templates, function(callback) { + self.templates[template] = callback; + return callback(templateInstance, model, modelFqn, id, onElement); + }); + }); + } + }; + Template.prototype.create = function(templateInstance, model, modelFqn, id, context, onElement) { + var childElementCount, childElements, childModel, collection, collectionLength, elementId, idForFqn, isBound, isCollection, memberTemplate, memberValue, modelTemplate, newFqn, self, _ref; + self = this; + elementId = context.elementId; + id = elementId || id; + isBound = elementId !== void 0 && elementId !== ""; + idForFqn = isBound ? id : ""; + newFqn = createFqn(modelFqn, idForFqn, false, self.name); + if (isBound && !model[id]) { + onElement(""); + return; + } + modelTemplate = getActualValue(model.__template__, model); + memberTemplate = getActualValue((_ref = model[id]) != null ? _ref.__template__ : void 0, model); + memberValue = getActualValue(getNestedValue(model[id], "__value__") || model[id] || getNestedValue(model, "__value__"), model); + childModel = isBound ? model[id] : model; + if (modelTemplate) { + delete model.__template__; + return self.handleModelTemplate(modelTemplate, templateInstance, model, modelFqn, id, context, function(x) { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, isBound, x, model, templateInstance)); + }); + } else if (memberTemplate) { + delete model[id].__template__; + return self.handleModelTemplate(modelTemplate, templateInstance, model, modelFqn, id, context, onElement); + } else { + childElements = context != null ? context.childrenToCreate.slice(0) : void 0; + childElementCount = childElements.length; + if (childElementCount > 0) { + collection = getNestedValue(memberValue, "__items__") || memberValue; + collectionLength = collection ? collection.length : 0; + isCollection = collectionLength && !_.isString(collection) ? collection : void 0; + self.factories[newFqn + "_add"] = function(itemIndex, itemModel, onItem) { + newFqn = "" + newFqn + "." + itemIndex; + return createChildren(0, templateInstance, itemModel, newFqn, itemIndex, context, onItem); + }; + if (isCollection) { + return createChildren(collectionLength, templateInstance, childModel, newFqn, void 0, context, function(list) { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, context.elementId, list, model, templateInstance)); + }); + } else { + return createChildren(0, templateInstance, childModel, newFqn, id, context, function(list) { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, context.elementId, list, model, templateInstance)); + }); + } + } else { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, isBound, memberValue, model, templateInstance)); + } + } + }; + Template.prototype.makeTag = function(tag, originalElement, fqn, id, hasId, val, model, templateInstance) { + var alt, content, element, link, properties, self, _ref, _ref2, _ref3; + self = this; + properties = {}; + content = _.isString(val) ? val : _.isArray(val) ? val || (val != null ? val[id] : void 0) : (val != null ? val[id] : void 0) || val; + content = originalElement.children.length === 0 && id === void 0 && (_.isObject(val) || _.isArray(val)) ? originalElement.textContent : content; + element = {}; + if (hasId) { + properties[configuration.elementIdentifier] = fqn; + } + if (originalElement["className"]) { + properties["class"] = originalElement["className"]; + } + if (originalElement["type"]) { + properties["type"] = originalElement["type"]; + } + if (originalElement["value"]) { + properties["value"] = originalElement["value"]; + } + if (originalElement["id"]) { + properties["id"] = originalElement["id"]; + } + if (model != null ? (_ref = model[id]) != null ? _ref["class"] : void 0 : void 0) { + properties["class"] = model[id]["class"]; + } + if (tag === "INPUT") { + if (!_.isObject(content)) { + properties.value = content; + } + element = self.html[tag](properties); + } else if (tag === "IMG") { + properties = $.extend(properties, { + src: content.src || content || originalElement.src, + alt: content.alt || content || originalElement.alt, + width: content.width || originalElement.width || "", + height: content.height || originalElement.height || "" + }); + element = self.html[tag](properties); + } else if (tag === "A") { + link = ((_ref2 = model[id]) != null ? _ref2.link : void 0) || model.link || originalElement.href; + alt = ((_ref3 = model[id]) != null ? _ref3.alt : void 0) || model.alt || content || originalElement.alt; + properties = $.extend(properties, { + href: link, + alt: alt + }); + element = self.html[tag](properties, content); + } else { + element = self.html[tag](properties, content); + } + return element; + }; + Template.prototype.render = function(id, originalModel, onResult) { + var model, self; + self = this; + model = $.extend(true, {}, originalModel); + if (!self.ready) { + return self.deferredApplyCalls.push(function() { + return self.render(id, model, onResult); + }); + } else { + return self.renderTemplate(id, model, id, void 0, function(x) { + var result; + result = {}; + if (!x.length) { + result = $(x)[0]; + $(result).attr(configuration.elementIdentifier, id); + } else { + result = getHtmlFromList(x, self.html); + } + return onResult(id, result, "render"); + }); + } + }; + Template.prototype.update = function(fqn, model, onResult) { + var childKey, lastIndex, parentKey, self, templateId; + self = this; + lastIndex = fqn.lastIndexOf("."); + templateId = fqn.split('.')[0]; + parentKey = fqn.substring(0, lastIndex); + childKey = fqn.substring(lastIndex + 1); + if (self.factories[fqn]) { + return self.factories[fqn](templateId, model, parentKey, childKey, (function(dom) { + var newElement; + newElement = dom; + return onResult(fqn, newElement, "update"); + })); + } + }; + Template.prototype.add = function(fqn, model, onResult) { + var addName, childKey, count, lastIndex, parentKey, self, templateId; + self = this; + lastIndex = fqn.lastIndexOf("."); + templateId = fqn.split('.')[0]; + parentKey = fqn.substring(0, lastIndex); + childKey = fqn.substring(lastIndex + 1); + addName = fqn + "_add"; + if (self.factories[addName]) { + count = $("[" + configuration.elementIdentifier + "=\"" + fqn + "\"]").children.length + 1; + return self.factories[addName](count, model, (function(dom) { + var newElement; + newElement = getHtmlFromList(dom, self.html); + return onResult(fqn, newElement, "add"); + })); + } + }; + return Template; +})(); return cartographer; +}); \ No newline at end of file diff --git a/lib/cartographer.amd.min.gz.js b/lib/cartographer.amd.min.gz.js new file mode 100644 index 0000000..feaef30 Binary files /dev/null and b/lib/cartographer.amd.min.gz.js differ diff --git a/lib/cartographer.amd.min.js b/lib/cartographer.amd.min.js new file mode 100644 index 0000000..5b71059 --- /dev/null +++ b/lib/cartographer.amd.min.js @@ -0,0 +1 @@ +define(["jquery","underscore","infuser","DOMBuilder"],function(a,b,c){var d,e,f,g,h,i,j;d={elementIdentifier:"data-id",templateIdentifier:"data-template"},e=function(a,b,c,d,e,f,g){var h,i,j,m,n,o,p,q,r,s,t;n=f.childrenToCreate,p=a>0,a||(a=1),j=e,m=c,i=d,h=[];for(q=0,t=a-1;0<=t?q<=t:q>=t;0<=t?q++:q--){e===void 0&&p&&(j=q,m=c[j],i=""+d+"."+j);for(r=0,s=n.length;r=k;0<=k?g++:g--)l.push(function(){var b,c,e;e=[];for(b=0,c=a.length;b=g;0<=g?e++:e--)f[e]=k(a,b,c[e]);return f},n=function(a,b,c){var d,e,f,g;d=b.length,f=new Array(d);for(e=0,g=d-1;0<=g?e<=g:e>=g;0<=g?e++:e--)f[e]=k(a,b[e],c);return f},k=function(a,b,c){return function(d){return b.apply(a,c.concat(d))}};var o,c,p;o=function(){function b(){this.sources=[]}return b.prototype.appendSource=function(a){return this.sources.push(a)},b.prototype.prependSource=function(a){return this.sources.unshift(a)},b.prototype.resolve=function(b,c,d){var e,f,g;return g=this,f=0,e=function(){},e=function(){var h;return h=g.sources[f],h?h(b,function(b){return c(a(b))},function(){return f++,e()}):d()},e()},b}(),p=new o,p.appendSource(function(b,c,d){var e;return e=a("#"+b+"-template"),e.length>0?c(e[0]):d()}),c=c||window.infuser,c&&p.appendSource(function(a,b,d){return c.get(a,function(a){return b(a)},function(a){return d()})});var q,r;q=function(){function a(){this.config=d,this.templates={},this.containerLookup={},this.instanceCache={},this.resolver=p}return a.prototype.map=function(a){var b;return b=new s(a),this.templates[a]=b,!0},a.prototype.render=function(a,b,c,d,e){var f,g,h;return f=this,this.containerLookup[b]=this.templates[a],this.templates[a]?(g=this.templates[a],g.render(b,c,function(a,b,c){return f.instanceCache[a]=c,d(a,b,c)})):c.__template__&&b?(h=c.__template__,this.map(h),this.render(h,b,c,d,e)):e(b,"render","No template with "+a+" has been mapped")},a.prototype.add=function(a,b,c,d){var e;if(this.containerLookup[a])return e=this.containerLookup[a],e.add(b,c,d)},a.prototype.update=function(a,b,c,d){var e;if(this.containerLookup[a])return e=this.containerLookup[a],e.update(b,c,d)},a}(),r=new q,r;var s;return s=function(){function c(a){var b;this.name=a,b=this,this.name=a,this.fqn="",this.html=DOMBuilder.dom,this.templates={},this.deferredApplyCalls=[],this.renderTemplate=function(){},this.ready=!1,this.factories={},this.crawl(this.name,void 0,{},function(a){var c,d,e,f,g;b.renderTemplate=a,b.ready=!0;if(b.deferredApplyCalls.length>0){f=b.deferredApplyCalls,g=[];for(d=0,e=f.length;d1?(u=b.length,f=function(){var d,e;e=[];for(q=0,d=u-1;0<=d?q<=d:q>=d;0<=d?q++:q--)e.push([a,b[q],c]);return e}(),v=m(s,s.crawl,f),l(v,function(a){return e(function(b,c,d,e,f){var g;return g=n(s,a,[b,c,d,e]),l(g,function(a){return f(a)})})})):s.crawl(a,b[0],c,e):(b!=null?b.nodeType:void 0)&&b.nodeType!==1?e(function(){return arguments[4](b.nodeValue)}):(t=b?t=g(b):a,p=b!=null?(w=b.attributes[d.elementIdentifier])!=null?w.value:void 0:void 0,o=a+(p?"."+p:""),t?c[t]?e(function(){return s.factories[t].apply(s,[].slice.call(arguments,0))}):(c[t]=t,s.handleTemplate(t,o+"."+t,function(b){return s.crawl(a,b,c,function(a){return s.factories[t]=a,e(a)})})):(j=b.childNodes,i=j.length,k=function(a){var d;return d=s.buildCreateCall(b,p,o,a,c),s.factories[o]=d,e(d)},j.length>0?(f=function(){var a,b,d;d=[];for(a=0,b=j.length;a0?(o=j(v,"__items__")||v,p=o?o.length:0,t=p&&!b.isString(o)?o:void 0,y.factories[x+"_add"]=function(b,c,d){return x=""+x+"."+b,e(0,a,c,x,b,i,d)},t?e(p,a,n,x,void 0,i,function(b){return k(y.makeTag(i.tag,i.element,x,g,i.elementId,b,c,a))}):e(0,a,n,x,g,i,function(b){return k(y.makeTag(i.tag,i.element,x,g,i.elementId,b,c,a))})):k(y.makeTag(i.tag,i.element,x,g,s,v,c,a)))},c.prototype.makeTag=function(c,e,f,g,h,i,j,k){var l,m,n,o,p,q,r,s,t;q=this,p={},m=b.isString(i)?i:b.isArray(i)?i||(i!=null?i[g]:void 0):(i!=null?i[g]:void 0)||i,m=e.children.length===0&&g===void 0&&(b.isObject(i)||b.isArray(i))?e.textContent:m,n={},h&&(p[d.elementIdentifier]=f),e.className&&(p["class"]=e.className),e.type&&(p.type=e.type),e.value&&(p.value=e.value),e.id&&(p.id=e.id);if(j!=null?(r=j[g])!=null?r["class"]:void 0:void 0)p["class"]=j[g]["class"];return c==="INPUT"?(b.isObject(m)||(p.value=m),n=q.html[c](p)):c==="IMG"?(p=a.extend(p,{src:m.src||m||e.src,alt:m.alt||m||e.alt,width:m.width||e.width||"",height:m.height||e.height||""}),n=q.html[c](p)):c==="A"?(o=((s=j[g])!=null?s.link:void 0)||j.link||e.href,l=((t=j[g])!=null?t.alt:void 0)||j.alt||m||e.alt,p=a.extend(p,{href:o,alt:l}),n=q.html[c](p,m)):n=q.html[c](p,m),n},c.prototype.render=function(b,c,e){var f,g;return g=this,f=a.extend(!0,{},c),g.ready?g.renderTemplate(b,f,b,void 0,function(c){var f;return f={},c.length?f=i(c,g.html):(f=a(c)[0],a(f).attr(d.elementIdentifier,b)),e(b,f,"render")}):g.deferredApplyCalls.push(function(){return g.render(b,f,e)})},c.prototype.update=function(a,b,c){var d,e,f,g,h;g=this,e=a.lastIndexOf("."),h=a.split(".")[0],f=a.substring(0,e),d=a.substring(e+1);if(g.factories[a])return g.factories[a](h,b,f,d,function(b){var d;return d=b,c(a,d,"update")})},c.prototype.add=function(b,c,e){var f,g,h,j,k,l,m;l=this,j=b.lastIndexOf("."),m=b.split(".")[0],k=b.substring(0,j),g=b.substring(j+1),f=b+"_add";if(l.factories[f])return h=a("["+d.elementIdentifier+'="'+b+'"]').children.length+1,l.factories[f](h,c,function(a){var c;return c=i(a,l.html),e(b,c,"add")})},c}(),r}) \ No newline at end of file diff --git a/lib/cartographer.js b/lib/cartographer.js index f970d38..edf0fc5 100644 --- a/lib/cartographer.js +++ b/lib/cartographer.js @@ -1,318 +1,528 @@ -(function(context) { -/* - cartographer - author: Alex Robson <@A_Robson> - License: MIT ( http://www.opensource.org/licenses/mit-license ) - Version: 0.1.0 -*/ -var Cartographer; -Cartographer = function() { - var self; - self = this; - postal.channel("cartographer").subscribe(function(m) { - if (m.map) { - return self.map(m.target, m.namespace); - } else if (m.apply) { - return self.apply(m.template, m.proxy, m.render, m.error); +var configuration, createChildren, createFqn, elementTemplate, getActualValue, getHtmlFromList, getNestedValue; +configuration = { + elementIdentifier: 'data-id', + templateIdentifier: 'data-template' +}; +createChildren = function(iterations, templateInstance, model, modelFqn, id, context, onChildren) { + var callList, childFqn, childId, childModel, children, fx, isCollection, iteration, _i, _len, _ref; + children = context.childrenToCreate; + isCollection = iterations > 0; + if (!iterations) { + iterations = 1; + } + childId = id; + childModel = model; + childFqn = modelFqn; + callList = []; + for (iteration = 0, _ref = iterations - 1; 0 <= _ref ? iteration <= _ref : iteration >= _ref; 0 <= _ref ? iteration++ : iteration--) { + if (id === void 0 && isCollection) { + childId = iteration; + childModel = model[childId]; + childFqn = "" + modelFqn + "." + childId; } - }); - this.templates = {}; - this.map = function(target, namespace) { - var template; - template = new Template(target, namespace); - return this.templates[template.fqn] = template; - }; - this.apply = function(template, proxy, render, error) { - var result, templateInstance; - templateInstance = this.templates[template]; - if (templateInstance) { - result = templateInstance.apply(proxy); - if (render) { - return render(result, templateInstance.fqn); - } else { - return $("#" + templateInstance.fqn).replaceWith(result); - } - } else if (error) { - return error(); + for (_i = 0, _len = children.length; _i < _len; _i++) { + fx = children[_i]; + callList.push(createCallback(self, fx, [templateInstance, childModel, childFqn, childId])); } - }; - return self; + } + return forkJoin(callList, onChildren); }; -context["cartographer"] = new Cartographer(); -var Template; -Template = function(target, namespace) { - var conditionalCopy, copyProperties, crawl, createFqn, makeTag, self, setupEvents, subscribe, wireup; - self = this; - var eventHandlers, modelTargets, modelTargetsForCollections, templateProperties; -eventHandlers = { - click: "onclick", - dblclick: "ondblclick", - mousedown: "onmousedown", - mouseup: "onmouseup", - mouseover: "onmouseover", - mousemove: "onmousemove", - mouseout: "onmouseout", - keydown: "onkeydown", - keypress: "onkeypress", - keyup: "onkeyup", - select: "onselect", - change: "onchange", - focus: "onfocus", - blur: "onblur", - scroll: "onscroll", - resize: "onresize", - submit: "onsubmit" +createFqn = function(namespace, id, name, filterName) { + var delimiter, newId, newNs, result; + newNs = namespace || ""; + newId = id === void 0 ? "" : id; + delimiter = newNs !== "" && newId !== "" ? "." : ""; + result = "" + newNs + delimiter + newId; + return result; }; -modelTargets = { - hide: "hidden", - title: "title", - "class": "className", - value: ["value", "textContent"] +elementTemplate = function(element) { + var _ref; + return element != null ? (_ref = element.attributes[configuration.templateIdentifier]) != null ? _ref.value : void 0 : void 0; }; -modelTargetsForCollections = { - hide: "hidden", - title: "title", - value: "value", - "class": "className" +getActualValue = function(value, context) { + if (_.isFunction(value)) { + return value.call(context); + } else { + return value; + } }; -templateProperties = { - id: "id", - name: "name", - title: "title", - className: "class", - type: "type", - width: "width", - height: "height", - value: "value" +getHtmlFromList = function(list, html) { + return $(html["DIV"]({}, list)).html(); }; - conditionalCopy = function(source, target, sourceId, targetId) { - var val, x, _i, _len, _results; - val = source[sourceId]; - if (val !== void 0) { - if (_.isArray(targetId)) { - _results = []; - for (_i = 0, _len = targetId.length; _i < _len; _i++) { - x = targetId[_i]; - _results.push((target[x] = val)); - } - return _results; +getNestedValue = function(value, property) { + if (value && value[property]) { + return value[property]; + } else { + return; + } +}; +var createCallback, forkJoin, queueByArgList, queueByFunctionList; +forkJoin = function(work, done, iterations) { + var callCounter, count, fx, iteration, list, onList, total, _ref, _results; + if (!iterations) { + iterations = 1; + } + total = work.length * iterations; + list = new Array(total); + count = 0; + onList = function(index, result) { + count++; + list[index] = result; + if (count === total) { + return done(list); + } + }; + callCounter = 0; + _results = []; + for (iteration = 0, _ref = iterations - 1; 0 <= _ref ? iteration <= _ref : iteration >= _ref; 0 <= _ref ? iteration++ : iteration--) { + _results.push((function() { + var _i, _len, _results2; + _results2 = []; + for (_i = 0, _len = work.length; _i < _len; _i++) { + fx = work[_i]; + fx(function(y) { + return onList(callCounter, y); + }); + _results2.push(callCounter++); + } + return _results2; + })()); + } + return _results; +}; +queueByArgList = function(context, worker, argList) { + var count, index, list, _ref; + count = argList.length; + list = new Array(count); + for (index = 0, _ref = count - 1; 0 <= _ref ? index <= _ref : index >= _ref; 0 <= _ref ? index++ : index--) { + list[index] = createCallback(context, worker, argList[index]); + } + return list; +}; +queueByFunctionList = function(context, workers, args) { + var count, index, list, _ref; + count = workers.length; + list = new Array(count); + for (index = 0, _ref = count - 1; 0 <= _ref ? index <= _ref : index >= _ref; 0 <= _ref ? index++ : index--) { + list[index] = createCallback(context, workers[index], args); + } + return list; +}; +createCallback = function(context, callback, args) { + return function(x) { + return callback.apply(context, args.concat(x)); + }; +}; +var SourceResolver, infuser, resolver; +SourceResolver = (function() { + function SourceResolver() { + this.sources = []; + } + SourceResolver.prototype.appendSource = function(source) { + return this.sources.push(source); + }; + SourceResolver.prototype.prependSource = function(source) { + return this.sources.unshift(source); + }; + SourceResolver.prototype.resolve = function(name, onFound, notFound) { + var finder, index, self; + self = this; + index = 0; + finder = function() {}; + finder = function() { + var call; + call = self.sources[index]; + if (call) { + return call(name, function(x) { + return onFound($(x)); + }, function() { + index++; + return finder(); + }); } else { - return target[targetId] = val; + return notFound(); } + }; + return finder(); + }; + return SourceResolver; +})(); +resolver = new SourceResolver(); +resolver.appendSource(function(name, success, fail) { + var template; + template = $('#' + name + '-template'); + if (template.length > 0) { + return success(template[0]); + } else { + return fail(); + } +}); +infuser = infuser || window.infuser; +if (infuser) { + resolver.appendSource(function(name, success, fail) { + return infuser.get(name, function(x) { + return success(x); + }, function(x) { + return fail(); + }); + }); +} +var Cartographer, cartographer; +Cartographer = (function() { + function Cartographer() { + this.config = configuration; + this.templates = {}; + this.containerLookup = {}; + this.instanceCache = {}; + this.resolver = resolver; + } + Cartographer.prototype.map = function(name) { + var template; + template = new Template(name); + this.templates[name] = template; + return true; + }; + Cartographer.prototype.render = function(name, id, model, onMarkup, onError) { + var self, template, templateName; + self = this; + this.containerLookup[id] = this.templates[name]; + if (this.templates[name]) { + template = this.templates[name]; + return template.render(id, model, function(id, op, result) { + self.instanceCache[id] = result; + return onMarkup(id, op, result); + }); + } else if (model.__template__ && id) { + templateName = model.__template__; + this.map(templateName); + return this.render(templateName, id, model, onMarkup, onError); + } else { + return onError(id, "render", "No template with " + name + " has been mapped"); } }; - copyProperties = function(source, target, list) { - var x, _i, _len, _ref, _results; - _ref = _.keys(list); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - x = _ref[_i]; - _results.push(conditionalCopy(source, target, x, list[x])); + Cartographer.prototype.add = function(id, listId, model, onMarkup) { + var template; + if (this.containerLookup[id]) { + template = this.containerLookup[id]; + return template.add(listId, model, onMarkup); } - return _results; }; - crawl = function(context, root, namespace, element) { - var call, child, createChildren, fqn, id, tag; - id = element["id"]; - fqn = createFqn(namespace, id); - tag = element.tagName.toUpperCase(); - context = context || root; - if (element.children !== void 0 && element.children.length > 0) { - createChildren = (function() { - var _i, _len, _ref, _results; - _ref = element.children; + Cartographer.prototype.update = function(id, controlId, model, onMarkup) { + var template; + if (this.containerLookup[id]) { + template = this.containerLookup[id]; + return template.update(controlId, model, onMarkup); + } + }; + return Cartographer; +})(); +cartographer = new Cartographer(); +cartographer; +var Template; +Template = (function() { + function Template(name) { + var self; + this.name = name; + self = this; + this.name = name; + this.fqn = ""; + this.html = DOMBuilder.dom; + this.templates = {}; + this.deferredApplyCalls = []; + this.renderTemplate = function() {}; + this.ready = false; + this.factories = {}; + this.crawl(this.name, void 0, {}, function(x) { + var call, _i, _len, _ref, _results; + self.renderTemplate = x; + self.ready = true; + if (self.deferredApplyCalls.length > 0) { + _ref = self.deferredApplyCalls; _results = []; for (_i = 0, _len = _ref.length; _i < _len; _i++) { - child = _ref[_i]; - _results.push(crawl(context, root, fqn, child)); + call = _ref[_i]; + _results.push(call()); } return _results; - })(); - call = function(html, model, parentFqn, idx) { - var actualId, call, childElement, childFactory, collection, controls, indx, list, myFqn, val, _ref; - actualId = id === "" ? idx : id; - myFqn = createFqn(parentFqn, actualId); - val = actualId === fqn || actualId === void 0 ? model : model != null ? model[actualId] : void 0; - collection = val.length ? val : val != null ? val.items : void 0; - if (collection && collection.length) { - list = []; - childFactory = createChildren[0]; - context.template[myFqn + "_add"] = function(newIndex, newModel) { - return childFactory(html, newModel, myFqn, newIndex); + } + }); + } + Template.prototype.handleTemplate = function(template, templateId, onTemplate) { + var self; + self = this; + if (self.templates[templateId]) { + onTemplate(self.templates[templateId]); + return true; + } else { + resolver.resolve(template, function(x) { + return onTemplate(x); + }, function() { + return console.log("Could not resolve tempalte " + template); + }); + return true; + } + }; + Template.prototype.buildCreateCall = function(element, elementId, elementFqn, childrenToCreate, templates) { + var context, self, tag; + self = this; + tag = element.tagName.toUpperCase(); + context = { + tag: tag, + element: element, + elementId: elementId, + elementFqn: elementFqn, + childrenToCreate: childrenToCreate, + templates: templates + }; + return function(instance, model, fqn, id, onElement) { + return self.create(instance, model, fqn, id, context, onElement); + }; + }; + Template.prototype.crawl = function(namespace, markup, templates, onDone) { + var argList, child, childFunctionsExpected, children, continueProcessing, elementFqn, elementId, i, queue1, self, template, total, workQueue, _ref; + self = this; + if ((markup != null ? markup.length : void 0) && (!markup.nodeType || markup.nodeType === 1)) { + if (markup.length > 1) { + total = markup.length; + argList = (function() { + var _ref, _results; + _results = []; + for (i = 0, _ref = total - 1; 0 <= _ref ? i <= _ref : i >= _ref; 0 <= _ref ? i++ : i--) { + _results.push([namespace, markup[i], templates]); + } + return _results; + })(); + workQueue = queueByArgList(self, self.crawl, argList); + return forkJoin(workQueue, function(callList) { + return onDone(function(instance, model, fqn, id, onElement) { + var crawlQueue; + crawlQueue = queueByFunctionList(self, callList, [instance, model, fqn, id]); + return forkJoin(crawlQueue, function(result) { + return onElement(result); + }); + }); + }); + } else { + return self.crawl(namespace, markup[0], templates, onDone); + } + } else { + if ((markup != null ? markup.nodeType : void 0) && markup.nodeType !== 1) { + return onDone(function() { + return arguments[4](markup.nodeValue); + }); + } else { + template = markup ? template = elementTemplate(markup) : namespace; + elementId = markup != null ? (_ref = markup.attributes[configuration.elementIdentifier]) != null ? _ref.value : void 0 : void 0; + elementFqn = namespace + (elementId ? "." + elementId : ''); + if (template) { + if (!templates[template]) { + templates[template] = template; + return self.handleTemplate(template, elementFqn + "." + template, function(x) { + return self.crawl(namespace, x, templates, function(f) { + self.factories[template] = f; + return onDone(f); + }); + }); + } else { + return onDone(function() { + return self.factories[template].apply(self, [].slice.call(arguments, 0)); + }); + } + } else { + children = markup.childNodes; + childFunctionsExpected = children.length; + continueProcessing = function(contentList) { + var factory; + factory = self.buildCreateCall(markup, elementId, elementFqn, contentList, templates); + self.factories[elementFqn] = factory; + return onDone(factory); }; - for (indx = 0, _ref = collection.length - 1; 0 <= _ref ? indx <= _ref : indx >= _ref; 0 <= _ref ? indx++ : indx--) { - list.push((function() { + if (children.length > 0) { + argList = (function() { var _i, _len, _results; _results = []; - for (_i = 0, _len = createChildren.length; _i < _len; _i++) { - call = createChildren[_i]; - _results.push(call(html, collection, myFqn, indx)); + for (_i = 0, _len = children.length; _i < _len; _i++) { + child = children[_i]; + _results.push([elementFqn, child, templates]); } return _results; - })()); + })(); + queue1 = queueByArgList(self, self.crawl, argList); + return forkJoin(queue1, continueProcessing); + } else { + return continueProcessing([]); } - childElement = makeTag(context, html, tag, element, myFqn, actualId, list, root, model); - context[myFqn] = childElement; - return childElement; - } else { - controls = (function() { - var _i, _len, _results; - _results = []; - for (_i = 0, _len = createChildren.length; _i < _len; _i++) { - call = createChildren[_i]; - _results.push(call(html, val, myFqn)); - } - return _results; - })(); - childElement = makeTag(context, html, tag, element, myFqn, actualId, controls, root, model); - context[myFqn] = childElement; - return childElement; } - }; - context.template[fqn] = call; - return call; + } + } + }; + Template.prototype.handleModelTemplate = function(template, templateInstance, model, modelFqn, id, context, onElement) { + var self; + self = this; + if (self.templates[template]) { + return self.templates[template](templateInstance, model, modelFqn, id, onElement); } else { - call = function(html, model, parentFqn, idx) { - var actualId, childElement, myFqn, val; - actualId = id === "" ? idx : id; - myFqn = createFqn(parentFqn, actualId); - val = actualId === fqn ? model : model != null ? model[actualId] : void 0; - childElement = makeTag(context, html, tag, element, myFqn, actualId, val, root, model); - context[myFqn] = childElement; - return childElement; - }; - context.template[fqn] = call; - return call; + return self.handleTemplate(template, template, function(x) { + return self.crawl(context.elementFqn, x, templates, function(callback) { + self.templates[template] = callback; + return callback(templateInstance, model, modelFqn, id, onElement); + }); + }); } }; - createFqn = function(namespace, id) { - var result; - if (id === void 0 || id === "") { - result = namespace; - } else if (namespace === void 0 || namespace === "") { - result = id; + Template.prototype.create = function(templateInstance, model, modelFqn, id, context, onElement) { + var childElementCount, childElements, childModel, collection, collectionLength, elementId, idForFqn, isBound, isCollection, memberTemplate, memberValue, modelTemplate, newFqn, self, _ref; + self = this; + elementId = context.elementId; + id = elementId || id; + isBound = elementId !== void 0 && elementId !== ""; + idForFqn = isBound ? id : ""; + newFqn = createFqn(modelFqn, idForFqn, false, self.name); + if (isBound && !model[id]) { + onElement(""); + return; + } + modelTemplate = getActualValue(model.__template__, model); + memberTemplate = getActualValue((_ref = model[id]) != null ? _ref.__template__ : void 0, model); + memberValue = getActualValue(getNestedValue(model[id], "__value__") || model[id] || getNestedValue(model, "__value__"), model); + childModel = isBound ? model[id] : model; + if (modelTemplate) { + delete model.__template__; + return self.handleModelTemplate(modelTemplate, templateInstance, model, modelFqn, id, context, function(x) { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, isBound, x, model, templateInstance)); + }); + } else if (memberTemplate) { + delete model[id].__template__; + return self.handleModelTemplate(modelTemplate, templateInstance, model, modelFqn, id, context, onElement); } else { - result = "" + namespace + "." + id; + childElements = context != null ? context.childrenToCreate.slice(0) : void 0; + childElementCount = childElements.length; + if (childElementCount > 0) { + collection = getNestedValue(memberValue, "__items__") || memberValue; + collectionLength = collection ? collection.length : 0; + isCollection = collectionLength && !_.isString(collection) ? collection : void 0; + self.factories[newFqn + "_add"] = function(itemIndex, itemModel, onItem) { + newFqn = "" + newFqn + "." + itemIndex; + return createChildren(0, templateInstance, itemModel, newFqn, itemIndex, context, onItem); + }; + if (isCollection) { + return createChildren(collectionLength, templateInstance, childModel, newFqn, void 0, context, function(list) { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, context.elementId, list, model, templateInstance)); + }); + } else { + return createChildren(0, templateInstance, childModel, newFqn, id, context, function(list) { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, context.elementId, list, model, templateInstance)); + }); + } + } else { + return onElement(self.makeTag(context.tag, context.element, newFqn, id, isBound, memberValue, model, templateInstance)); + } } - return result; }; - makeTag = function(context, html, tag, template, myFqn, id, val, root, model) { - var content, element, properties, templateSource; + Template.prototype.makeTag = function(tag, originalElement, fqn, id, hasId, val, model, templateInstance) { + var alt, content, element, link, properties, self, _ref, _ref2, _ref3; + self = this; properties = {}; - templateSource = template.textContent ? template.textContent : template.value; - content = val ? val : templateSource; + content = _.isString(val) ? val : _.isArray(val) ? val || (val != null ? val[id] : void 0) : (val != null ? val[id] : void 0) || val; + content = originalElement.children.length === 0 && id === void 0 && (_.isObject(val) || _.isArray(val)) ? originalElement.textContent : content; element = {}; - if (id || id === 0) { - properties.id = id; + if (hasId) { + properties[configuration.elementIdentifier] = fqn; + } + if (originalElement["className"]) { + properties["class"] = originalElement["className"]; } - if (template) { - copyProperties(template, properties, templateProperties); + if (originalElement["type"]) { + properties["type"] = originalElement["type"]; + } + if (originalElement["value"]) { + properties["value"] = originalElement["value"]; + } + if (originalElement["id"]) { + properties["id"] = originalElement["id"]; + } + if (model != null ? (_ref = model[id]) != null ? _ref["class"] : void 0 : void 0) { + properties["class"] = model[id]["class"]; } if (tag === "INPUT") { if (!_.isObject(content)) { properties.value = content; } - element = html[tag](properties); + element = self.html[tag](properties); + } else if (tag === "IMG") { + properties = $.extend(properties, { + src: content.src || content || originalElement.src, + alt: content.alt || content || originalElement.alt, + width: content.width || originalElement.width || "", + height: content.height || originalElement.height || "" + }); + element = self.html[tag](properties); + } else if (tag === "A") { + link = ((_ref2 = model[id]) != null ? _ref2.link : void 0) || model.link || originalElement.href; + alt = ((_ref3 = model[id]) != null ? _ref3.alt : void 0) || model.alt || content || originalElement.alt; + properties = $.extend(properties, { + href: link, + alt: alt + }); + element = self.html[tag](properties, content); } else { - element = html[tag](properties, content); - } - if (model != null ? model[id] : void 0) { - if (val instanceof Array) { - copyProperties(model[id], element, modelTargetsForCollections); - } else { - copyProperties(model[id], element, modelTargets); - } + element = self.html[tag](properties, content); } - setupEvents(model != null ? model[id] : void 0, root, myFqn, element, context); return element; }; - setupEvents = function(model, root, fqn, element, context) { - var x, _i, _len, _ref, _results; - if (model) { - _ref = _.keys(eventHandlers); - _results = []; - for (_i = 0, _len = _ref.length; _i < _len; _i++) { - x = _ref[_i]; - _results.push(wireup(x, eventHandlers[x], model, root, fqn, element, context)); - } - return _results; + Template.prototype.render = function(id, originalModel, onResult) { + var model, self; + self = this; + model = $.extend(true, {}, originalModel); + if (!self.ready) { + return self.deferredApplyCalls.push(function() { + return self.render(id, model, onResult); + }); + } else { + return self.renderTemplate(id, model, id, void 0, function(x) { + var result; + result = {}; + if (!x.length) { + result = $(x)[0]; + $(result).attr(configuration.elementIdentifier, id); + } else { + result = getHtmlFromList(x, self.html); + } + return onResult(id, result, "render"); + }); } }; - subscribe = function(context, channelName) { - if (this.changeSubscription && this.changeSubscription.unsubscribe) { - this.changeSubscription.ubsubscribe(); + Template.prototype.update = function(fqn, model, onResult) { + var childKey, lastIndex, parentKey, self, templateId; + self = this; + lastIndex = fqn.lastIndexOf("."); + templateId = fqn.split('.')[0]; + parentKey = fqn.substring(0, lastIndex); + childKey = fqn.substring(lastIndex + 1); + if (self.factories[fqn]) { + return self.factories[fqn](templateId, model, parentKey, childKey, (function(dom) { + var newElement; + newElement = dom; + return onResult(fqn, newElement, "update"); + })); } - return this.changesSubscription = postal.channel(channelName).subscribe(function(m) { - var addName, childKey, control, lastIndex, newElement, parentKey; - if (m.event !== "read") { - control = context[m.key]; - lastIndex = m.key.lastIndexOf("."); - parentKey = m.key.substring(0, lastIndex); - childKey = m.key.substring(lastIndex + 1); - target = "value"; - if (childKey === "value" || !control) { - control = context[parentKey]; - target = childKey; - } - if (m.event === "wrote") { - if (control) { - if (m.info.value.isProxy) { - return $(context[m.key]).replaceWith(context.template[m.key](self.html, m.info.value.getRoot(), parentKey)); - } else { - return conditionalCopy(m.info, control, "value", modelTargets[target]); - } - } - } else if (m.event === "added") { - addName = parentKey + "_add"; - newElement = context.template[addName](childKey, m.parent); - return $(context[parentKey]).append(newElement); - } - } - }); }; - wireup = function(alias, event, model, root, fqn, element, context) { - var handler, handlerProxy; - handler = model[alias]; - if (handler) { - handlerProxy = function(x) { - return handler.apply(model, [ - root, { - id: fqn, - control: context[fqn], - event: event, - context: context, - info: x - } - ]); - }; - return element[event] = handlerProxy; - } else { - return element[event] = function(x) { - if (event === "onchange") { - x.stopPropagation(); - } - return context.eventChannel.publish({ - id: fqn, - model: model, - control: context[fqn], - event: event, - context: context, - info: x - }); - }; + Template.prototype.add = function(fqn, model, onResult) { + var addName, childKey, count, lastIndex, parentKey, self, templateId; + self = this; + lastIndex = fqn.lastIndexOf("."); + templateId = fqn.split('.')[0]; + parentKey = fqn.substring(0, lastIndex); + childKey = fqn.substring(lastIndex + 1); + addName = fqn + "_add"; + if (self.factories[addName]) { + count = $("[" + configuration.elementIdentifier + "=\"" + fqn + "\"]").children.length + 1; + return self.factories[addName](count, model, (function(dom) { + var newElement; + newElement = getHtmlFromList(dom, self.html); + return onResult(fqn, newElement, "add"); + })); } }; - this.apply = function(model) { - var fn; - fn = crawl(this, model, namespace, this.element, this.apply); - return fn(this.html, model); - }; - this.element = $(target)[0]; - this.fqn = createFqn(namespace, this.element["id"]); - this.eventChannel = postal.channel(this.fqn + "_events"); - this.html = DOMBuilder.dom; - this.template = {}; - subscribe(self, self.fqn + "_model"); - return this; -}; -})(window); \ No newline at end of file + return Template; +})(); \ No newline at end of file diff --git a/lib/cartographer.min.gz.js b/lib/cartographer.min.gz.js new file mode 100644 index 0000000..f745c8e Binary files /dev/null and b/lib/cartographer.min.gz.js differ diff --git a/lib/cartographer.min.js b/lib/cartographer.min.js index 2fdc436..4293b30 100644 --- a/lib/cartographer.min.js +++ b/lib/cartographer.min.js @@ -1 +1 @@ -(function(a){var b;b=function(){var a;return a=this,postal.channel("cartographer").subscribe(function(b){if(b.map)return a.map(b.target,b.namespace);if(b.apply)return a.apply(b.template,b.proxy,b.render,b.error)}),this.templates={},this.map=function(a,b){var d;return d=new c(a,b),this.templates[d.fqn]=d},this.apply=function(a,b,c,d){var e,f;f=this.templates[a];if(f)return e=f.apply(b),c?c(e,f.fqn):$("#"+f.fqn).replaceWith(e);if(d)return d()},a},a.cartographer=new b;var c;c=function(a,b){var c,d,e,f,g,h,i,j,k;h=this;var l,m,n,o;return l={click:"onclick",dblclick:"ondblclick",mousedown:"onmousedown",mouseup:"onmouseup",mouseover:"onmouseover",mousemove:"onmousemove",mouseout:"onmouseout",keydown:"onkeydown",keypress:"onkeypress",keyup:"onkeyup",select:"onselect",change:"onchange",focus:"onfocus",blur:"onblur",scroll:"onscroll",resize:"onresize",submit:"onsubmit"},m={hide:"hidden",title:"title","class":"className",value:["value","textContent"]},n={hide:"hidden",title:"title",value:"value","class":"className"},o={id:"id",name:"name",title:"title",className:"class",type:"type",width:"width",height:"height",value:"value"},c=function(a,b,c,d){var e,f,g,h,i;e=a[c];if(e!==void 0){if(_.isArray(d)){i=[];for(g=0,h=d.length;g0?(j=function(){var c,f,g,h;g=d.children,h=[];for(c=0,f=g.length;c=x;0<=x?t++:t--)u.push(function(){var a,b,d;d=[];for(a=0,b=j.length;a0,a||(a=1),j=e,k=c,i=d,h=[];for(o=0,r=a-1;0<=r?o<=r:o>=r;0<=r?o++:o--){e===void 0&&n&&(j=o,k=c[j],i=""+d+"."+j);for(p=0,q=l.length;p=k;0<=k?g++:g--)l.push(function(){var b,c,e;e=[];for(b=0,c=a.length;b=g;0<=g?e++:e--)f[e]=createCallback(a,b,c[e]);return f},queueByFunctionList=function(a,b,c){var d,e,f,g;d=b.length,f=new Array(d);for(e=0,g=d-1;0<=g?e<=g:e>=g;0<=g?e++:e--)f[e]=createCallback(a,b[e],c);return f},createCallback=function(a,b,c){return function(d){return b.apply(a,c.concat(d))}};var SourceResolver,infuser,resolver;SourceResolver=function(){function a(){this.sources=[]}return a.prototype.appendSource=function(a){return this.sources.push(a)},a.prototype.prependSource=function(a){return this.sources.unshift(a)},a.prototype.resolve=function(a,b,c){var d,e,f;return f=this,e=0,d=function(){},d=function(){var g;return g=f.sources[e],g?g(a,function(a){return b($(a))},function(){return e++,d()}):c()},d()},a}(),resolver=new SourceResolver,resolver.appendSource(function(a,b,c){var d;return d=$("#"+a+"-template"),d.length>0?b(d[0]):c()}),infuser=infuser||window.infuser,infuser&&resolver.appendSource(function(a,b,c){return infuser.get(a,function(a){return b(a)},function(a){return c()})});var Cartographer,cartographer;Cartographer=function(){function a(){this.config=configuration,this.templates={},this.containerLookup={},this.instanceCache={},this.resolver=resolver}return a.prototype.map=function(a){var b;return b=new Template(a),this.templates[a]=b,!0},a.prototype.render=function(a,b,c,d,e){var f,g,h;return f=this,this.containerLookup[b]=this.templates[a],this.templates[a]?(g=this.templates[a],g.render(b,c,function(a,b,c){return f.instanceCache[a]=c,d(a,b,c)})):c.__template__&&b?(h=c.__template__,this.map(h),this.render(h,b,c,d,e)):e(b,"render","No template with "+a+" has been mapped")},a.prototype.add=function(a,b,c,d){var e;if(this.containerLookup[a])return e=this.containerLookup[a],e.add(b,c,d)},a.prototype.update=function(a,b,c,d){var e;if(this.containerLookup[a])return e=this.containerLookup[a],e.update(b,c,d)},a}(),cartographer=new Cartographer,cartographer;var Template;Template=function(){function a(a){var b;this.name=a,b=this,this.name=a,this.fqn="",this.html=DOMBuilder.dom,this.templates={},this.deferredApplyCalls=[],this.renderTemplate=function(){},this.ready=!1,this.factories={},this.crawl(this.name,void 0,{},function(a){var c,d,e,f,g;b.renderTemplate=a,b.ready=!0;if(b.deferredApplyCalls.length>0){f=b.deferredApplyCalls,g=[];for(d=0,e=f.length;d1?(p=b.length,e=function(){var d,e;e=[];for(l=0,d=p-1;0<=d?l<=d:l>=d;0<=d?l++:l--)e.push([a,b[l],c]);return e}(),q=queueByArgList(n,n.crawl,e),forkJoin(q,function(a){return d(function(b,c,d,e,f){var g;return g=queueByFunctionList(n,a,[b,c,d,e]),forkJoin(g,function(a){return f(a)})})})):n.crawl(a,b[0],c,d):(b!=null?b.nodeType:void 0)&&b.nodeType!==1?d(function(){return arguments[4](b.nodeValue)}):(o=b?o=elementTemplate(b):a,k=b!=null?(r=b.attributes[configuration.elementIdentifier])!=null?r.value:void 0:void 0,j=a+(k?"."+k:""),o?c[o]?d(function(){return n.factories[o].apply(n,[].slice.call(arguments,0))}):(c[o]=o,n.handleTemplate(o,j+"."+o,function(b){return n.crawl(a,b,c,function(a){return n.factories[o]=a,d(a)})})):(h=b.childNodes,g=h.length,i=function(a){var e;return e=n.buildCreateCall(b,k,j,a,c),n.factories[j]=e,d(e)},h.length>0?(e=function(){var a,b,d;d=[];for(a=0,b=h.length;a0?(j=getNestedValue(q,"__items__")||q,k=j?j.length:0,o=k&&!_.isString(j)?j:void 0,t.factories[s+"_add"]=function(b,c,d){return s=""+s+"."+b,createChildren(0,a,c,s,b,e,d)},o?createChildren(k,a,i,s,void 0,e,function(c){return f(t.makeTag(e.tag,e.element,s,d,e.elementId,c,b,a))}):createChildren(0,a,i,s,d,e,function(c){return f(t.makeTag(e.tag,e.element,s,d,e.elementId,c,b,a))})):f(t.makeTag(e.tag,e.element,s,d,n,q,b,a)))},a.prototype.makeTag=function(a,b,c,d,e,f,g,h){var i,j,k,l,m,n,o,p,q;n=this,m={},j=_.isString(f)?f:_.isArray(f)?f||(f!=null?f[d]:void 0):(f!=null?f[d]:void 0)||f,j=b.children.length===0&&d===void 0&&(_.isObject(f)||_.isArray(f))?b.textContent:j,k={},e&&(m[configuration.elementIdentifier]=c),b.className&&(m["class"]=b.className),b.type&&(m.type=b.type),b.value&&(m.value=b.value),b.id&&(m.id=b.id);if(g!=null?(o=g[d])!=null?o["class"]:void 0:void 0)m["class"]=g[d]["class"];return a==="INPUT"?(_.isObject(j)||(m.value=j),k=n.html[a](m)):a==="IMG"?(m=$.extend(m,{src:j.src||j||b.src,alt:j.alt||j||b.alt,width:j.width||b.width||"",height:j.height||b.height||""}),k=n.html[a](m)):a==="A"?(l=((p=g[d])!=null?p.link:void 0)||g.link||b.href,i=((q=g[d])!=null?q.alt:void 0)||g.alt||j||b.alt,m=$.extend(m,{href:l,alt:i}),k=n.html[a](m,j)):k=n.html[a](m,j),k},a.prototype.render=function(a,b,c){var d,e;return e=this,d=$.extend(!0,{},b),e.ready?e.renderTemplate(a,d,a,void 0,function(b){var d;return d={},b.length?d=getHtmlFromList(b,e.html):(d=$(b)[0],$(d).attr(configuration.elementIdentifier,a)),c(a,d,"render")}):e.deferredApplyCalls.push(function(){return e.render(a,d,c)})},a.prototype.update=function(a,b,c){var d,e,f,g,h;g=this,e=a.lastIndexOf("."),h=a.split(".")[0],f=a.substring(0,e),d=a.substring(e+1);if(g.factories[a])return g.factories[a](h,b,f,d,function(b){var d;return d=b,c(a,d,"update")})},a.prototype.add=function(a,b,c){var d,e,f,g,h,i,j;i=this,g=a.lastIndexOf("."),j=a.split(".")[0],h=a.substring(0,g),e=a.substring(g+1),d=a+"_add";if(i.factories[d])return f=$("["+configuration.elementIdentifier+'="'+a+'"]').children.length+1,i.factories[d](f,b,function(b){var d;return d=getHtmlFromList(b,i.html),c(a,d,"add")})},a}() \ No newline at end of file diff --git a/lib/postal.adapter.amd.js b/lib/postal.adapter.amd.js new file mode 100644 index 0000000..2404043 --- /dev/null +++ b/lib/postal.adapter.amd.js @@ -0,0 +1,73 @@ +define(['postal', 'cartographer'], function(postal, cartographer) { + var PostalSetup, setup; +PostalSetup = (function() { + function PostalSetup() { + var self; + self = this; + postal.subscribe("cartographer", "api", function(message, envelope) { + var operation; + operation = message.operation; + return self[operation](message); + }); + } + PostalSetup.prototype.apply = function(message) { + var model, name, template; + name = message.name; + template = message.template; + model = message.model; + return cartographer.apply(name, template, model, (function(id, markup, op) { + return postal.publish("cartographer", "render." + template, { + template: template, + markup: markup, + operation: "render" + }); + }), (function(error) { + return postal.publish("cartographer", "render." + error, { + template: template, + error: error, + operation: "render" + }); + })); + }; + PostalSetup.prototype.map = function(message) { + return cartographer.map(message.name); + }; + PostalSetup.prototype.resolver = function(message) { + if (message.order === "prepend") { + return cartographer.resolver.prependSource(message.resolver); + } else { + return cartographer.resolver.appendSource(message.resolver); + } + }; + PostalSetup.prototype.add = function(message) { + var fqn, model, templateId; + templateId = message.template; + fqn = message.id; + model = message.model; + return cartographer.add(templateId, fqn, model, function(id, markup, op) { + return postal.publish("cartographer", "render.{templateId}", { + template: templateId, + parent: fqn, + markup: markup, + operation: "add" + }); + }); + }; + PostalSetup.prototype.update = function(message) { + var fqn, model, templateId; + templateId = message.template; + fqn = message.id; + model = message.model; + return cartographer.update(templateId, fqn, model, function(id, markup, op) { + return postal.publish("cartographer", "render.{templateId}", { + template: templateId, + id: fqn, + markup: markup, + operation: "update" + }); + }); + }; + return PostalSetup; +})(); +setup = new PostalSetup(); +}); \ No newline at end of file diff --git a/lib/postal.adapter.amd.min.gz.js b/lib/postal.adapter.amd.min.gz.js new file mode 100644 index 0000000..3c293eb Binary files /dev/null and b/lib/postal.adapter.amd.min.gz.js differ diff --git a/lib/postal.adapter.amd.min.js b/lib/postal.adapter.amd.min.js new file mode 100644 index 0000000..fa53314 --- /dev/null +++ b/lib/postal.adapter.amd.min.js @@ -0,0 +1 @@ +define(["postal","cartographer"],function(a,b){var c,d;c=function(){function c(){var b;b=this,a.subscribe("cartographer","api",function(a,c){var d;return d=a.operation,b[d](a)})}return c.prototype.apply=function(c){var d,e,f;return e=c.name,f=c.template,d=c.model,b.apply(e,f,d,function(b,c,d){return a.publish("cartographer","render."+f,{template:f,markup:c,operation:"render"})},function(b){return a.publish("cartographer","render."+b,{template:f,error:b,operation:"render"})})},c.prototype.map=function(a){return b.map(a.name)},c.prototype.resolver=function(a){return a.order==="prepend"?b.resolver.prependSource(a.resolver):b.resolver.appendSource(a.resolver)},c.prototype.add=function(c){var d,e,f;return f=c.template,d=c.id,e=c.model,b.add(f,d,e,function(b,c,e){return a.publish("cartographer","render.{templateId}",{template:f,parent:d,markup:c,operation:"add"})})},c.prototype.update=function(c){var d,e,f;return f=c.template,d=c.id,e=c.model,b.update(f,d,e,function(b,c,e){return a.publish("cartographer","render.{templateId}",{template:f,id:d,markup:c,operation:"update"})})},c}(),d=new c}) \ No newline at end of file diff --git a/lib/postal.adapter.js b/lib/postal.adapter.js new file mode 100644 index 0000000..4d22105 --- /dev/null +++ b/lib/postal.adapter.js @@ -0,0 +1,71 @@ +var PostalSetup, setup; +PostalSetup = (function() { + function PostalSetup() { + var self; + self = this; + postal.subscribe("cartographer", "api", function(message, envelope) { + var operation; + operation = message.operation; + return self[operation](message); + }); + } + PostalSetup.prototype.apply = function(message) { + var model, name, template; + name = message.name; + template = message.template; + model = message.model; + return cartographer.apply(name, template, model, (function(id, markup, op) { + return postal.publish("cartographer", "render." + template, { + template: template, + markup: markup, + operation: "render" + }); + }), (function(error) { + return postal.publish("cartographer", "render." + error, { + template: template, + error: error, + operation: "render" + }); + })); + }; + PostalSetup.prototype.map = function(message) { + return cartographer.map(message.name); + }; + PostalSetup.prototype.resolver = function(message) { + if (message.order === "prepend") { + return cartographer.resolver.prependSource(message.resolver); + } else { + return cartographer.resolver.appendSource(message.resolver); + } + }; + PostalSetup.prototype.add = function(message) { + var fqn, model, templateId; + templateId = message.template; + fqn = message.id; + model = message.model; + return cartographer.add(templateId, fqn, model, function(id, markup, op) { + return postal.publish("cartographer", "render.{templateId}", { + template: templateId, + parent: fqn, + markup: markup, + operation: "add" + }); + }); + }; + PostalSetup.prototype.update = function(message) { + var fqn, model, templateId; + templateId = message.template; + fqn = message.id; + model = message.model; + return cartographer.update(templateId, fqn, model, function(id, markup, op) { + return postal.publish("cartographer", "render.{templateId}", { + template: templateId, + id: fqn, + markup: markup, + operation: "update" + }); + }); + }; + return PostalSetup; +})(); +setup = new PostalSetup(); \ No newline at end of file diff --git a/lib/postal.adapter.min.gz.js b/lib/postal.adapter.min.gz.js new file mode 100644 index 0000000..c171d5a Binary files /dev/null and b/lib/postal.adapter.min.gz.js differ diff --git a/lib/postal.adapter.min.js b/lib/postal.adapter.min.js new file mode 100644 index 0000000..0336527 --- /dev/null +++ b/lib/postal.adapter.min.js @@ -0,0 +1 @@ +var PostalSetup,setup;PostalSetup=function(){function a(){var a;a=this,postal.subscribe("cartographer","api",function(b,c){var d;return d=b.operation,a[d](b)})}return a.prototype.apply=function(a){var b,c,d;return c=a.name,d=a.template,b=a.model,cartographer.apply(c,d,b,function(a,b,c){return postal.publish("cartographer","render."+d,{template:d,markup:b,operation:"render"})},function(a){return postal.publish("cartographer","render."+a,{template:d,error:a,operation:"render"})})},a.prototype.map=function(a){return cartographer.map(a.name)},a.prototype.resolver=function(a){return a.order==="prepend"?cartographer.resolver.prependSource(a.resolver):cartographer.resolver.appendSource(a.resolver)},a.prototype.add=function(a){var b,c,d;return d=a.template,b=a.id,c=a.model,cartographer.add(d,b,c,function(a,c,e){return postal.publish("cartographer","render.{templateId}",{template:d,parent:b,markup:c,operation:"add"})})},a.prototype.update=function(a){var b,c,d;return d=a.template,b=a.id,c=a.model,cartographer.update(d,b,c,function(a,c,e){return postal.publish("cartographer","render.{templateId}",{template:d,id:b,markup:c,operation:"update"})})},a}(),setup=new PostalSetup \ No newline at end of file diff --git a/pavlov b/pavlov new file mode 120000 index 0000000..a38862f --- /dev/null +++ b/pavlov @@ -0,0 +1 @@ +/src/nvm/v0.6.10/lib/node_modules/anvil.js/ext \ No newline at end of file diff --git a/spec/add-spec.coffee b/spec/add-spec.coffee new file mode 100644 index 0000000..ac05925 --- /dev/null +++ b/spec/add-spec.coffee @@ -0,0 +1,49 @@ +QUnit.specify "template add", -> + describe "template add", -> + + model = + listItems: [ + { name: "banana", qty: "all of them" }, + { name: "apple", qty: "2"}, + { name: "oranges", qty: "three"}, + ] + + iterativeTemplate = new Template 'iterative' + + expected = '
    +

    Grocery List

    +
    +
    + banana + - + all of them +
    +
    + apple + - + 2 +
    +
    + oranges + - + three +
    +
    +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + newElement = '' + + iterativeTemplate.render 'iterative', model, (id, x, op) -> + markup = scrub(x) + + iterativeTemplate.add("iterative.listItems", { name: "granola", qty: "one feedbag" }, (id, x, op) -> + newElement = scrub(x) ) + + setTimeout () -> + assert(markup).equals scrub(expected) + assert(newElement).equals scrub('
    granola - one feedbag
    ') + resume() + ) \ No newline at end of file diff --git a/spec/anchor-template-spec.coffee b/spec/anchor-template-spec.coffee new file mode 100644 index 0000000..1f9210f --- /dev/null +++ b/spec/anchor-template-spec.coffee @@ -0,0 +1,46 @@ + +QUnit.specify "anchor template", -> + describe "anchor template", -> + + model = { + top: { + __value__: "top", + link: "http://thisislame.com" + } + list: [ + { __value__: "one", link: "#one" }, + { __value__: "two", link: "#two" }, + { __value__: "three", link: "#three" } + ] + } + + anchorTemplate = new Template 'anchor' + + expected = 'top +
    +
    + one +
    +
    + two +
    +
    + three +
    +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + + anchorTemplate.render 'anchor', model, (id, x, op) -> + markup = scrub(x) + + setTimeout (() -> + assert(markup).equals scrub(expected) + resume() + ), 200 + ) +### +top
    one
    two
    three
    +top
    one
    two
    three
    " \ No newline at end of file diff --git a/spec/big-model.coffee b/spec/big-model.coffee new file mode 100644 index 0000000..e72eb14 --- /dev/null +++ b/spec/big-model.coffee @@ -0,0 +1,104 @@ +model = + listItems: [ + { name: "banana", qty: "all of them", __template__: 'iterative-item' }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "banana", qty: "all of them" }, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "apple", qty: "2"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + ] \ No newline at end of file diff --git a/spec/change-spec.coffee b/spec/change-spec.coffee new file mode 100644 index 0000000..c1d4e95 --- /dev/null +++ b/spec/change-spec.coffee @@ -0,0 +1,33 @@ + +QUnit.specify "template change", -> + describe "template change", -> + + model = + firstName: "Alex" + lastName: "Robson" + + + flatTemplate = new Template 'flat' + + expected = '
    +

    First Name

    + Alex +

    Last Name

    + Trebec +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + newElement = '' + + flatTemplate.render 'flat', model, (id, x, op) -> + markup = scrub(x) + + setTimeout () -> + flatTemplate.update('flat.lastName', { lastName: 'Trebec'}, + (id, x, op) -> newElement = scrub(x) + ) + assert(newElement).equals scrub('Trebec') + resume() + ) \ No newline at end of file diff --git a/spec/embedded-template-spec.coffee b/spec/embedded-template-spec.coffee new file mode 100644 index 0000000..cb07af9 --- /dev/null +++ b/spec/embedded-template-spec.coffee @@ -0,0 +1,25 @@ +QUnit.specify "embedded template", -> + describe "embedded template", -> + + model = + message: "Hi" + + + expected = '
    + Hi +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + $( () -> + flatTemplate = new Template 'page' + flatTemplate.render 'embedded-template', model, (id, x, op) -> + markup = scrub(x) + ) + + setTimeout (() -> + assert(markup).equals scrub(expected) + resume() + ), 10 + ) \ No newline at end of file diff --git a/spec/flat-template-spec.coffee b/spec/flat-template-spec.coffee new file mode 100644 index 0000000..f1d8e75 --- /dev/null +++ b/spec/flat-template-spec.coffee @@ -0,0 +1,31 @@ + +QUnit.specify "flat template", -> + describe "flat template", -> + + model = + firstName: "Alex" + lastName: "Robson" + + + flatTemplate = new Template 'flat' + + expected = '
    +

    First Name

    + Alex +

    Last Name

    + Robson +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + + flatTemplate.render 'flat', model, (id, x, op) -> + markup = scrub(x) + + setTimeout (() -> + assert(markup).equals scrub(expected) + resume() + ), 200 + ) + diff --git a/spec/fork-join-spec.coffee b/spec/fork-join-spec.coffee new file mode 100644 index 0000000..196bc49 --- /dev/null +++ b/spec/fork-join-spec.coffee @@ -0,0 +1,40 @@ +QUnit.specify "fork join", -> + describe "time to join the forks...", -> + + argList = [ + ['a','b','c'], + ['d','e','f'], + ['g','h','i'], + ] + + worker1 = (x, y, z, done) -> + done "#{x}.#{y}.#{z}" + + worker2 = (x, y, z, done) -> + done "#{x}-#{y}-#{z}" + + worker3 = (x, y, z, done) -> + done "#{x}+#{y}+#{z}" + + result = "" + + it "argument queues should assemble results in order", async(() -> + workQueue1 = queueByArgList this, worker1, argList + forkJoin workQueue1, (list) -> + result = "#{list[0]}.#{list[1]}.#{list[2]}" + + setTimeout () -> + assert(result).equals "a.b.c.d.e.f.g.h.i" + resume() + ) + + + it "function queues should assemble results in order", async(() -> + workQueue2 = queueByFunctionList this, [worker1, worker2, worker3], [1,2,3] + forkJoin workQueue2, (list) -> + result = "#{list[0]} #{list[1]} #{list[2]}" + + setTimeout () -> + assert(result).equals "1.2.3 1-2-3 1+2+3" + resume() + ) \ No newline at end of file diff --git a/spec/func-template-spec.coffee b/spec/func-template-spec.coffee new file mode 100644 index 0000000..900f22e --- /dev/null +++ b/spec/func-template-spec.coffee @@ -0,0 +1,32 @@ + +QUnit.specify "flat template", -> + describe "flat template", -> + + model = + firstName: "Alex" + lastName: "Robson" + fullName: () -> "#{@.firstName} #{@.lastName}" + + + flatTemplate = new Template 'func' + + expected = '
    +

    Alex Robson

    +

    First Name

    + Alex +

    Last Name

    + Robson +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + + flatTemplate.render 'func', model, (id, x, op) -> + markup = scrub(x) + + setTimeout (() -> + assert(markup).equals scrub(expected) + resume() + ), 200 + ) \ No newline at end of file diff --git a/spec/interpolated-template-spec.coffee b/spec/interpolated-template-spec.coffee new file mode 100644 index 0000000..16e6049 --- /dev/null +++ b/spec/interpolated-template-spec.coffee @@ -0,0 +1,25 @@ + +QUnit.specify "interpolation template", -> + describe "interpolation template", -> + + model = + type: "geek" + name: "Alex" + + + interpolationTemplate = new Template 'interpol' + + expected = '
    +

    O

    nce upon a time, there was a geek named Alex. +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + interpolationTemplate.render 'interpol', model, (id, x, op) -> + markup = scrub(x) + + setTimeout () -> + assert(markup).equals scrub(expected) + resume() + ) \ No newline at end of file diff --git a/spec/iterative-external-template-spec.coffee b/spec/iterative-external-template-spec.coffee new file mode 100644 index 0000000..2b5e703 --- /dev/null +++ b/spec/iterative-external-template-spec.coffee @@ -0,0 +1,46 @@ +QUnit.specify "iterative external template", -> + describe "iterative external template", -> + + model = + listItems: [ + { name: "banana", qty: "all of them", __template__: 'iterative-item' }, + { name: "apple", qty: "2", __template__: 'iterative-item'}, + { name: "oranges", qty: "three", __template__: 'iterative-item'} + ] + + iterativeExternalTemplate = new Template 'iterative-external' + + expected = '
    +

    Grocery List

    +
    +
    + banana + - + all of them +
    +
    + apple + - + 2 +
    +
    + oranges + - + three +
    +
    +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + iterativeExternalTemplate.render 'iterative2', model, (id, x, op) -> + markup = scrub(x) + + setTimeout () -> + assert(markup).equals scrub(expected) + assert(model.listItems[0].__template__).equals("iterative-item") + assert(model.listItems[1].__template__).equals("iterative-item") + assert(model.listItems[2].__template__).equals("iterative-item") + resume() + ) \ No newline at end of file diff --git a/spec/iterative-template-spec.coffee b/spec/iterative-template-spec.coffee new file mode 100644 index 0000000..cc0c934 --- /dev/null +++ b/spec/iterative-template-spec.coffee @@ -0,0 +1,45 @@ +QUnit.specify "iterative template", -> + describe "iterative template", -> + + model = + listItems: [ + { name: "banana", qty: "all of them" }, + { name: "apple", qty: "2"}, + { name: "oranges", qty: "three"}, + ] + + iterativeTemplate = new Template 'iterative' + + expected = '
    +

    Grocery List

    +
    +
    + banana + - + all of them +
    +
    + apple + - + 2 +
    +
    + oranges + - + three +
    +
    +
    ' + + + + it "should produce the correct markup", async(() -> + + markup = '' + iterativeTemplate.render 'iterative', model, (id, x, op) -> + markup = scrub(x) + + setTimeout () -> + assert(markup).equals scrub(expected) + resume() + ) \ No newline at end of file diff --git a/spec/iterative-throughput-spec.coffee b/spec/iterative-throughput-spec.coffee new file mode 100644 index 0000000..feb5787 --- /dev/null +++ b/spec/iterative-throughput-spec.coffee @@ -0,0 +1,34 @@ +QUnit.specify "iterative throughput", -> + describe "iterative throughput", -> + + model = + listItems: [ + { name: "banana", qty: "all of them" }, + { name: "apple", qty: "2"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + { name: "oranges", qty: "three"}, + ] + + iterativeTemplate = new Template 'iterative' + + started = new Date().getTime() + + it "should complete 100 iterations in under 1 second", async(() -> + total = 100 + iterations = total + + for i in [0..total] + do () -> + iterativeTemplate.render 'iterative', model, (id, x, op) -> + if iterations-- <= 0 + elapsed = new Date().getTime() - started + console.log "#{elapsed} ms" + assert( elapsed < total*10 ).isTrue() + resume() + ) \ No newline at end of file diff --git a/spec/missing-model-spec.coffee b/spec/missing-model-spec.coffee new file mode 100644 index 0000000..784b38e --- /dev/null +++ b/spec/missing-model-spec.coffee @@ -0,0 +1,26 @@ +QUnit.specify "missing model template", -> + describe "missing model template", -> + + model = + firstName: "Alex" + lastName: "Robson" + + nestedTemplate = new Template 'nested' + + expected = '
    +

    Parent

    + Alex + - + Robson +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + nestedTemplate.render 'nested', model, (id, x, op) -> + markup = scrub(x) + + setTimeout () -> + assert(markup).equals scrub(expected) + resume() + ) \ No newline at end of file diff --git a/spec/nested-template-spec.coffee b/spec/nested-template-spec.coffee new file mode 100644 index 0000000..b750772 --- /dev/null +++ b/spec/nested-template-spec.coffee @@ -0,0 +1,35 @@ +QUnit.specify "nested template", -> + describe "nested template", -> + + model = + firstName: "Alex" + lastName: "Robson" + child: + firstName: "Dexter" + lastName: "Robson" + + nestedTemplate = new Template 'nested' + + expected = '
    +

    Parent

    + Alex + - + Robson +
    +

    Child

    + Dexter + - + Robson +
    +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + nestedTemplate.render 'nested', model, (id, x, op) -> + markup = scrub(x) + + setTimeout () -> + assert(markup).equals scrub(expected) + resume() + ) \ No newline at end of file diff --git a/spec/parent-child-template-spec.coffee b/spec/parent-child-template-spec.coffee new file mode 100644 index 0000000..1dfea84 --- /dev/null +++ b/spec/parent-child-template-spec.coffee @@ -0,0 +1,30 @@ + +QUnit.specify "parent-child template", -> + describe "parent-child template", -> + + model = + parentValue: "This is the parent value!" + childValue: "This is the child value!" + + parentChildTemplate = new Template 'parent-child' + + expected = '
    +

    Parent Template

    +
    This is the parent value!
    +
    +

    Child Template

    +
    This is the child value!
    +
    +
    ' + + it "should produce the correct markup", async(() -> + + markup = '' + parentChildTemplate.render 'parentChildTest', model, (id, x, op) -> + markup = scrub(x) + + setTimeout () -> + assert(markup).equals scrub(expected) + resume() + ) + diff --git a/spec/qunit-1.3.0pre.css b/spec/qunit-1.3.0pre.css new file mode 100644 index 0000000..d90656a --- /dev/null +++ b/spec/qunit-1.3.0pre.css @@ -0,0 +1,228 @@ +/** + * QUnit v1.3.0pre - A JavaScript Unit Testing Framework + * + * http://docs.jquery.com/QUnit + * + * Copyright (c) 2011 John Resig, Jörn Zaefferer + * Dual licensed under the MIT (MIT-LICENSE.txt) + * or GPL (GPL-LICENSE.txt) licenses. + * Pulled Live from Git Sat Feb 11 19:20:01 UTC 2012 + * Last Commit: 0712230bb203c262211649b32bd712ec7df5f857 + */ + +/** Font Family and Sizes */ + +#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult { + font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif; +} + +#qunit-testrunner-toolbar, #qunit-userAgent, #qunit-testresult, #qunit-tests li { font-size: small; } +#qunit-tests { font-size: smaller; } + + +/** Resets */ + +#qunit-tests, #qunit-tests ol, #qunit-header, #qunit-banner, #qunit-userAgent, #qunit-testresult { + margin: 0; + padding: 0; +} + + +/** Header */ + +#qunit-header { + padding: 0.5em 0 0.5em 1em; + + color: #8699a4; + background-color: #0d3349; + + font-size: 1.5em; + line-height: 1em; + font-weight: normal; + + border-radius: 15px 15px 0 0; + -moz-border-radius: 15px 15px 0 0; + -webkit-border-top-right-radius: 15px; + -webkit-border-top-left-radius: 15px; +} + +#qunit-header a { + text-decoration: none; + color: #c2ccd1; +} + +#qunit-header a:hover, +#qunit-header a:focus { + color: #fff; +} + +#qunit-banner { + height: 5px; +} + +#qunit-testrunner-toolbar { + padding: 0.5em 0 0.5em 2em; + color: #5E740B; + background-color: #eee; +} + +#qunit-userAgent { + padding: 0.5em 0 0.5em 2.5em; + background-color: #2b81af; + color: #fff; + text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px; +} + + +/** Tests: Pass/Fail */ + +#qunit-tests { + list-style-position: inside; +} + +#qunit-tests li { + padding: 0.4em 0.5em 0.4em 2.5em; + border-bottom: 1px solid #fff; + list-style-position: inside; +} + +#qunit-tests.hidepass li.pass, #qunit-tests.hidepass li.running { + display: none; +} + +#qunit-tests li strong { + cursor: pointer; +} + +#qunit-tests li a { + padding: 0.5em; + color: #c2ccd1; + text-decoration: none; +} +#qunit-tests li a:hover, +#qunit-tests li a:focus { + color: #000; +} + +#qunit-tests ol { + margin-top: 0.5em; + padding: 0.5em; + + background-color: #fff; + + border-radius: 15px; + -moz-border-radius: 15px; + -webkit-border-radius: 15px; + + box-shadow: inset 0px 2px 13px #999; + -moz-box-shadow: inset 0px 2px 13px #999; + -webkit-box-shadow: inset 0px 2px 13px #999; +} + +#qunit-tests table { + border-collapse: collapse; + margin-top: .2em; +} + +#qunit-tests th { + text-align: right; + vertical-align: top; + padding: 0 .5em 0 0; +} + +#qunit-tests td { + vertical-align: top; +} + +#qunit-tests pre { + margin: 0; + white-space: pre-wrap; + word-wrap: break-word; +} + +#qunit-tests del { + background-color: #e0f2be; + color: #374e0c; + text-decoration: none; +} + +#qunit-tests ins { + background-color: #ffcaca; + color: #500; + text-decoration: none; +} + +/*** Test Counts */ + +#qunit-tests b.counts { color: black; } +#qunit-tests b.passed { color: #5E740B; } +#qunit-tests b.failed { color: #710909; } + +#qunit-tests li li { + margin: 0.5em; + padding: 0.4em 0.5em 0.4em 0.5em; + background-color: #fff; + border-bottom: none; + list-style-position: inside; +} + +/*** Passing Styles */ + +#qunit-tests li li.pass { + color: #5E740B; + background-color: #fff; + border-left: 26px solid #C6E746; +} + +#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; } +#qunit-tests .pass .test-name { color: #366097; } + +#qunit-tests .pass .test-actual, +#qunit-tests .pass .test-expected { color: #999999; } + +#qunit-banner.qunit-pass { background-color: #C6E746; } + +/*** Failing Styles */ + +#qunit-tests li li.fail { + color: #710909; + background-color: #fff; + border-left: 26px solid #EE5757; + white-space: pre; +} + +#qunit-tests > li:last-child { + border-radius: 0 0 15px 15px; + -moz-border-radius: 0 0 15px 15px; + -webkit-border-bottom-right-radius: 15px; + -webkit-border-bottom-left-radius: 15px; +} + +#qunit-tests .fail { color: #000000; background-color: #EE5757; } +#qunit-tests .fail .test-name, +#qunit-tests .fail .module-name { color: #000000; } + +#qunit-tests .fail .test-actual { color: #EE5757; } +#qunit-tests .fail .test-expected { color: green; } + +#qunit-banner.qunit-fail { background-color: #EE5757; } + + +/** Result */ + +#qunit-testresult { + padding: 0.5em 0.5em 0.5em 2.5em; + + color: #2b81af; + background-color: #D2E0E6; + + border-bottom: 1px solid white; +} + +/** Fixture */ + +#qunit-fixture { + position: absolute; + top: -10000px; + left: -10000px; +} \ No newline at end of file diff --git a/spec/rootless-template-spec.coffee b/spec/rootless-template-spec.coffee new file mode 100644 index 0000000..b3ed483 --- /dev/null +++ b/spec/rootless-template-spec.coffee @@ -0,0 +1,28 @@ + +QUnit.specify "rootless template", -> + describe "rootless template", -> + + model = + firstName: "Alex" + lastName: "Robson" + + rootlessTemplate = new Template 'rootless' + + expected = '

    First Name

    + Alex +

    Last Name

    + Robson' + + it "should produce the correct markup", async(() -> + + markup = '' + + rootlessTemplate.render 'flat', model, (id, x, op) -> + markup = scrub(x) + + setTimeout (() -> + assert(markup).equals scrub(expected) + resume() + ), 200 + ) + diff --git a/spec/template-source.coffee b/spec/template-source.coffee new file mode 100644 index 0000000..0eb8133 --- /dev/null +++ b/spec/template-source.coffee @@ -0,0 +1,73 @@ +templates = + anchor: ' +
    +
    + +
    +
    ', + flat: '
    +

    First Name

    + +

    Last Name

    + +
    ', + rootless: '

    First Name

    + +

    Last Name

    + ', + func: '
    +

    +

    First Name

    + +

    Last Name

    + +
    ', + iterative: '
    +

    Grocery List

    +
    +
    + - +
    +
    +
    ', + nested: '
    +

    Parent

    + - + +
    +

    Child

    + - + +
    +
    ', + 'parent-child': '
    +

    Parent Template

    +
    +
    +
    ', + child: '
    +

    Child Template

    +
    +
    ', + 'iterative-external': '
    +

    Grocery List

    +
    +
    +
    +
    ', + 'iterative-item': ' - ', + 'interpol': '

    O

    nce upon a time, there was a named .
    ' + + +window.scrub = (x) -> + $('
    ').html(x).html().replace(/\s/g, "") + +resolver.prependSource( + (name, success, fail) -> + if templates[name] + success templates[name] + else + fail() +) + +### diff --git a/spec/test-runner.html b/spec/test-runner.html new file mode 100644 index 0000000..433985a --- /dev/null +++ b/spec/test-runner.html @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    +

    +
    +

    +
      + + + + + \ No newline at end of file diff --git a/spec/test.html b/spec/test.html new file mode 100644 index 0000000..cafa67a --- /dev/null +++ b/spec/test.html @@ -0,0 +1,415 @@ + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/adapter.amd.coffee b/src/adapter.amd.coffee new file mode 100644 index 0000000..7550360 --- /dev/null +++ b/src/adapter.amd.coffee @@ -0,0 +1,2 @@ +define ['postal', 'cartographer'], (postal, cartographer) -> + ###import "postal.coffee" ### \ No newline at end of file diff --git a/src/adapter.coffee b/src/adapter.coffee new file mode 100644 index 0000000..98d4223 --- /dev/null +++ b/src/adapter.coffee @@ -0,0 +1 @@ +###import "postal.coffee" ### \ No newline at end of file diff --git a/src/amd.coffee b/src/amd.coffee new file mode 100644 index 0000000..2f63b43 --- /dev/null +++ b/src/amd.coffee @@ -0,0 +1,3 @@ +define ['jquery', 'underscore', 'infuser', 'DOMBuilder'], ($, _, infuser) -> + ###import "cartographer.coffee" ### + return cartographer; \ No newline at end of file diff --git a/src/browser.coffee b/src/browser.coffee new file mode 100644 index 0000000..c01bba2 --- /dev/null +++ b/src/browser.coffee @@ -0,0 +1 @@ +###import "cartographer.coffee" ### \ No newline at end of file diff --git a/src/cartographer.coffee b/src/cartographer.coffee index 8ba7708..e0b8d2b 100644 --- a/src/cartographer.coffee +++ b/src/cartographer.coffee @@ -1,9 +1,5 @@ -### - cartographer - author: Alex Robson <@A_Robson> - License: MIT ( http://www.opensource.org/licenses/mit-license ) - Version: 0.1.0 -### - -###import "main.coffee" #### -###import "template.coffee" ### \ No newline at end of file + ###import "local.coffee" ### + ###import "forkJoin.coffee" ### + ###import "sourceResolver.coffee" ### + ###import "main.coffee" #### + ###import "template.coffee" ### \ No newline at end of file diff --git a/src/forkJoin.coffee b/src/forkJoin.coffee new file mode 100644 index 0000000..38ab8f2 --- /dev/null +++ b/src/forkJoin.coffee @@ -0,0 +1,36 @@ + +forkJoin = (work, done, iterations) -> + if not iterations + iterations = 1 + total = work.length * iterations + list = new Array(total) + count = 0 + onList = (index, result) -> + count++ + list[index] = result + if count == total + done list + + callCounter = 0 + for iteration in [0..iterations-1] + for fx in work + fx ( y ) -> + onList callCounter, y + callCounter++ + +queueByArgList = (context, worker, argList) -> + count = argList.length + list = new Array(count) + for index in [0..count-1] + list[index] = createCallback context, worker, argList[index] + list + +queueByFunctionList = (context, workers, args) -> + count = workers.length + list = new Array(count) + for index in [0..count-1] + list[index] = createCallback context, workers[index], args + list + +createCallback = (context, callback, args) -> + (x) -> callback.apply(context, args.concat(x) ) \ No newline at end of file diff --git a/src/lists.coffee b/src/lists.coffee deleted file mode 100644 index c3fb75c..0000000 --- a/src/lists.coffee +++ /dev/null @@ -1,40 +0,0 @@ - eventHandlers = - click: "onclick" - dblclick: "ondblclick" - mousedown: "onmousedown" - mouseup: "onmouseup" - mouseover: "onmouseover" - mousemove: "onmousemove" - mouseout: "onmouseout" - keydown: "onkeydown" - keypress: "onkeypress" - keyup: "onkeyup" - select: "onselect" - change: "onchange" - focus: "onfocus" - blur: "onblur" - scroll: "onscroll" - resize: "onresize" - submit: "onsubmit" - - modelTargets = - hide: "hidden" - title: "title" - class: "className" - value: ["value", "textContent"] - - modelTargetsForCollections = - hide: "hidden" - title: "title" - value: "value" - class: "className" - - templateProperties = - id: "id" - name: "name" - title: "title" - className: "class" - type: "type" - width: "width" - height: "height" - value: "value" \ No newline at end of file diff --git a/src/local.coffee b/src/local.coffee new file mode 100644 index 0000000..2c1165a --- /dev/null +++ b/src/local.coffee @@ -0,0 +1,41 @@ +configuration = + elementIdentifier: 'data-id' + templateIdentifier: 'data-template' + +createChildren = ( iterations, templateInstance, model, modelFqn, id, context, onChildren) -> + children = context.childrenToCreate + isCollection = iterations > 0 + if not iterations + iterations = 1 + childId = id + childModel = model + childFqn = modelFqn + + callList = [] + for iteration in [0..iterations-1] + if id == undefined and isCollection + childId = iteration + childModel = model[childId] + childFqn = "#{modelFqn}.#{childId}" + for fx in children + callList.push createCallback self, fx, [templateInstance, childModel, childFqn, childId] + forkJoin callList, onChildren + +createFqn = ( namespace, id, name, filterName ) -> + newNs = namespace || "" + newId = if id == undefined then "" else id + delimiter = if newNs != "" and newId != "" then "." else "" + result = "#{newNs}#{delimiter}#{newId}" + result + +elementTemplate = ( element ) -> + element?.attributes[configuration.templateIdentifier]?.value + +getActualValue = (value, context) -> + if _.isFunction value then value.call(context) else value + +getHtmlFromList = (list, html) -> + $(html["DIV"]({}, list)).html() + +getNestedValue = (value, property) -> + if value and value[property] then value[property] else undefined \ No newline at end of file diff --git a/src/main.coffee b/src/main.coffee index b899dc1..6606e46 100644 --- a/src/main.coffee +++ b/src/main.coffee @@ -1,29 +1,42 @@ -Cartographer = () -> - self = this +class Cartographer - postal.channel("cartographer").subscribe (m) -> - if m.map - self.map m.target, m.namespace - else if m.apply - self.apply m.template, m.proxy, m.render, m.error + constructor: -> + @config = configuration + @templates = {} + @containerLookup = {} + @instanceCache = {} + @resolver = resolver - @templates = {} + map: ( name ) -> + template = new Template name + @templates[name] = template + true - @map = ( target, namespace ) -> - template = new Template target, namespace - @templates[template.fqn] = template + render: ( name, id, model, onMarkup, onError ) -> + self = this + @containerLookup[id] = @templates[name] + if @templates[name] + template = @templates[name] + template.render id, model, (id, op, result) -> + self.instanceCache[id] = result + onMarkup id, op, result + else if model.__template__ and id + templateName = model.__template__ + @map templateName + @render templateName, id, model, onMarkup, onError + else + onError id, "render", "No template with #{name} has been mapped" - @apply = ( template, proxy, render, error ) -> - templateInstance = @templates[template] - if templateInstance - result = templateInstance.apply proxy - if render - render( result, templateInstance.fqn ) - else - $("#" + templateInstance.fqn ).replaceWith( result ) - else if error - error() + add: (id, listId, model, onMarkup) -> + if @containerLookup[id] + template = @containerLookup[id] + template.add listId, model, onMarkup - self + update: (id, controlId, model, onMarkup) -> + if @containerLookup[id] + template = @containerLookup[id] + template.update controlId, model, onMarkup -context["cartographer"] = new Cartographer() \ No newline at end of file +cartographer = new Cartographer() + +cartographer \ No newline at end of file diff --git a/src/postal.coffee b/src/postal.coffee new file mode 100644 index 0000000..383aa72 --- /dev/null +++ b/src/postal.coffee @@ -0,0 +1,57 @@ +class PostalSetup + constructor: -> + self = this + postal.subscribe "cartographer", "api", (message, envelope) -> + operation = message.operation + self[operation](message) + + apply: (message) -> + name = message.name + template = message.template + model = message.model + cartographer.apply name, template, model, ( + (id, markup, op) -> + postal.publish "cartographer", "render.#{template}", + template: template + markup: markup + operation: "render" + ), + ( (error) -> + postal.publish "cartographer", "render.#{error}", + template: template + error: error + operation: "render" + ) + + map: (message) -> + cartographer.map message.name + + resolver: (message) -> + if message.order == "prepend" + cartographer.resolver.prependSource message.resolver + else + cartographer.resolver.appendSource message.resolver + + add: (message) -> + templateId = message.template + fqn = message.id + model = message.model + cartographer.add templateId, fqn, model, (id,markup, op) -> + postal.publish "cartographer", "render.{templateId}", + template: templateId + parent: fqn + markup: markup + operation: "add" + + update: (message) -> + templateId = message.template + fqn = message.id + model = message.model + cartographer.update templateId, fqn, model, (id, markup, op) -> + postal.publish "cartographer", "render.{templateId}", + template: templateId + id: fqn + markup: markup + operation: "update" + +setup = new PostalSetup() \ No newline at end of file diff --git a/src/sourceResolver.coffee b/src/sourceResolver.coffee new file mode 100644 index 0000000..88972a7 --- /dev/null +++ b/src/sourceResolver.coffee @@ -0,0 +1,52 @@ +class SourceResolver + + constructor: -> + @sources = [] + + appendSource: (source) -> + @sources.push source + + prependSource: (source) -> + @sources.unshift source + + resolve: (name, onFound, notFound) -> + self = this + # iterate through sources until + # 1 - the finder returns a template and calls onFound with result + # 2 - all sources are exhausted + index = 0 + finder = -> # this list is required, DO NOT REMOVE + finder = () -> + call = self.sources[index] + if call + call( + name, + (x) -> + onFound $(x), + () -> + index++ + finder() + ) + else + notFound() + finder() + +resolver = new SourceResolver() + +# add a page check method as the first source +resolver.appendSource (name, success, fail) -> + template = $( '#' + name + '-template' ) + if template.length > 0 + success template[0] + else + fail() + +infuser = infuser || window.infuser + +# if infuser is present, add it as a source +if infuser + resolver.appendSource (name, success, fail) -> + infuser.get name, + (x) -> success x, + (x) -> + fail() \ No newline at end of file diff --git a/src/template.coffee b/src/template.coffee index 0472dcb..b24231b 100644 --- a/src/template.coffee +++ b/src/template.coffee @@ -1,157 +1,279 @@ -Template = (target, namespace) -> +class Template + + constructor: (@name) -> self = this + @name = name + @fqn = "" + @html = DOMBuilder.dom + @templates = {} + @deferredApplyCalls = [] + @renderTemplate = () -> + @ready = false + @factories = {} - ###import "lists.coffee" #### + @crawl @name, undefined, {}, (x) -> + self.renderTemplate = x + self.ready = true + if self.deferredApplyCalls.length > 0 + for call in self.deferredApplyCalls + call() - conditionalCopy = ( source, target, sourceId, targetId ) -> - val = source[sourceId] - if val != undefined - if _.isArray(targetId) - ( target[x] = val ) for x in targetId - else - target[targetId] = val - - copyProperties = ( source, target, list ) -> - ( conditionalCopy source, target, x, list[x] ) for x in _.keys(list) - - crawl = ( context, root, namespace, element ) -> - id = element["id"] - fqn = createFqn namespace, id - tag = element.tagName.toUpperCase() - context = context or root - - if element.children != undefined and element.children.length > 0 - createChildren = ( crawl( context, root, fqn, child ) for child in element.children ) - - call = ( html, model, parentFqn, idx ) -> - actualId = if id == "" then idx else id - myFqn = createFqn parentFqn, actualId - val = if actualId == fqn or actualId == undefined then model else model?[actualId] - #collection = if val instanceof ArrayWrapper then val else val?.items - collection = if val.length then val else val?.items - #if collection and collection instanceof ArrayWrapper - if collection and collection.length - list = [] - childFactory = createChildren[0] - context.template[myFqn + "_add"] = ( newIndex, newModel ) -> - childFactory( html, newModel, myFqn, newIndex ) - - for indx in [0..collection.length-1] - list.push ( call( html, collection, myFqn, indx ) for call in createChildren ) - - childElement = makeTag( context, html, tag, element, myFqn, actualId, list, root, model ) - context[myFqn] = childElement - childElement - else - controls = ( call( html, val, myFqn ) for call in createChildren ) - childElement = makeTag( context, html, tag, element, myFqn, actualId, controls, root, model ) - context[myFqn] = childElement - childElement - - context.template[fqn] = call - call - else - call = ( html, model, parentFqn, idx ) -> - actualId = if id == "" then idx else id - myFqn = createFqn parentFqn, actualId - val = if actualId == fqn then model else model?[actualId] - childElement = makeTag( context, html, tag, element, myFqn, actualId, val, root, model ) - context[myFqn] = childElement - childElement - - context.template[fqn] = call - call - - createFqn = ( namespace, id ) -> - if id == undefined or id == "" - result = namespace - else if namespace == undefined or namespace == "" - result = id - else - result = "#{namespace}.#{id}" - result + handleTemplate: ( template, templateId, onTemplate ) -> + self = this + if self.templates[templateId] + onTemplate self.templates[templateId] + true + else + resolver.resolve( + template, + (x) -> + onTemplate(x) + , + () -> console.log "Could not resolve tempalte #{template}") + true - makeTag = ( context, html, tag, template, myFqn, id, val, root, model ) -> - properties = {} - templateSource = if template.textContent then template.textContent else template.value - content = if val then val else templateSource - element = {} - if id or id == 0 - properties.id = id + buildCreateCall: ( element, elementId, elementFqn, childrenToCreate, templates ) -> + self = this + tag = element.tagName.toUpperCase() + context = + tag: tag, + element: element, + elementId: elementId, + elementFqn: elementFqn, + childrenToCreate: childrenToCreate, + templates: templates - if template - copyProperties template, properties, templateProperties + return ( instance, model, fqn, id, onElement ) -> + self.create( instance, model, fqn, id, context, onElement ) + + crawl: ( namespace, markup, templates, onDone ) -> + self = this + if markup?.length and ( not markup.nodeType || markup.nodeType == 1 ) + if markup.length > 1 + total = markup.length + argList = ([namespace, markup[i], templates] for i in [0..total-1]) + workQueue = queueByArgList(self, self.crawl, argList) + forkJoin workQueue, (callList) -> + onDone (instance, model, fqn, id, onElement) -> + crawlQueue = queueByFunctionList self, callList, [instance, model, fqn, id] + forkJoin crawlQueue, (result) -> onElement result - if tag == "INPUT" - if not _.isObject content - properties.value = content - element = html[tag]( properties ) + else self.crawl namespace, markup[0], templates, onDone + else + if markup?.nodeType and markup.nodeType != 1 + onDone( () -> + arguments[4] markup.nodeValue + ) + else + template = if markup then template = elementTemplate markup else namespace + elementId = markup?.attributes[configuration.elementIdentifier]?.value + elementFqn = namespace + if elementId then ".#{elementId}" else '' + + if template + if not templates[template] + templates[template] = template + self.handleTemplate( + template, + elementFqn + "." + template, + (x) -> self.crawl namespace, x, templates, (f) -> + self.factories[template] = f + onDone f + ) + else + onDone () -> self.factories[template].apply(self, [].slice.call(arguments,0)) else - element = html[tag]( properties, content ) + children = markup.childNodes + childFunctionsExpected = children.length - if model?[id] - if val instanceof Array - copyProperties model[id], element, modelTargetsForCollections + continueProcessing = (contentList) -> + factory = self.buildCreateCall markup, elementId, elementFqn, contentList, templates + self.factories[elementFqn] = factory + onDone( factory ) + + if children.length > 0 + argList = ( [elementFqn, child, templates] for child in children ) + queue1 = queueByArgList self, self.crawl, argList + forkJoin queue1, continueProcessing else - copyProperties model[id], element, modelTargets - setupEvents( model?[id], root, myFqn, element, context ) - element - - setupEvents = ( model, root, fqn, element, context ) -> - if model - (wireup x, eventHandlers[x], model, root, fqn, element, context ) for x in _.keys(eventHandlers) - - subscribe = ( context, channelName ) -> - if @changeSubscription and @changeSubscription.unsubscribe - @changeSubscription.ubsubscribe(); - @changesSubscription = postal.channel( channelName ).subscribe (m) -> - if m.event != "read" - control = context[m.key] - - lastIndex = m.key.lastIndexOf "." - parentKey = m.key.substring 0, lastIndex - childKey = m.key.substring ( lastIndex + 1 ) - target = "value" - - if childKey == "value" or not control - control = context[parentKey] - target = childKey - - if m.event == "wrote" - if control - if m.info.value.isProxy - $(context[m.key]).replaceWith context.template[m.key]( self.html, m.info.value.getRoot(), parentKey ) - else - conditionalCopy m.info, control, "value", modelTargets[target] - - else if m.event == "added" - addName = parentKey + "_add" - newElement = context.template[addName]( childKey, m.parent ) - $(context[parentKey]).append newElement - - wireup = ( alias, event, model, root, fqn, element, context ) -> - handler = model[alias] - if handler - handlerProxy = (x) -> handler.apply( - model, - [root, { id: fqn, control: context[fqn], event: event, context: context, info: x } ] - ) - element[event] = handlerProxy + continueProcessing [] + + handleModelTemplate: (template, templateInstance, model, modelFqn, id, context, onElement) -> + self = this + if self.templates[template] + self.templates[template]( templateInstance, model, modelFqn, id, onElement ) + else + self.handleTemplate(template, template, (x) -> + self.crawl context.elementFqn, x, templates, ( callback ) -> + self.templates[template] = callback + callback templateInstance, model, modelFqn, id, onElement + ) + + create: ( templateInstance, model, modelFqn, id, context, onElement ) -> + self = this + elementId = context.elementId + id = elementId || id #set id to the current position or the dom position + # is this bound to the model or just structural + isBound = elementId != undefined and elementId != "" + idForFqn = if isBound then id else "" + newFqn = createFqn modelFqn, idForFqn, false, self.name + + # if the element is bound but no model is present, skip this render + if isBound and not model[id] + onElement "" + return + + # does this poisition of the model have a template? + modelTemplate = getActualValue model.__template__, model + + # does the member we're on have a template? + memberTemplate = getActualValue model[id]?.__template__, model + memberValue = getActualValue( + getNestedValue(model[id], "__value__" ) || + model[id] || + getNestedValue(model, "__value__"), + model) + + # used to advance the model to the next level + childModel = if isBound then model[id] else model + + # if there is a template on the model itself + # then we parse this element but replace it's children + if modelTemplate + delete model.__template__ + self.handleModelTemplate modelTemplate, templateInstance, model, modelFqn, id, context, (x) -> + onElement (self.makeTag context.tag, context.element, newFqn, id, isBound, x, model, templateInstance) + + # if there is a template on the member + # then we replace/insert an element at the current location + else if memberTemplate + delete model[id].__template__ + self.handleModelTemplate modelTemplate, templateInstance, model, modelFqn, id, context, onElement + + #if not memberTemplate + else + childElements = context?.childrenToCreate.slice(0) + childElementCount = childElements.length + # are there elements to create under this one? + if childElementCount > 0 + + # if the value has items + collection = getNestedValue(memberValue, "__items__") || memberValue + collectionLength = if collection then collection.length else 0 + isCollection = if collectionLength and not _.isString(collection) then collection + + self.factories[newFqn+"_add"] = (itemIndex, itemModel, onItem) -> + newFqn = "#{newFqn}.#{itemIndex}" + createChildren 0, templateInstance, itemModel, newFqn, itemIndex, context, onItem + + if isCollection + createChildren collectionLength, templateInstance, childModel, newFqn, undefined, context, (list) -> + onElement self.makeTag context.tag, context.element, newFqn, id, context.elementId, list, model, templateInstance + + else # the current value is not a collection, but there are still child elements + createChildren 0, templateInstance, childModel, newFqn, id, context, (list) -> + onElement self.makeTag context.tag, context.element, newFqn, id, context.elementId, list, model, templateInstance + + else # this element has no children, it only holds the value + onElement self.makeTag( context.tag, context.element, newFqn, id, isBound, memberValue, model, templateInstance ) + + makeTag: (tag, originalElement, fqn, id, hasId, val, model, templateInstance ) -> + self = this + properties = {} + content = + if _.isString(val) + val + else if _.isArray(val) + val || val?[id] else - element[event] = (x) -> - if event == "onchange" - x.stopPropagation() - context.eventChannel.publish( { id: fqn, model: model, control: context[fqn], event: event, context: context, info: x } ) - - @apply = (model) -> - fn = crawl this, model, namespace, @element, @apply - fn @html, model - @element = $(target)[0] - @fqn = createFqn namespace, @element["id"] - @eventChannel = postal.channel(@fqn + "_events") - @html = DOMBuilder.dom - @template = {} + val?[id] || val + content = if originalElement.children.length == 0 and id == undefined and (_.isObject(val) or _.isArray(val)) then originalElement.textContent else content + element = {} + + if hasId + properties[configuration.elementIdentifier] = fqn + if originalElement["className"] + properties["class"] = originalElement["className"] + if originalElement["type"] + properties["type"] = originalElement["type"] + if originalElement["value"] + properties["value"] = originalElement["value"] + if originalElement["id"] + properties["id"] = originalElement["id"] + if model?[id]?.class + properties["class"] = model[id].class - subscribe( self, self.fqn + "_model" ) + if tag == "INPUT" + if not _.isObject content + properties.value = content + element = self.html[tag]( properties ) + else if tag == "IMG" + properties = $.extend(properties, { + src: content.src || content || originalElement.src, + alt: content.alt || content || originalElement.alt, + width: content.width || originalElement.width || "", + height: content.height || originalElement.height || "" + }) + element = self.html[tag]( properties ) + else if tag == "A" + link = model[id]?.link || model.link || originalElement.href + alt = model[id]?.alt || model.alt || content || originalElement.alt + properties = $.extend(properties, { + href: link, + alt: alt + }) + element = self.html[tag]( properties, content ) + else + element = self.html[tag]( properties, content ) + element + + render: (id, originalModel, onResult) -> + self = this + model = $.extend(true, {}, originalModel); + if not self.ready + self.deferredApplyCalls.push( () -> self.render(id, model, onResult ) ); + else + self.renderTemplate( id, model, id, undefined, (x) -> + result = {} + if not x.length + result = $(x)[0] + $(result).attr(configuration.elementIdentifier, id) + else + result = getHtmlFromList(x, self.html) + onResult id, result, "render" + ) + + update: (fqn, model, onResult) -> + self = this + lastIndex = fqn.lastIndexOf "." + templateId = fqn.split('.')[0] + parentKey = fqn.substring 0, lastIndex + childKey = fqn.substring ( lastIndex + 1 ) + + if self.factories[fqn] + self.factories[fqn]( + templateId + model, + parentKey, + childKey, + ((dom) -> + newElement = dom + onResult fqn, newElement, "update") + ) + + add: (fqn, model, onResult) -> + self = this + lastIndex = fqn.lastIndexOf "." + templateId = fqn.split('.')[0] + parentKey = fqn.substring 0, lastIndex + childKey = fqn.substring ( lastIndex + 1 ) - this \ No newline at end of file + addName = fqn + "_add" + if self.factories[addName] + count = $("[#{configuration.elementIdentifier}=\"#{fqn}\"]").children.length + 1 + self.factories[addName]( + count, + model, + ((dom) -> + newElement = getHtmlFromList(dom, self.html) + onResult fqn, newElement, "add") + )