This commit is contained in:
Eryx
2013-11-22 10:55:00 +08:00
227 changed files with 160691 additions and 76 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+144
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
+144
View File
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+2 -2
View File
@@ -1,7 +1,7 @@
{
"name": "F2",
"description": "An open framework for the financial services industry.",
"version": "1.3.0",
"description": "An open and free web integration framework for the financial services industry.",
"version": "1.3.2",
"keywords": [
"openf2"
],
File diff suppressed because one or more lines are too long
@@ -0,0 +1,632 @@
// Backbone.Validation v0.8.2
//
// Copyright (c) 2011-2013 Thomas Pedersen
// Distributed under MIT License
//
// Documentation and full license available at:
// http://thedersen.com/projects/backbone-validation
(function (factory) {
if (typeof exports === 'object') {
module.exports = factory(require('backbone'), require('underscore'));
} else if (typeof define === 'function' && define.amd) {
define(['backbone', 'underscore'], factory);
}
}(function (Backbone, _) {
Backbone.Validation = (function(_){
'use strict';
// Default options
// ---------------
var defaultOptions = {
forceUpdate: false,
selector: 'name',
labelFormatter: 'sentenceCase',
valid: Function.prototype,
invalid: Function.prototype
};
// Helper functions
// ----------------
// Formatting functions used for formatting error messages
var formatFunctions = {
// Uses the configured label formatter to format the attribute name
// to make it more readable for the user
formatLabel: function(attrName, model) {
return defaultLabelFormatters[defaultOptions.labelFormatter](attrName, model);
},
// Replaces nummeric placeholders like {0} in a string with arguments
// passed to the function
format: function() {
var args = Array.prototype.slice.call(arguments),
text = args.shift();
return text.replace(/\{(\d+)\}/g, function(match, number) {
return typeof args[number] !== 'undefined' ? args[number] : match;
});
}
};
// Flattens an object
// eg:
//
// var o = {
// address: {
// street: 'Street',
// zip: 1234
// }
// };
//
// becomes:
//
// var o = {
// 'address.street': 'Street',
// 'address.zip': 1234
// };
var flatten = function (obj, into, prefix) {
into = into || {};
prefix = prefix || '';
_.each(obj, function(val, key) {
if(obj.hasOwnProperty(key)) {
if (val && typeof val === 'object' && !(
val instanceof Array ||
val instanceof Date ||
val instanceof RegExp ||
val instanceof Backbone.Model ||
val instanceof Backbone.Collection)
) {
flatten(val, into, prefix + key + '.');
}
else {
into[prefix + key] = val;
}
}
});
return into;
};
// Validation
// ----------
var Validation = (function(){
// Returns an object with undefined properties for all
// attributes on the model that has defined one or more
// validation rules.
var getValidatedAttrs = function(model) {
return _.reduce(_.keys(_.result(model, 'validation') || {}), function(memo, key) {
memo[key] = void 0;
return memo;
}, {});
};
// Looks on the model for validations for a specified
// attribute. Returns an array of any validators defined,
// or an empty array if none is defined.
var getValidators = function(model, attr) {
var attrValidationSet = model.validation ? _.result(model, 'validation')[attr] || {} : {};
// If the validator is a function or a string, wrap it in a function validator
if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) {
attrValidationSet = {
fn: attrValidationSet
};
}
// Stick the validator object into an array
if(!_.isArray(attrValidationSet)) {
attrValidationSet = [attrValidationSet];
}
// Reduces the array of validators into a new array with objects
// with a validation method to call, the value to validate against
// and the specified error message, if any
return _.reduce(attrValidationSet, function(memo, attrValidation) {
_.each(_.without(_.keys(attrValidation), 'msg'), function(validator) {
memo.push({
fn: defaultValidators[validator],
val: attrValidation[validator],
msg: attrValidation.msg
});
});
return memo;
}, []);
};
// Validates an attribute against all validators defined
// for that attribute. If one or more errors are found,
// the first error message is returned.
// If the attribute is valid, an empty string is returned.
var validateAttr = function(model, attr, value, computed) {
// Reduces the array of validators to an error message by
// applying all the validators and returning the first error
// message, if any.
return _.reduce(getValidators(model, attr), function(memo, validator){
// Pass the format functions plus the default
// validators as the context to the validator
var ctx = _.extend({}, formatFunctions, defaultValidators),
result = validator.fn.call(ctx, value, attr, validator.val, model, computed);
if(result === false || memo === false) {
return false;
}
if (result && !memo) {
return _.result(validator, 'msg') || result;
}
return memo;
}, '');
};
// Loops through the model's attributes and validates them all.
// Returns and object containing names of invalid attributes
// as well as error messages.
var validateModel = function(model, attrs) {
var error,
invalidAttrs = {},
isValid = true,
computed = _.clone(attrs),
flattened = flatten(attrs);
_.each(flattened, function(val, attr) {
error = validateAttr(model, attr, val, computed);
if (error) {
invalidAttrs[attr] = error;
isValid = false;
}
});
return {
invalidAttrs: invalidAttrs,
isValid: isValid
};
};
// Contains the methods that are mixed in on the model when binding
var mixin = function(view, options) {
return {
// Check whether or not a value, or a hash of values
// passes validation without updating the model
preValidate: function(attr, value) {
var self = this,
result = {},
error;
if(_.isObject(attr)){
_.each(attr, function(value, key) {
error = self.preValidate(key, value);
if(error){
result[key] = error;
}
});
return _.isEmpty(result) ? undefined : result;
}
else {
return validateAttr(this, attr, value, _.extend({}, this.attributes));
}
},
// Check to see if an attribute, an array of attributes or the
// entire model is valid. Passing true will force a validation
// of the model.
isValid: function(option) {
var flattened = flatten(this.attributes);
if(_.isString(option)){
return !validateAttr(this, option, flattened[option], _.extend({}, this.attributes));
}
if(_.isArray(option)){
return _.reduce(option, function(memo, attr) {
return memo && !validateAttr(this, attr, flattened[attr], _.extend({}, this.attributes));
}, true, this);
}
if(option === true) {
this.validate();
}
return this.validation ? this._isValid : true;
},
// This is called by Backbone when it needs to perform validation.
// You can call it manually without any parameters to validate the
// entire model.
validate: function(attrs, setOptions){
var model = this,
validateAll = !attrs,
opt = _.extend({}, options, setOptions),
validatedAttrs = getValidatedAttrs(model),
allAttrs = _.extend({}, validatedAttrs, model.attributes, attrs),
changedAttrs = flatten(attrs || allAttrs),
result = validateModel(model, allAttrs);
model._isValid = result.isValid;
// After validation is performed, loop through all changed attributes
// and call the valid callbacks so the view is updated.
_.each(validatedAttrs, function(val, attr){
var invalid = result.invalidAttrs.hasOwnProperty(attr);
if(!invalid){
opt.valid(view, attr, opt.selector);
}
});
// After validation is performed, loop through all changed attributes
// and call the invalid callback so the view is updated.
_.each(validatedAttrs, function(val, attr){
var invalid = result.invalidAttrs.hasOwnProperty(attr),
changed = changedAttrs.hasOwnProperty(attr);
if(invalid && (changed || validateAll)){
opt.invalid(view, attr, result.invalidAttrs[attr], opt.selector);
}
});
// Trigger validated events.
// Need to defer this so the model is actually updated before
// the event is triggered.
_.defer(function() {
model.trigger('validated', model._isValid, model, result.invalidAttrs);
model.trigger('validated:' + (model._isValid ? 'valid' : 'invalid'), model, result.invalidAttrs);
});
// Return any error messages to Backbone, unless the forceUpdate flag is set.
// Then we do not return anything and fools Backbone to believe the validation was
// a success. That way Backbone will update the model regardless.
if (!opt.forceUpdate && _.intersection(_.keys(result.invalidAttrs), _.keys(changedAttrs)).length > 0) {
return result.invalidAttrs;
}
}
};
};
// Helper to mix in validation on a model
var bindModel = function(view, model, options) {
_.extend(model, mixin(view, options));
};
// Removes the methods added to a model
var unbindModel = function(model) {
delete model.validate;
delete model.preValidate;
delete model.isValid;
};
// Mix in validation on a model whenever a model is
// added to a collection
var collectionAdd = function(model) {
bindModel(this.view, model, this.options);
};
// Remove validation from a model whenever a model is
// removed from a collection
var collectionRemove = function(model) {
unbindModel(model);
};
// Returns the public methods on Backbone.Validation
return {
// Current version of the library
version: '0.8.2',
// Called to configure the default options
configure: function(options) {
_.extend(defaultOptions, options);
},
// Hooks up validation on a view with a model
// or collection
bind: function(view, options) {
options = _.extend({}, defaultOptions, defaultCallbacks, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(typeof model === 'undefined' && typeof collection === 'undefined'){
throw 'Before you execute the binding your view must have a model or a collection.\n' +
'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
}
if(model) {
bindModel(view, model, options);
}
else if(collection) {
collection.each(function(model){
bindModel(view, model, options);
});
collection.bind('add', collectionAdd, {view: view, options: options});
collection.bind('remove', collectionRemove);
}
},
// Removes validation from a view with a model
// or collection
unbind: function(view, options) {
options = _.extend({}, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(model) {
unbindModel(model);
}
if(collection) {
collection.each(function(model){
unbindModel(model);
});
collection.unbind('add', collectionAdd);
collection.unbind('remove', collectionRemove);
}
},
// Used to extend the Backbone.Model.prototype
// with validation
mixin: mixin(null, defaultOptions)
};
}());
// Callbacks
// ---------
var defaultCallbacks = Validation.callbacks = {
// Gets called when a previously invalid field in the
// view becomes valid. Removes any error message.
// Should be overridden with custom functionality.
valid: function(view, attr, selector) {
view.$('[' + selector + '~="' + attr + '"]')
.removeClass('invalid')
.removeAttr('data-error');
},
// Gets called when a field in the view becomes invalid.
// Adds a error message.
// Should be overridden with custom functionality.
invalid: function(view, attr, error, selector) {
view.$('[' + selector + '~="' + attr + '"]')
.addClass('invalid')
.attr('data-error', error);
}
};
// Patterns
// --------
var defaultPatterns = Validation.patterns = {
// Matches any digit(s) (i.e. 0-9)
digits: /^\d+$/,
// Matched any number (e.g. 100.000)
number: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,
// Matches a valid email address (e.g. mail@example.com)
email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,
// Mathes any valid url (e.g. http://www.xample.com)
url: /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
};
// Error messages
// --------------
// Error message for the build in validators.
// {x} gets swapped out with arguments form the validator.
var defaultMessages = Validation.messages = {
required: '{0} is required',
acceptance: '{0} must be accepted',
min: '{0} must be greater than or equal to {1}',
max: '{0} must be less than or equal to {1}',
range: '{0} must be between {1} and {2}',
length: '{0} must be {1} characters',
minLength: '{0} must be at least {1} characters',
maxLength: '{0} must be at most {1} characters',
rangeLength: '{0} must be between {1} and {2} characters',
oneOf: '{0} must be one of: {1}',
equalTo: '{0} must be the same as {1}',
pattern: '{0} must be a valid {1}'
};
// Label formatters
// ----------------
// Label formatters are used to convert the attribute name
// to a more human friendly label when using the built in
// error messages.
// Configure which one to use with a call to
//
// Backbone.Validation.configure({
// labelFormatter: 'label'
// });
var defaultLabelFormatters = Validation.labelFormatters = {
// Returns the attribute name with applying any formatting
none: function(attrName) {
return attrName;
},
// Converts attributeName or attribute_name to Attribute name
sentenceCase: function(attrName) {
return attrName.replace(/(?:^\w|[A-Z]|\b\w)/g, function(match, index) {
return index === 0 ? match.toUpperCase() : ' ' + match.toLowerCase();
}).replace(/_/g, ' ');
},
// Looks for a label configured on the model and returns it
//
// var Model = Backbone.Model.extend({
// validation: {
// someAttribute: {
// required: true
// }
// },
//
// labels: {
// someAttribute: 'Custom label'
// }
// });
label: function(attrName, model) {
return (model.labels && model.labels[attrName]) || defaultLabelFormatters.sentenceCase(attrName, model);
}
};
// Built in validators
// -------------------
var defaultValidators = Validation.validators = (function(){
// Use native trim when defined
var trim = String.prototype.trim ?
function(text) {
return text === null ? '' : String.prototype.trim.call(text);
} :
function(text) {
var trimLeft = /^\s+/,
trimRight = /\s+$/;
return text === null ? '' : text.toString().replace(trimLeft, '').replace(trimRight, '');
};
// Determines whether or not a value is a number
var isNumber = function(value){
return _.isNumber(value) || (_.isString(value) && value.match(defaultPatterns.number));
};
// Determines whether or not a value is empty
var hasValue = function(value) {
return !(_.isNull(value) || _.isUndefined(value) || (_.isString(value) && trim(value) === '') || (_.isArray(value) && _.isEmpty(value)));
};
return {
// Function validator
// Lets you implement a custom function used for validation
fn: function(value, attr, fn, model, computed) {
if(_.isString(fn)){
fn = model[fn];
}
return fn.call(model, value, attr, computed);
},
// Required validator
// Validates if the attribute is required or not
required: function(value, attr, required, model, computed) {
var isRequired = _.isFunction(required) ? required.call(model, value, attr, computed) : required;
if(!isRequired && !hasValue(value)) {
return false; // overrides all other validators
}
if (isRequired && !hasValue(value)) {
return this.format(defaultMessages.required, this.formatLabel(attr, model));
}
},
// Acceptance validator
// Validates that something has to be accepted, e.g. terms of use
// `true` or 'true' are valid
acceptance: function(value, attr, accept, model) {
if(value !== 'true' && (!_.isBoolean(value) || value === false)) {
return this.format(defaultMessages.acceptance, this.formatLabel(attr, model));
}
},
// Min validator
// Validates that the value has to be a number and equal to or greater than
// the min value specified
min: function(value, attr, minValue, model) {
if (!isNumber(value) || value < minValue) {
return this.format(defaultMessages.min, this.formatLabel(attr, model), minValue);
}
},
// Max validator
// Validates that the value has to be a number and equal to or less than
// the max value specified
max: function(value, attr, maxValue, model) {
if (!isNumber(value) || value > maxValue) {
return this.format(defaultMessages.max, this.formatLabel(attr, model), maxValue);
}
},
// Range validator
// Validates that the value has to be a number and equal to or between
// the two numbers specified
range: function(value, attr, range, model) {
if(!isNumber(value) || value < range[0] || value > range[1]) {
return this.format(defaultMessages.range, this.formatLabel(attr, model), range[0], range[1]);
}
},
// Length validator
// Validates that the value has to be a string with length equal to
// the length value specified
length: function(value, attr, length, model) {
if (!hasValue(value) || trim(value).length !== length) {
return this.format(defaultMessages.length, this.formatLabel(attr, model), length);
}
},
// Min length validator
// Validates that the value has to be a string with length equal to or greater than
// the min length value specified
minLength: function(value, attr, minLength, model) {
if (!hasValue(value) || trim(value).length < minLength) {
return this.format(defaultMessages.minLength, this.formatLabel(attr, model), minLength);
}
},
// Max length validator
// Validates that the value has to be a string with length equal to or less than
// the max length value specified
maxLength: function(value, attr, maxLength, model) {
if (!hasValue(value) || trim(value).length > maxLength) {
return this.format(defaultMessages.maxLength, this.formatLabel(attr, model), maxLength);
}
},
// Range length validator
// Validates that the value has to be a string and equal to or between
// the two numbers specified
rangeLength: function(value, attr, range, model) {
if(!hasValue(value) || trim(value).length < range[0] || trim(value).length > range[1]) {
return this.format(defaultMessages.rangeLength, this.formatLabel(attr, model), range[0], range[1]);
}
},
// One of validator
// Validates that the value has to be equal to one of the elements in
// the specified array. Case sensitive matching
oneOf: function(value, attr, values, model) {
if(!_.include(values, value)){
return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', '));
}
},
// Equal to validator
// Validates that the value has to be equal to the value of the attribute
// with the name specified
equalTo: function(value, attr, equalTo, model, computed) {
if(value !== computed[equalTo]) {
return this.format(defaultMessages.equalTo, this.formatLabel(attr, model), this.formatLabel(equalTo, model));
}
},
// Pattern validator
// Validates that the value has to match the pattern specified.
// Can be a regular expression or the name of one of the built in patterns
pattern: function(value, attr, pattern, model) {
if (!hasValue(value) || !value.toString().match(defaultPatterns[pattern] || pattern)) {
return this.format(defaultMessages.pattern, this.formatLabel(attr, model), pattern);
}
}
};
}());
return Validation;
}(_));
return Backbone.Validation;
}));
File diff suppressed because one or more lines are too long
@@ -0,0 +1,623 @@
// Backbone.Validation v0.8.2
//
// Copyright (c) 2011-2013 Thomas Pedersen
// Distributed under MIT License
//
// Documentation and full license available at:
// http://thedersen.com/projects/backbone-validation
Backbone.Validation = (function(_){
'use strict';
// Default options
// ---------------
var defaultOptions = {
forceUpdate: false,
selector: 'name',
labelFormatter: 'sentenceCase',
valid: Function.prototype,
invalid: Function.prototype
};
// Helper functions
// ----------------
// Formatting functions used for formatting error messages
var formatFunctions = {
// Uses the configured label formatter to format the attribute name
// to make it more readable for the user
formatLabel: function(attrName, model) {
return defaultLabelFormatters[defaultOptions.labelFormatter](attrName, model);
},
// Replaces nummeric placeholders like {0} in a string with arguments
// passed to the function
format: function() {
var args = Array.prototype.slice.call(arguments),
text = args.shift();
return text.replace(/\{(\d+)\}/g, function(match, number) {
return typeof args[number] !== 'undefined' ? args[number] : match;
});
}
};
// Flattens an object
// eg:
//
// var o = {
// address: {
// street: 'Street',
// zip: 1234
// }
// };
//
// becomes:
//
// var o = {
// 'address.street': 'Street',
// 'address.zip': 1234
// };
var flatten = function (obj, into, prefix) {
into = into || {};
prefix = prefix || '';
_.each(obj, function(val, key) {
if(obj.hasOwnProperty(key)) {
if (val && typeof val === 'object' && !(
val instanceof Array ||
val instanceof Date ||
val instanceof RegExp ||
val instanceof Backbone.Model ||
val instanceof Backbone.Collection)
) {
flatten(val, into, prefix + key + '.');
}
else {
into[prefix + key] = val;
}
}
});
return into;
};
// Validation
// ----------
var Validation = (function(){
// Returns an object with undefined properties for all
// attributes on the model that has defined one or more
// validation rules.
var getValidatedAttrs = function(model) {
return _.reduce(_.keys(_.result(model, 'validation') || {}), function(memo, key) {
memo[key] = void 0;
return memo;
}, {});
};
// Looks on the model for validations for a specified
// attribute. Returns an array of any validators defined,
// or an empty array if none is defined.
var getValidators = function(model, attr) {
var attrValidationSet = model.validation ? _.result(model, 'validation')[attr] || {} : {};
// If the validator is a function or a string, wrap it in a function validator
if (_.isFunction(attrValidationSet) || _.isString(attrValidationSet)) {
attrValidationSet = {
fn: attrValidationSet
};
}
// Stick the validator object into an array
if(!_.isArray(attrValidationSet)) {
attrValidationSet = [attrValidationSet];
}
// Reduces the array of validators into a new array with objects
// with a validation method to call, the value to validate against
// and the specified error message, if any
return _.reduce(attrValidationSet, function(memo, attrValidation) {
_.each(_.without(_.keys(attrValidation), 'msg'), function(validator) {
memo.push({
fn: defaultValidators[validator],
val: attrValidation[validator],
msg: attrValidation.msg
});
});
return memo;
}, []);
};
// Validates an attribute against all validators defined
// for that attribute. If one or more errors are found,
// the first error message is returned.
// If the attribute is valid, an empty string is returned.
var validateAttr = function(model, attr, value, computed) {
// Reduces the array of validators to an error message by
// applying all the validators and returning the first error
// message, if any.
return _.reduce(getValidators(model, attr), function(memo, validator){
// Pass the format functions plus the default
// validators as the context to the validator
var ctx = _.extend({}, formatFunctions, defaultValidators),
result = validator.fn.call(ctx, value, attr, validator.val, model, computed);
if(result === false || memo === false) {
return false;
}
if (result && !memo) {
return _.result(validator, 'msg') || result;
}
return memo;
}, '');
};
// Loops through the model's attributes and validates them all.
// Returns and object containing names of invalid attributes
// as well as error messages.
var validateModel = function(model, attrs) {
var error,
invalidAttrs = {},
isValid = true,
computed = _.clone(attrs),
flattened = flatten(attrs);
_.each(flattened, function(val, attr) {
error = validateAttr(model, attr, val, computed);
if (error) {
invalidAttrs[attr] = error;
isValid = false;
}
});
return {
invalidAttrs: invalidAttrs,
isValid: isValid
};
};
// Contains the methods that are mixed in on the model when binding
var mixin = function(view, options) {
return {
// Check whether or not a value, or a hash of values
// passes validation without updating the model
preValidate: function(attr, value) {
var self = this,
result = {},
error;
if(_.isObject(attr)){
_.each(attr, function(value, key) {
error = self.preValidate(key, value);
if(error){
result[key] = error;
}
});
return _.isEmpty(result) ? undefined : result;
}
else {
return validateAttr(this, attr, value, _.extend({}, this.attributes));
}
},
// Check to see if an attribute, an array of attributes or the
// entire model is valid. Passing true will force a validation
// of the model.
isValid: function(option) {
var flattened = flatten(this.attributes);
if(_.isString(option)){
return !validateAttr(this, option, flattened[option], _.extend({}, this.attributes));
}
if(_.isArray(option)){
return _.reduce(option, function(memo, attr) {
return memo && !validateAttr(this, attr, flattened[attr], _.extend({}, this.attributes));
}, true, this);
}
if(option === true) {
this.validate();
}
return this.validation ? this._isValid : true;
},
// This is called by Backbone when it needs to perform validation.
// You can call it manually without any parameters to validate the
// entire model.
validate: function(attrs, setOptions){
var model = this,
validateAll = !attrs,
opt = _.extend({}, options, setOptions),
validatedAttrs = getValidatedAttrs(model),
allAttrs = _.extend({}, validatedAttrs, model.attributes, attrs),
changedAttrs = flatten(attrs || allAttrs),
result = validateModel(model, allAttrs);
model._isValid = result.isValid;
// After validation is performed, loop through all changed attributes
// and call the valid callbacks so the view is updated.
_.each(validatedAttrs, function(val, attr){
var invalid = result.invalidAttrs.hasOwnProperty(attr);
if(!invalid){
opt.valid(view, attr, opt.selector);
}
});
// After validation is performed, loop through all changed attributes
// and call the invalid callback so the view is updated.
_.each(validatedAttrs, function(val, attr){
var invalid = result.invalidAttrs.hasOwnProperty(attr),
changed = changedAttrs.hasOwnProperty(attr);
if(invalid && (changed || validateAll)){
opt.invalid(view, attr, result.invalidAttrs[attr], opt.selector);
}
});
// Trigger validated events.
// Need to defer this so the model is actually updated before
// the event is triggered.
_.defer(function() {
model.trigger('validated', model._isValid, model, result.invalidAttrs);
model.trigger('validated:' + (model._isValid ? 'valid' : 'invalid'), model, result.invalidAttrs);
});
// Return any error messages to Backbone, unless the forceUpdate flag is set.
// Then we do not return anything and fools Backbone to believe the validation was
// a success. That way Backbone will update the model regardless.
if (!opt.forceUpdate && _.intersection(_.keys(result.invalidAttrs), _.keys(changedAttrs)).length > 0) {
return result.invalidAttrs;
}
}
};
};
// Helper to mix in validation on a model
var bindModel = function(view, model, options) {
_.extend(model, mixin(view, options));
};
// Removes the methods added to a model
var unbindModel = function(model) {
delete model.validate;
delete model.preValidate;
delete model.isValid;
};
// Mix in validation on a model whenever a model is
// added to a collection
var collectionAdd = function(model) {
bindModel(this.view, model, this.options);
};
// Remove validation from a model whenever a model is
// removed from a collection
var collectionRemove = function(model) {
unbindModel(model);
};
// Returns the public methods on Backbone.Validation
return {
// Current version of the library
version: '0.8.2',
// Called to configure the default options
configure: function(options) {
_.extend(defaultOptions, options);
},
// Hooks up validation on a view with a model
// or collection
bind: function(view, options) {
options = _.extend({}, defaultOptions, defaultCallbacks, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(typeof model === 'undefined' && typeof collection === 'undefined'){
throw 'Before you execute the binding your view must have a model or a collection.\n' +
'See http://thedersen.com/projects/backbone-validation/#using-form-model-validation for more information.';
}
if(model) {
bindModel(view, model, options);
}
else if(collection) {
collection.each(function(model){
bindModel(view, model, options);
});
collection.bind('add', collectionAdd, {view: view, options: options});
collection.bind('remove', collectionRemove);
}
},
// Removes validation from a view with a model
// or collection
unbind: function(view, options) {
options = _.extend({}, options);
var model = options.model || view.model,
collection = options.collection || view.collection;
if(model) {
unbindModel(model);
}
if(collection) {
collection.each(function(model){
unbindModel(model);
});
collection.unbind('add', collectionAdd);
collection.unbind('remove', collectionRemove);
}
},
// Used to extend the Backbone.Model.prototype
// with validation
mixin: mixin(null, defaultOptions)
};
}());
// Callbacks
// ---------
var defaultCallbacks = Validation.callbacks = {
// Gets called when a previously invalid field in the
// view becomes valid. Removes any error message.
// Should be overridden with custom functionality.
valid: function(view, attr, selector) {
view.$('[' + selector + '~="' + attr + '"]')
.removeClass('invalid')
.removeAttr('data-error');
},
// Gets called when a field in the view becomes invalid.
// Adds a error message.
// Should be overridden with custom functionality.
invalid: function(view, attr, error, selector) {
view.$('[' + selector + '~="' + attr + '"]')
.addClass('invalid')
.attr('data-error', error);
}
};
// Patterns
// --------
var defaultPatterns = Validation.patterns = {
// Matches any digit(s) (i.e. 0-9)
digits: /^\d+$/,
// Matched any number (e.g. 100.000)
number: /^-?(?:\d+|\d{1,3}(?:,\d{3})+)(?:\.\d+)?$/,
// Matches a valid email address (e.g. mail@example.com)
email: /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/i,
// Mathes any valid url (e.g. http://www.xample.com)
url: /^(https?|ftp):\/\/(((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:)*@)?(((\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5])\.(\d|[1-9]\d|1\d\d|2[0-4]\d|25[0-5]))|((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?)(:\d*)?)(\/((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)+(\/(([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)*)*)?)?(\?((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|[\uE000-\uF8FF]|\/|\?)*)?(\#((([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(%[\da-f]{2})|[!\$&'\(\)\*\+,;=]|:|@)|\/|\?)*)?$/i
};
// Error messages
// --------------
// Error message for the build in validators.
// {x} gets swapped out with arguments form the validator.
var defaultMessages = Validation.messages = {
required: '{0} is required',
acceptance: '{0} must be accepted',
min: '{0} must be greater than or equal to {1}',
max: '{0} must be less than or equal to {1}',
range: '{0} must be between {1} and {2}',
length: '{0} must be {1} characters',
minLength: '{0} must be at least {1} characters',
maxLength: '{0} must be at most {1} characters',
rangeLength: '{0} must be between {1} and {2} characters',
oneOf: '{0} must be one of: {1}',
equalTo: '{0} must be the same as {1}',
pattern: '{0} must be a valid {1}'
};
// Label formatters
// ----------------
// Label formatters are used to convert the attribute name
// to a more human friendly label when using the built in
// error messages.
// Configure which one to use with a call to
//
// Backbone.Validation.configure({
// labelFormatter: 'label'
// });
var defaultLabelFormatters = Validation.labelFormatters = {
// Returns the attribute name with applying any formatting
none: function(attrName) {
return attrName;
},
// Converts attributeName or attribute_name to Attribute name
sentenceCase: function(attrName) {
return attrName.replace(/(?:^\w|[A-Z]|\b\w)/g, function(match, index) {
return index === 0 ? match.toUpperCase() : ' ' + match.toLowerCase();
}).replace(/_/g, ' ');
},
// Looks for a label configured on the model and returns it
//
// var Model = Backbone.Model.extend({
// validation: {
// someAttribute: {
// required: true
// }
// },
//
// labels: {
// someAttribute: 'Custom label'
// }
// });
label: function(attrName, model) {
return (model.labels && model.labels[attrName]) || defaultLabelFormatters.sentenceCase(attrName, model);
}
};
// Built in validators
// -------------------
var defaultValidators = Validation.validators = (function(){
// Use native trim when defined
var trim = String.prototype.trim ?
function(text) {
return text === null ? '' : String.prototype.trim.call(text);
} :
function(text) {
var trimLeft = /^\s+/,
trimRight = /\s+$/;
return text === null ? '' : text.toString().replace(trimLeft, '').replace(trimRight, '');
};
// Determines whether or not a value is a number
var isNumber = function(value){
return _.isNumber(value) || (_.isString(value) && value.match(defaultPatterns.number));
};
// Determines whether or not a value is empty
var hasValue = function(value) {
return !(_.isNull(value) || _.isUndefined(value) || (_.isString(value) && trim(value) === '') || (_.isArray(value) && _.isEmpty(value)));
};
return {
// Function validator
// Lets you implement a custom function used for validation
fn: function(value, attr, fn, model, computed) {
if(_.isString(fn)){
fn = model[fn];
}
return fn.call(model, value, attr, computed);
},
// Required validator
// Validates if the attribute is required or not
required: function(value, attr, required, model, computed) {
var isRequired = _.isFunction(required) ? required.call(model, value, attr, computed) : required;
if(!isRequired && !hasValue(value)) {
return false; // overrides all other validators
}
if (isRequired && !hasValue(value)) {
return this.format(defaultMessages.required, this.formatLabel(attr, model));
}
},
// Acceptance validator
// Validates that something has to be accepted, e.g. terms of use
// `true` or 'true' are valid
acceptance: function(value, attr, accept, model) {
if(value !== 'true' && (!_.isBoolean(value) || value === false)) {
return this.format(defaultMessages.acceptance, this.formatLabel(attr, model));
}
},
// Min validator
// Validates that the value has to be a number and equal to or greater than
// the min value specified
min: function(value, attr, minValue, model) {
if (!isNumber(value) || value < minValue) {
return this.format(defaultMessages.min, this.formatLabel(attr, model), minValue);
}
},
// Max validator
// Validates that the value has to be a number and equal to or less than
// the max value specified
max: function(value, attr, maxValue, model) {
if (!isNumber(value) || value > maxValue) {
return this.format(defaultMessages.max, this.formatLabel(attr, model), maxValue);
}
},
// Range validator
// Validates that the value has to be a number and equal to or between
// the two numbers specified
range: function(value, attr, range, model) {
if(!isNumber(value) || value < range[0] || value > range[1]) {
return this.format(defaultMessages.range, this.formatLabel(attr, model), range[0], range[1]);
}
},
// Length validator
// Validates that the value has to be a string with length equal to
// the length value specified
length: function(value, attr, length, model) {
if (!hasValue(value) || trim(value).length !== length) {
return this.format(defaultMessages.length, this.formatLabel(attr, model), length);
}
},
// Min length validator
// Validates that the value has to be a string with length equal to or greater than
// the min length value specified
minLength: function(value, attr, minLength, model) {
if (!hasValue(value) || trim(value).length < minLength) {
return this.format(defaultMessages.minLength, this.formatLabel(attr, model), minLength);
}
},
// Max length validator
// Validates that the value has to be a string with length equal to or less than
// the max length value specified
maxLength: function(value, attr, maxLength, model) {
if (!hasValue(value) || trim(value).length > maxLength) {
return this.format(defaultMessages.maxLength, this.formatLabel(attr, model), maxLength);
}
},
// Range length validator
// Validates that the value has to be a string and equal to or between
// the two numbers specified
rangeLength: function(value, attr, range, model) {
if(!hasValue(value) || trim(value).length < range[0] || trim(value).length > range[1]) {
return this.format(defaultMessages.rangeLength, this.formatLabel(attr, model), range[0], range[1]);
}
},
// One of validator
// Validates that the value has to be equal to one of the elements in
// the specified array. Case sensitive matching
oneOf: function(value, attr, values, model) {
if(!_.include(values, value)){
return this.format(defaultMessages.oneOf, this.formatLabel(attr, model), values.join(', '));
}
},
// Equal to validator
// Validates that the value has to be equal to the value of the attribute
// with the name specified
equalTo: function(value, attr, equalTo, model, computed) {
if(value !== computed[equalTo]) {
return this.format(defaultMessages.equalTo, this.formatLabel(attr, model), this.formatLabel(equalTo, model));
}
},
// Pattern validator
// Validates that the value has to match the pattern specified.
// Can be a regular expression or the name of one of the built in patterns
pattern: function(value, attr, pattern, model) {
if (!hasValue(value) || !value.toString().match(defaultPatterns[pattern] || pattern)) {
return this.format(defaultMessages.pattern, this.formatLabel(attr, model), pattern);
}
}
};
}());
return Validation;
}(_));
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "backbone.validation",
"filename": "backbone-validation-min.js",
"version": "0.7.1",
"version": "0.8.2",
"description": "A validation plugin for Backbone.js that validates both your model as well as form input.",
"homepage": "http://thedersen.com/projects/backbone-validation",
"keywords": [
+266
View File
@@ -0,0 +1,266 @@
/*!
* bootstrap-select v1.3.5
* http://silviomoreto.github.io/bootstrap-select/
*
* Copyright 2013 bootstrap-select
* Licensed under the MIT license
*/
.bootstrap-select.btn-group,
.bootstrap-select.btn-group[class*="span"] {
float: none;
display: inline-block;
margin-bottom: 10px;
margin-left: 0;
}
.form-search .bootstrap-select.btn-group,
.form-inline .bootstrap-select.btn-group,
.form-horizontal .bootstrap-select.btn-group {
margin-bottom: 0;
}
.bootstrap-select.form-control {
padding: 0;
border: none;
}
.bootstrap-select.btn-group.pull-right,
.bootstrap-select.btn-group[class*="span"].pull-right,
.row-fluid .bootstrap-select.btn-group[class*="span"].pull-right {
float: right;
}
.input-append .bootstrap-select.btn-group {
margin-left: -1px;
}
.input-prepend .bootstrap-select.btn-group {
margin-right: -1px;
}
.bootstrap-select:not([class*="span"]):not([class*="col-"]):not([class*="form-control"]) {
width: 220px;
}
.bootstrap-select {
/*width: 220px\9; IE8 and below*/
width: 220px\0; /*IE9 and below*/
}
.bootstrap-select.form-control:not([class*="span"]) {
width: 100%;
}
.bootstrap-select > .btn {
width: 100%;
}
.error .bootstrap-select .btn {
border: 1px solid #b94a48;
}
.dropdown-menu {
z-index: 2000;
}
.bootstrap-select.show-menu-arrow.open > .btn {
z-index: 2051;
}
.bootstrap-select .btn:focus {
outline: thin dotted #333333 !important;
outline: 5px auto -webkit-focus-ring-color !important;
outline-offset: -2px;
}
.bootstrap-select.btn-group .btn .filter-option {
overflow: hidden;
position: absolute;
left: 12px;
right: 25px;
text-align: left;
}
.bootstrap-select.btn-group .btn .caret {
position: absolute;
top: 50%;
right: 12px;
margin-top: -2px;
vertical-align: middle;
}
.bootstrap-select.btn-group > .disabled,
.bootstrap-select.btn-group .dropdown-menu li.disabled > a {
cursor: not-allowed;
}
.bootstrap-select.btn-group > .disabled:focus {
outline: none !important;
}
.bootstrap-select.btn-group[class*="span"] .btn {
width: 100%;
}
.bootstrap-select.btn-group .dropdown-menu {
min-width: 100%;
-moz-box-sizing: border-box;
-webkit-box-sizing: border-box;
box-sizing: border-box;
}
.bootstrap-select.btn-group .dropdown-menu.inner {
position: static;
border: 0;
padding: 0;
margin: 0;
-webkit-border-radius: 0;
-moz-border-radius: 0;
border-radius: 0;
-webkit-box-shadow: none;
-moz-box-shadow: none;
box-shadow: none;
}
.bootstrap-select.btn-group .dropdown-menu dt {
display: block;
padding: 3px 20px;
cursor: default;
}
.bootstrap-select.btn-group .div-contain {
overflow: hidden;
}
.bootstrap-select.btn-group .dropdown-menu li {
position: relative;
}
.bootstrap-select.btn-group .dropdown-menu li > a.opt {
position: relative;
padding-left: 35px;
}
.bootstrap-select.btn-group .dropdown-menu li > a {
cursor: pointer;
}
.bootstrap-select.btn-group .dropdown-menu li > dt small {
font-weight: normal;
}
.bootstrap-select.btn-group.show-tick .dropdown-menu li.selected a i.check-mark {
display: inline-block;
position: absolute;
right: 15px;
margin-top: 2.5px;
}
.bootstrap-select.btn-group .dropdown-menu li a i.check-mark {
display: none;
}
.bootstrap-select.btn-group.show-tick .dropdown-menu li a span.text {
margin-right: 34px;
}
.bootstrap-select.btn-group .dropdown-menu li small {
padding-left: 0.5em;
}
.bootstrap-select.btn-group .dropdown-menu li:not(.disabled) > a:hover small,
.bootstrap-select.btn-group .dropdown-menu li:not(.disabled) > a:focus small {
color: #64b1d8;
color: rgba(255,255,255,0.4);
}
.bootstrap-select.btn-group .dropdown-menu li > dt small {
font-weight: normal;
}
.bootstrap-select.show-menu-arrow .dropdown-toggle:before {
content: '';
display: inline-block;
border-left: 7px solid transparent;
border-right: 7px solid transparent;
border-bottom: 7px solid #CCC;
border-bottom-color: rgba(0, 0, 0, 0.2);
position: absolute;
bottom: -4px;
left: 9px;
display: none;
}
.bootstrap-select.show-menu-arrow .dropdown-toggle:after {
content: '';
display: inline-block;
border-left: 6px solid transparent;
border-right: 6px solid transparent;
border-bottom: 6px solid white;
position: absolute;
bottom: -4px;
left: 10px;
display: none;
}
.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:before {
bottom: auto;
top: -3px;
border-top: 7px solid #ccc;
border-bottom: 0;
border-top-color: rgba(0, 0, 0, 0.2);
}
.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:after {
bottom: auto;
top: -3px;
border-top: 6px solid #ffffff;
border-bottom: 0;
}
.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:before {
right: 12px;
left: auto;
}
.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:after {
right: 13px;
left: auto;
}
.bootstrap-select.show-menu-arrow.open > .dropdown-toggle:before,
.bootstrap-select.show-menu-arrow.open > .dropdown-toggle:after {
display: block;
}
.mobile-device {
position: absolute;
top: 0;
left: 0;
display: block !important;
width: 100%;
height: 100% !important;
opacity: 0;
}
.bootstrap-select.fit-width {
width: auto !important;
}
.bootstrap-select.btn-group.fit-width .btn .filter-option {
position: static;
}
.bootstrap-select.btn-group.fit-width .btn .caret {
position: static;
top: auto;
margin-top: -1px;
}
.control-group.error .bootstrap-select .dropdown-toggle{
border-color: #b94a48;
}
.bootstrap-select-searchbox {
padding: 4px 8px;
}
+726
View File
@@ -0,0 +1,726 @@
/*!
* bootstrap-select v1.3.5
* http://silviomoreto.github.io/bootstrap-select/
*
* Copyright 2013 bootstrap-select
* Licensed under the MIT license
*/
!function($) {
"use strict";
$.expr[":"].icontains = function(obj, index, meta) {
return $(obj).text().toUpperCase().indexOf(meta[3].toUpperCase()) >= 0;
};
var Selectpicker = function(element, options, e) {
if (e) {
e.stopPropagation();
e.preventDefault();
}
this.$element = $(element);
this.$newElement = null;
this.$button = null;
this.$menu = null;
//Merge defaults, options and data-attributes to make our options
this.options = $.extend({}, $.fn.selectpicker.defaults, this.$element.data(), typeof options == 'object' && options);
//If we have no title yet, check the attribute 'title' (this is missed by jq as its not a data-attribute
if (this.options.title == null) {
this.options.title = this.$element.attr('title');
}
//Expose public methods
this.val = Selectpicker.prototype.val;
this.render = Selectpicker.prototype.render;
this.refresh = Selectpicker.prototype.refresh;
this.setStyle = Selectpicker.prototype.setStyle;
this.selectAll = Selectpicker.prototype.selectAll;
this.deselectAll = Selectpicker.prototype.deselectAll;
this.init();
};
Selectpicker.prototype = {
constructor: Selectpicker,
init: function() {
this.$element.hide();
this.multiple = this.$element.prop('multiple');
var id = this.$element.attr('id');
this.$newElement = this.createView();
this.$element.after(this.$newElement);
this.$menu = this.$newElement.find('> .dropdown-menu');
this.$button = this.$newElement.find('> button');
this.$searchbox = this.$newElement.find('input');
if (id !== undefined) {
var that = this;
this.$button.attr('data-id', id);
$('label[for="' + id + '"]').click(function(e) {
e.preventDefault();
that.$button.focus();
});
}
this.checkDisabled();
this.clickListener();
this.liveSearchListener();
this.render();
this.liHeight();
this.setStyle();
this.setWidth();
if (this.options.container) {
this.selectPosition();
}
this.$menu.data('this', this);
this.$newElement.data('this', this);
},
createDropdown: function() {
//If we are multiple, then add the show-tick class by default
var multiple = this.multiple ? ' show-tick' : '';
var header = this.options.header ? '<div class="popover-title"><button type="button" class="close" aria-hidden="true">&times;</button>' + this.options.header + '</div>' : '';
var searchbox = this.options.liveSearch ? '<div class="bootstrap-select-searchbox"><input type="text" class="input-block-level form-control" /></div>' : '';
var drop =
"<div class='btn-group bootstrap-select" + multiple + "'>" +
"<button type='button' class='btn dropdown-toggle' data-toggle='dropdown'>" +
"<div class='filter-option pull-left'></div>&nbsp;" +
"<div class='caret'></div>" +
"</button>" +
"<div class='dropdown-menu open'>" +
header +
searchbox +
"<ul class='dropdown-menu inner' role='menu'>" +
"</ul>" +
"</div>" +
"</div>";
return $(drop);
},
createView: function() {
var $drop = this.createDropdown();
var $li = this.createLi();
$drop.find('ul').append($li);
return $drop;
},
reloadLi: function() {
//Remove all children.
this.destroyLi();
//Re build
var $li = this.createLi();
this.$menu.find('ul').append( $li );
},
destroyLi: function() {
this.$menu.find('li').remove();
},
createLi: function() {
var that = this,
_liA = [],
_liHtml = '';
this.$element.find('option').each(function() {
var $this = $(this);
//Get the class and text for the option
var optionClass = $this.attr("class") || '';
var inline = $this.attr("style") || '';
var text = $this.data('content') ? $this.data('content') : $this.html();
var subtext = $this.data('subtext') !== undefined ? '<small class="muted text-muted">' + $this.data('subtext') + '</small>' : '';
var icon = $this.data('icon') !== undefined ? '<i class="glyphicon '+$this.data('icon')+'"></i> ' : '';
if (icon !== '' && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
icon = '<span>'+icon+'</span>';
}
if (!$this.data('content')) {
//Prepend any icon and append any subtext to the main text.
text = icon + '<span class="text">' + text + subtext + '</span>';
}
if (that.options.hideDisabled && ($this.is(':disabled') || $this.parent().is(':disabled'))) {
_liA.push('<a style="min-height: 0; padding: 0"></a>');
} else if ($this.parent().is('optgroup') && $this.data('divider') !== true) {
if ($this.index() == 0) {
//Get the opt group label
var label = $this.parent().attr('label');
var labelSubtext = $this.parent().data('subtext') !== undefined ? '<small class="muted text-muted">'+$this.parent().data('subtext')+'</small>' : '';
var labelIcon = $this.parent().data('icon') ? '<i class="'+$this.parent().data('icon')+'"></i> ' : '';
label = labelIcon + '<span class="text">' + label + labelSubtext + '</span>';
if ($this[0].index != 0) {
_liA.push(
'<div class="div-contain"><div class="divider"></div></div>'+
'<dt>'+label+'</dt>'+
that.createA(text, "opt " + optionClass, inline )
);
} else {
_liA.push(
'<dt>'+label+'</dt>'+
that.createA(text, "opt " + optionClass, inline ));
}
} else {
_liA.push(that.createA(text, "opt " + optionClass, inline ));
}
} else if ($this.data('divider') === true) {
_liA.push('<div class="div-contain"><div class="divider"></div></div>');
} else if ($(this).data('hidden') === true) {
_liA.push('');
} else {
_liA.push(that.createA(text, optionClass, inline ));
}
});
$.each(_liA, function(i, item) {
_liHtml += "<li rel=" + i + ">" + item + "</li>";
});
//If we are not multiple, and we dont have a selected item, and we dont have a title, select the first element so something is set in the button
if (!this.multiple && this.$element.find('option:selected').length==0 && !this.options.title) {
this.$element.find('option').eq(0).prop('selected', true).attr('selected', 'selected');
}
return $(_liHtml);
},
createA: function(text, classes, inline) {
return '<a tabindex="0" class="'+classes+'" style="'+inline+'">' +
text +
'<i class="glyphicon glyphicon-ok icon-ok check-mark"></i>' +
'</a>';
},
render: function() {
var that = this;
//Update the LI to match the SELECT
this.$element.find('option').each(function(index) {
that.setDisabled(index, $(this).is(':disabled') || $(this).parent().is(':disabled') );
that.setSelected(index, $(this).is(':selected') );
});
this.tabIndex();
var selectedItems = this.$element.find('option:selected').map(function() {
var $this = $(this);
var icon = $this.data('icon') && that.options.showIcon ? '<i class="glyphicon ' + $this.data('icon') + '"></i> ' : '';
var subtext;
if (that.options.showSubtext && $this.attr('data-subtext') && !that.multiple) {
subtext = ' <small class="muted text-muted">'+$this.data('subtext') +'</small>';
} else {
subtext = '';
}
if ($this.data('content') && that.options.showContent) {
return $this.data('content');
} else if ($this.attr('title') != undefined) {
return $this.attr('title');
} else {
return icon + $this.html() + subtext;
}
}).toArray();
//Fixes issue in IE10 occurring when no default option is selected and at least one option is disabled
//Convert all the values into a comma delimited string
var title = !this.multiple ? selectedItems[0] : selectedItems.join(", ");
//If this is multi select, and the selectText type is count, the show 1 of 2 selected etc..
if (this.multiple && this.options.selectedTextFormat.indexOf('count') > -1) {
var max = this.options.selectedTextFormat.split(">");
var notDisabled = this.options.hideDisabled ? ':not([disabled])' : '';
if ( (max.length>1 && selectedItems.length > max[1]) || (max.length==1 && selectedItems.length>=2)) {
title = this.options.countSelectedText.replace('{0}', selectedItems.length).replace('{1}', this.$element.find('option:not([data-divider="true"]):not([data-hidden="true"])'+notDisabled).length);
}
}
//If we dont have a title, then use the default, or if nothing is set at all, use the not selected text
if (!title) {
title = this.options.title != undefined ? this.options.title : this.options.noneSelectedText;
}
this.$newElement.find('.filter-option').html(title);
},
setStyle: function(style, status) {
if (this.$element.attr('class')) {
this.$newElement.addClass(this.$element.attr('class').replace(/selectpicker|mobile-device/gi, ''));
}
var buttonClass = style ? style : this.options.style;
if (status == 'add') {
this.$button.addClass(buttonClass);
} else if (status == 'remove') {
this.$button.removeClass(buttonClass);
} else {
this.$button.removeClass(this.options.style);
this.$button.addClass(buttonClass);
}
},
liHeight: function() {
var selectClone = this.$newElement.clone();
selectClone.appendTo('body');
var $menuClone = selectClone.addClass('open').find('> .dropdown-menu');
var liHeight = $menuClone.find('li > a').outerHeight();
var headerHeight = this.options.header ? $menuClone.find('.popover-title').outerHeight() : 0;
var searchHeight = this.options.liveSearch ? $menuClone.find('.bootstrap-select-searchbox').outerHeight() : 0;
selectClone.remove();
this.$newElement.data('liHeight', liHeight).data('headerHeight', headerHeight).data('searchHeight', searchHeight);
},
setSize: function() {
var that = this,
menu = this.$menu,
menuInner = menu.find('.inner'),
selectHeight = this.$newElement.outerHeight(),
liHeight = this.$newElement.data('liHeight'),
headerHeight = this.$newElement.data('headerHeight'),
searchHeight = this.$newElement.data('searchHeight'),
divHeight = menu.find('li .divider').outerHeight(true),
menuPadding = parseInt(menu.css('padding-top')) +
parseInt(menu.css('padding-bottom')) +
parseInt(menu.css('border-top-width')) +
parseInt(menu.css('border-bottom-width')),
notDisabled = this.options.hideDisabled ? ':not(.disabled)' : '',
$window = $(window),
menuExtras = menuPadding + parseInt(menu.css('margin-top')) + parseInt(menu.css('margin-bottom')) + 2,
menuHeight,
selectOffsetTop,
selectOffsetBot,
posVert = function() {
selectOffsetTop = that.$newElement.offset().top - $window.scrollTop();
selectOffsetBot = $window.height() - selectOffsetTop - selectHeight;
};
posVert();
if (this.options.header) menu.css('padding-top', 0);
if (this.options.size == 'auto') {
var getSize = function() {
var minHeight;
posVert();
menuHeight = selectOffsetBot - menuExtras;
that.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && (menuHeight - menuExtras) < menu.height() && that.options.dropupAuto);
if (that.$newElement.hasClass('dropup')) {
menuHeight = selectOffsetTop - menuExtras;
}
if ((menu.find('li').length + menu.find('dt').length) > 3) {
minHeight = liHeight*3 + menuExtras - 2;
} else {
minHeight = 0;
}
menu.css({'max-height' : menuHeight + 'px', 'overflow' : 'hidden', 'min-height' : minHeight + 'px'});
menuInner.css({'max-height' : menuHeight - headerHeight - searchHeight- menuPadding + 'px', 'overflow-y' : 'auto', 'min-height' : minHeight - menuPadding + 'px'});
};
getSize();
$(window).resize(getSize);
$(window).scroll(getSize);
} else if (this.options.size && this.options.size != 'auto' && menu.find('li'+notDisabled).length > this.options.size) {
var optIndex = menu.find("li"+notDisabled+" > *").filter(':not(.div-contain)').slice(0,this.options.size).last().parent().index();
var divLength = menu.find("li").slice(0,optIndex + 1).find('.div-contain').length;
menuHeight = liHeight*this.options.size + divLength*divHeight + menuPadding;
this.$newElement.toggleClass('dropup', (selectOffsetTop > selectOffsetBot) && menuHeight < menu.height() && this.options.dropupAuto);
menu.css({'max-height' : menuHeight + headerHeight + searchHeight + 'px', 'overflow' : 'hidden'});
menuInner.css({'max-height' : menuHeight - menuPadding + 'px', 'overflow-y' : 'auto'});
}
},
setWidth: function() {
if (this.options.width == 'auto') {
this.$menu.css('min-width', '0');
// Get correct width if element hidden
var selectClone = this.$newElement.clone().appendTo('body');
var ulWidth = selectClone.find('> .dropdown-menu').css('width');
selectClone.remove();
this.$newElement.css('width', ulWidth);
} else if (this.options.width == 'fit') {
// Remove inline min-width so width can be changed from 'auto'
this.$menu.css('min-width', '');
this.$newElement.css('width', '').addClass('fit-width');
} else if (this.options.width) {
// Remove inline min-width so width can be changed from 'auto'
this.$menu.css('min-width', '');
this.$newElement.css('width', this.options.width);
} else {
// Remove inline min-width/width so width can be changed
this.$menu.css('min-width', '');
this.$newElement.css('width', '');
}
// Remove fit-width class if width is changed programmatically
if (this.$newElement.hasClass('fit-width') && this.options.width !== 'fit') {
this.$newElement.removeClass('fit-width');
}
},
selectPosition: function() {
var that = this,
drop = "<div />",
$drop = $(drop),
pos,
actualHeight,
getPlacement = function($element) {
$drop.addClass($element.attr('class')).toggleClass('dropup', $element.hasClass('dropup'));
pos = $element.offset();
actualHeight = $element.hasClass('dropup') ? 0 : $element[0].offsetHeight;
$drop.css({'top' : pos.top + actualHeight, 'left' : pos.left, 'width' : $element[0].offsetWidth, 'position' : 'absolute'});
};
this.$newElement.on('click', function() {
getPlacement($(this));
$drop.appendTo(that.options.container);
$drop.toggleClass('open', !$(this).hasClass('open'));
$drop.append(that.$menu);
});
$(window).resize(function() {
getPlacement(that.$newElement);
});
$(window).on('scroll', function() {
getPlacement(that.$newElement);
});
$('html').on('click', function(e) {
if ($(e.target).closest(that.$newElement).length < 1) {
$drop.removeClass('open');
}
});
},
mobile: function() {
this.$element.addClass('mobile-device').appendTo(this.$newElement);
if (this.options.container) this.$menu.hide();
},
refresh: function() {
this.reloadLi();
this.render();
this.setWidth();
this.setStyle();
this.checkDisabled();
this.liHeight();
},
update: function() {
this.reloadLi();
this.setWidth();
this.setStyle();
this.checkDisabled();
this.liHeight();
},
setSelected: function(index, selected) {
this.$menu.find('li').eq(index).toggleClass('selected', selected);
},
setDisabled: function(index, disabled) {
if (disabled) {
this.$menu.find('li').eq(index).addClass('disabled').find('a').attr('href','#').attr('tabindex',-1);
} else {
this.$menu.find('li').eq(index).removeClass('disabled').find('a').removeAttr('href').attr('tabindex',0);
}
},
isDisabled: function() {
return this.$element.is(':disabled');
},
checkDisabled: function() {
var that = this;
if (this.isDisabled()) {
this.$button.addClass('disabled').attr('tabindex', -1);
} else {
if (this.$button.hasClass('disabled')) {
this.$button.removeClass('disabled');
}
if (this.$button.attr('tabindex') == -1) {
if (!this.$element.data('tabindex')) this.$button.removeAttr('tabindex');
}
}
this.$button.click(function() {
return !that.isDisabled();
});
},
tabIndex: function() {
if (this.$element.is('[tabindex]')) {
this.$element.data('tabindex', this.$element.attr("tabindex"));
this.$button.attr('tabindex', this.$element.data('tabindex'));
}
},
clickListener: function() {
var that = this;
$('body').on('touchstart.dropdown', '.dropdown-menu', function(e) {
e.stopPropagation();
});
this.$newElement.on('click', function() {
that.setSize();
});
this.$menu.on('click', 'li a', function(e) {
var clickedIndex = $(this).parent().index(),
prevValue = that.$element.val();
//Dont close on multi choice menu
if (that.multiple) {
e.stopPropagation();
}
e.preventDefault();
//Dont run if we have been disabled
if (!that.isDisabled() && !$(this).parent().hasClass('disabled')) {
var $options = that.$element.find('option');
var $option = $options.eq(clickedIndex);
//Deselect all others if not multi select box
if (!that.multiple) {
$options.prop('selected', false);
$option.prop('selected', true);
}
//Else toggle the one we have chosen if we are multi select.
else {
var state = $option.prop('selected');
$option.prop('selected', !state);
}
that.$button.focus();
// Trigger select 'change'
if (prevValue != that.$element.val()) {
that.$element.change();
}
}
});
this.$menu.on('click', 'li.disabled a, li dt, li .div-contain, h3.popover-title', function(e) {
if (e.target == this) {
e.preventDefault();
e.stopPropagation();
that.$button.focus();
}
});
this.$searchbox.on('click', function(e) {
e.stopPropagation();
});
this.$element.change(function() {
that.render();
});
},
liveSearchListener: function() {
var that = this;
this.$newElement.on('click.dropdown.data-api', function(){
if(that.options.liveSearch) {
setTimeout(function() {
that.$searchbox.focus();
}, 10);
}
});
this.$searchbox.on('input', function() {
if (that.$searchbox.val()) {
that.$menu.find('li').show().not(':icontains(' + that.$searchbox.val() + ')').hide();
} else {
that.$menu.find('li').show();
}
});
},
val: function(value) {
if (value != undefined) {
this.$element.val( value );
this.$element.change();
return this.$element;
} else {
return this.$element.val();
}
},
selectAll: function() {
this.$element.find('option').prop('selected', true).attr('selected', 'selected');
this.render();
},
deselectAll: function() {
this.$element.find('option').prop('selected', false).removeAttr('selected');
this.render();
},
keydown: function(e) {
var $this,
$items,
$parent,
index,
next,
first,
last,
prev,
nextPrev,
that;
$this = $(this);
$parent = $this.parent();
that = $parent.data('this');
if (that.options.container) $parent = that.$menu;
$items = $('[role=menu] li:not(.divider):visible a', $parent);
if (!$items.length) return;
if (/(38|40)/.test(e.keyCode)) {
index = $items.index($items.filter(':focus'));
first = $items.parent(':not(.disabled)').first().index();
last = $items.parent(':not(.disabled)').last().index();
next = $items.eq(index).parent().nextAll(':not(.disabled)').eq(0).index();
prev = $items.eq(index).parent().prevAll(':not(.disabled)').eq(0).index();
nextPrev = $items.eq(next).parent().prevAll(':not(.disabled)').eq(0).index();
if (e.keyCode == 38) {
if (index != nextPrev && index > prev) index = prev;
if (index < first) index = first;
}
if (e.keyCode == 40) {
if (index != nextPrev && index < next) index = next;
if (index > last) index = last;
if (index == -1) index = 0;
}
$items.eq(index).focus();
} else {
var keyCodeMap = {
48:"0", 49:"1", 50:"2", 51:"3", 52:"4", 53:"5", 54:"6", 55:"7", 56:"8", 57:"9", 59:";",
65:"a", 66:"b", 67:"c", 68:"d", 69:"e", 70:"f", 71:"g", 72:"h", 73:"i", 74:"j", 75:"k", 76:"l",
77:"m", 78:"n", 79:"o", 80:"p", 81:"q", 82:"r", 83:"s", 84:"t", 85:"u", 86:"v", 87:"w", 88:"x", 89:"y", 90:"z",
96:"0", 97:"1", 98:"2", 99:"3", 100:"4", 101:"5", 102:"6", 103:"7", 104:"8", 105:"9"
};
var keyIndex = [];
$items.each(function() {
if ($(this).parent().is(':not(.disabled)')) {
if ($.trim($(this).text().toLowerCase()).substring(0,1) == keyCodeMap[e.keyCode]) {
keyIndex.push($(this).parent().index());
}
}
});
var count = $(document).data('keycount');
count++;
$(document).data('keycount',count);
var prevKey = $.trim($(':focus').text().toLowerCase()).substring(0,1);
if (prevKey != keyCodeMap[e.keyCode]) {
count = 1;
$(document).data('keycount',count);
} else if (count >= keyIndex.length) {
$(document).data('keycount',0);
}
$items.eq(keyIndex[count - 1]).focus();
}
// select focused option if "Enter" or "Spacebar" are pressed
if (/(13|32)/.test(e.keyCode)) {
e.preventDefault();
$(':focus').click();
$(document).data('keycount',0);
}
},
hide: function() {
this.$newElement.hide();
},
show: function() {
this.$newElement.show();
},
destroy: function() {
this.$newElement.remove();
this.$element.remove();
}
};
$.fn.selectpicker = function(option, event) {
//get the args of the outer function..
var args = arguments;
var value;
var chain = this.each(function() {
if ($(this).is('select')) {
var $this = $(this),
data = $this.data('selectpicker'),
options = typeof option == 'object' && option;
if (!data) {
$this.data('selectpicker', (data = new Selectpicker(this, options, event)));
} else if (options) {
for(var i in options) {
data.options[i] = options[i];
}
}
if (typeof option == 'string') {
//Copy the value of option, as once we shift the arguments
//it also shifts the value of option.
var property = option;
if (data[property] instanceof Function) {
[].shift.apply(args);
value = data[property].apply(data, args);
} else {
value = data.options[property];
}
}
}
});
if (value != undefined) {
return value;
} else {
return chain;
}
};
$.fn.selectpicker.defaults = {
style: 'btn-default',
size: 'auto',
title: null,
selectedTextFormat : 'values',
noneSelectedText : 'Nothing selected',
countSelectedText: '{0} of {1} selected',
width: false,
container: false,
hideDisabled: false,
showSubtext: false,
showIcon: true,
showContent: true,
dropupAuto: true,
header: false,
liveSearch: false
};
$(document)
.data('keycount', 0)
.on('keydown', '[data-toggle=dropdown], [role=menu]' , Selectpicker.prototype.keydown);
}(window.jQuery);
+7
View File
@@ -0,0 +1,7 @@
/*!
* bootstrap-select v1.3.5
* http://silviomoreto.github.io/bootstrap-select/
*
* Copyright 2013 bootstrap-select
* Licensed under the MIT license
*/.bootstrap-select.btn-group,.bootstrap-select.btn-group[class*="span"]{float:none;display:inline-block;margin-bottom:10px;margin-left:0}.form-search .bootstrap-select.btn-group,.form-inline .bootstrap-select.btn-group,.form-horizontal .bootstrap-select.btn-group{margin-bottom:0}.bootstrap-select.form-control{padding:0;border:0}.bootstrap-select.btn-group.pull-right,.bootstrap-select.btn-group[class*="span"].pull-right,.row-fluid .bootstrap-select.btn-group[class*="span"].pull-right{float:right}.input-append .bootstrap-select.btn-group{margin-left:-1px}.input-prepend .bootstrap-select.btn-group{margin-right:-1px}.bootstrap-select:not([class*="span"]):not([class*="col-"]):not([class*="form-control"]){width:220px}.bootstrap-select{width:220px\0}.bootstrap-select.form-control:not([class*="span"]){width:100%}.bootstrap-select>.btn{width:100%}.error .bootstrap-select .btn{border:1px solid #b94a48}.dropdown-menu{z-index:2000}.bootstrap-select.show-menu-arrow.open>.btn{z-index:2051}.bootstrap-select .btn:focus{outline:thin dotted #333 !important;outline:5px auto -webkit-focus-ring-color !important;outline-offset:-2px}.bootstrap-select.btn-group .btn .filter-option{overflow:hidden;position:absolute;left:12px;right:25px;text-align:left}.bootstrap-select.btn-group .btn .caret{position:absolute;top:50%;right:12px;margin-top:-2px;vertical-align:middle}.bootstrap-select.btn-group>.disabled,.bootstrap-select.btn-group .dropdown-menu li.disabled>a{cursor:not-allowed}.bootstrap-select.btn-group>.disabled:focus{outline:none !important}.bootstrap-select.btn-group[class*="span"] .btn{width:100%}.bootstrap-select.btn-group .dropdown-menu{min-width:100%;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;box-sizing:border-box}.bootstrap-select.btn-group .dropdown-menu.inner{position:static;border:0;padding:0;margin:0;-webkit-border-radius:0;-moz-border-radius:0;border-radius:0;-webkit-box-shadow:none;-moz-box-shadow:none;box-shadow:none}.bootstrap-select.btn-group .dropdown-menu dt{display:block;padding:3px 20px;cursor:default}.bootstrap-select.btn-group .div-contain{overflow:hidden}.bootstrap-select.btn-group .dropdown-menu li{position:relative}.bootstrap-select.btn-group .dropdown-menu li>a.opt{position:relative;padding-left:35px}.bootstrap-select.btn-group .dropdown-menu li>a{cursor:pointer}.bootstrap-select.btn-group .dropdown-menu li>dt small{font-weight:normal}.bootstrap-select.btn-group.show-tick .dropdown-menu li.selected a i.check-mark{display:inline-block;position:absolute;right:15px;margin-top:2.5px}.bootstrap-select.btn-group .dropdown-menu li a i.check-mark{display:none}.bootstrap-select.btn-group.show-tick .dropdown-menu li a span.text{margin-right:34px}.bootstrap-select.btn-group .dropdown-menu li small{padding-left:.5em}.bootstrap-select.btn-group .dropdown-menu li:not(.disabled)>a:hover small,.bootstrap-select.btn-group .dropdown-menu li:not(.disabled)>a:focus small{color:#64b1d8;color:rgba(255,255,255,0.4)}.bootstrap-select.btn-group .dropdown-menu li>dt small{font-weight:normal}.bootstrap-select.show-menu-arrow .dropdown-toggle:before{content:'';display:inline-block;border-left:7px solid transparent;border-right:7px solid transparent;border-bottom:7px solid #CCC;border-bottom-color:rgba(0,0,0,0.2);position:absolute;bottom:-4px;left:9px;display:none}.bootstrap-select.show-menu-arrow .dropdown-toggle:after{content:'';display:inline-block;border-left:6px solid transparent;border-right:6px solid transparent;border-bottom:6px solid white;position:absolute;bottom:-4px;left:10px;display:none}.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:before{bottom:auto;top:-3px;border-top:7px solid #ccc;border-bottom:0;border-top-color:rgba(0,0,0,0.2)}.bootstrap-select.show-menu-arrow.dropup .dropdown-toggle:after{bottom:auto;top:-3px;border-top:6px solid #fff;border-bottom:0}.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:before{right:12px;left:auto}.bootstrap-select.show-menu-arrow.pull-right .dropdown-toggle:after{right:13px;left:auto}.bootstrap-select.show-menu-arrow.open>.dropdown-toggle:before,.bootstrap-select.show-menu-arrow.open>.dropdown-toggle:after{display:block}.mobile-device{position:absolute;top:0;left:0;display:block !important;width:100%;height:100% !important;opacity:0}.bootstrap-select.fit-width{width:auto !important}.bootstrap-select.btn-group.fit-width .btn .filter-option{position:static}.bootstrap-select.btn-group.fit-width .btn .caret{position:static;top:auto;margin-top:-1px}.control-group.error .bootstrap-select .dropdown-toggle{border-color:#b94a48}.bootstrap-select-searchbox{padding:4px 8px}
File diff suppressed because one or more lines are too long
+31
View File
@@ -0,0 +1,31 @@
{
"name": "bootstrap-select",
"filename": "bootstrap-select.min.js",
"version": "1.3.5",
"title": "Bootstrap Select",
"description": "A custom select / multiselect for @twitter bootstrap using button dropdown, designed to behave like regular Bootstrap selects",
"keywords": [
"form",
"bootstrap",
"select",
"replacement"
],
"version": "1.3.5",
"author": {
"name": "Silvio Moreto",
"url": "https://github.com/silviomoreto/"
},
"licenses": [
{
"type": "MIT",
"url": "https://github.com/silviomoreto/bootstrap-select#copyright-and-license"
}
],
"bugs": "https://github.com/silviomoreto/bootstrap-select/issues",
"homepage": "https://github.com/silviomoreto/bootstrap-select",
"docs": "https://github.com/silviomoreto/bootstrap-select",
"download": "https://github.com/silviomoreto/bootstrap-select/releases",
"dependencies": {
"jquery": ">=1.7"
}
}
+265
View File
@@ -0,0 +1,265 @@
/* fallback.js v1.0.5 | https://github.com/dolox/fallback/ | Salvatore Garbesi <sal@dolox.com> | (c) 2013 Dolox Inc. */
(function(window) {
'use strict';
var fallback = {
callback: null,
callbacks: [],
head: document.getElementsByTagName('head')[0],
libraries: {},
libraries_count: 0,
loaded: {},
loaded_count: 0,
fail: {},
fail_count: 0,
shim: {}
};
fallback.is_array = function(variable) {
if (variable instanceof Array) {
return true;
}
return false;
};
fallback.is_defined = function(variable) {
/* jslint evil: true */
if (eval('window.' + variable)) {
return true;
}
return false;
};
fallback.is_function = function(variable) {
if (({}).toString.call(variable) === '[object Function]') {
return true;
}
return false;
};
fallback.is_object = function(variable) {
if (typeof variable === 'object') {
return true;
}
return false;
};
fallback.index_of = function(object, value) {
var index;
for (index in object) {
if (object[index] === value) {
return index;
}
}
return -1;
};
fallback.initialize = function() {
var library, urls;
for (library in this.libraries) {
if (this.libraries[library]) {
urls = this.libraries[library];
if (!this.is_array(urls)) {
this.libraries[library] = urls = [urls];
}
this.libraries_count++;
if (!this.shim[library]) {
this.spawn(library, urls[0], 0);
}
}
}
};
fallback.completed = function() {
this.ready_invocation();
if (this.libraries_count === this.loaded_count + this.fail_count) {
if (this.is_function(this.callback)) {
this.callback(this.loaded, this.fail);
}
this.callback = null;
}
};
fallback.error = function(library, index) {
index = parseInt(index,0);
if (!this.fail[library]) {
this.fail[library] = [];
}
this.fail[library][this.fail[library].length] = this.libraries[library][index];
if (index < this.libraries[library].length - 1) {
this.spawn(library, this.libraries[library][index + 1], index + 1);
} else {
this.fail_count++;
}
this.completed();
};
fallback.load = function(libraries, options, callback) {
if (this.is_function(options)) {
callback = options;
options = {};
}
if (!this.is_object(options)) {
options = {};
}
if (options.shim) {
this.shim = options.shim;
}
if (!this.is_function(callback)) {
callback = function() {};
}
this.callback = callback;
this.libraries = libraries;
this.initialize();
};
fallback.ready = function(libraries, callback) {
var options = {
callback: callback,
libraries: libraries
};
if (!this.is_array(libraries)) {
options.callback = libraries;
options.libraries = [];
}
this.callbacks[this.callbacks.length] = options;
this.ready_invocation();
};
fallback.ready_invocation = function() {
var index, options, count, library, wipe;
for (index in this.callbacks) {
if (this.is_object(this.callbacks[index])) {
options = this.callbacks[index];
wipe = false;
if (options.libraries.length > 0) {
count = 0;
for (library in this.loaded) {
if (this.index_of(options.libraries, library) >= 0) {
count++;
}
}
if (count === options.libraries.length) {
options.callback();
wipe = true;
}
} else if (this.libraries_count === this.loaded_count + this.fail_count) {
options.callback(this.loaded, this.fail);
wipe = true;
}
if (wipe) {
delete this.callbacks[index];
}
}
}
};
fallback.spawn = function(library, url, index) {
var element;
if (this.is_defined(library)) {
return fallback.success(library, index);
}
if (url.indexOf('.css') > -1) {
element = document.createElement('link');
element.rel = 'stylesheet';
element.href = url;
} else {
element = document.createElement('script');
element.src = url;
}
element.onload = function() {
fallback.success(library, index);
};
element.onreadystatechange = function() {
if (!this.readyState || this.readyState === 'loaded' || this.readyState === 'complete') {
this.onreadystatechange = null;
if (!fallback.is_defined(library)) {
fallback.error(library, index);
} else {
fallback.success(library, index);
}
}
};
element.onerror = function() {
fallback.error(library, index);
};
this.head.appendChild(element);
};
fallback.success = function(library, index) {
this.loaded[library] = this.libraries[library][index];
this.loaded_count++;
if (this.shim) {
this.shim_invocation(library);
}
this.completed();
};
fallback.shim_invocation = function() {
var count, index, shim, shimming;
for (shim in this.shim) {
if (this.shim[shim]) {
shimming = this.shim[shim];
count = 0;
if (!this.loaded[shim]) {
for (index in shimming) {
if (this.loaded[shimming[index]]) {
count++;
}
}
if (count === shimming.length) {
this.spawn(shim, this.libraries[shim][0], 0);
delete this.shim[shim];
}
}
}
}
};
window.fallback = fallback;
})(window);
+6
View File
@@ -0,0 +1,6 @@
/* fallback.js v1.0.5 | https://github.com/dolox/fallback/ | Salvatore Garbesi <sal@dolox.com> | (c) 2013 Dolox Inc. */
(function(f){var e={b:null,c:[],head:document.getElementsByTagName("head")[0],a:{},g:0,loaded:{},h:0,d:{},e:0,shim:{},l:function(a){return a instanceof Array?!0:!1},m:function(a){return eval("window."+a)?!0:!1},f:function(a){return"[object Function]"==={}.toString.call(a)?!0:!1},n:function(a){return"object"===typeof a?!0:!1},p:function(a,b){for(var c in a)if(a[c]===b)return c;return-1},q:function(){var a,b;for(a in this.a)this.a[a]&&(b=this.a[a],this.l(b)||(this.a[a]=b=[b]),this.g++,this.shim[a]||
this.i(a,b[0],0))},k:function(){this.o();this.g===this.h+this.e&&(this.f(this.b)&&this.b(this.loaded,this.d),this.b=null)},error:function(a,b){b=parseInt(b,0);this.d[a]||(this.d[a]=[]);this.d[a][this.d[a].length]=this.a[a][b];b<this.a[a].length-1?this.i(a,this.a[a][b+1],b+1):this.e++;this.k()},load:function(a,b,c){this.f(b)&&(c=b,b={});this.n(b)||(b={});b.shim&&(this.shim=b.shim);this.f(c)||(c=function(){});this.b=c;this.a=a;this.q()},ready:function(a,b){var c={b:b,a:a};this.l(a)||(c.b=a,c.a=[]);
this.c[this.c.length]=c;this.o()},o:function(){var a,b,c,d,e;for(a in this.c)if(this.n(this.c[a])){b=this.c[a];e=!1;if(0<b.a.length){c=0;for(d in this.loaded)0<=this.p(b.a,d)&&c++;c===b.a.length&&(b.b(),e=!0)}else this.g===this.h+this.e&&(b.b(this.loaded,this.d),e=!0);e&&delete this.c[a]}},i:function(a,b,c){var d;if(this.m(a))return e.j(a,c);-1<b.indexOf(".css")?(d=document.createElement("link"),d.rel="stylesheet",d.href=b):(d=document.createElement("script"),d.src=b);d.onload=function(){e.j(a,c)};
d.onreadystatechange=function(){this.readyState&&"loaded"!==this.readyState&&"complete"!==this.readyState||(this.onreadystatechange=null,e.m(a)?e.j(a,c):e.error(a,c))};d.onerror=function(){e.error(a,c)};this.head.appendChild(d)},j:function(a,b){this.loaded[a]=this.a[a][b];this.h++;this.shim&&this.r(a);this.k()},r:function(){var a,b,c,d;for(c in this.shim)if(this.shim[c]&&(d=this.shim[c],a=0,!this.loaded[c])){for(b in d)this.loaded[d[b]]&&a++;a===d.length&&(this.i(c,this.a[c][0],0),delete this.shim[c])}}};
f.fallback=e})(window);
+31
View File
@@ -0,0 +1,31 @@
{
"name": "fallback",
"filename": "fallback.min.js",
"version": "1.0.5",
"description": "JavaScript library for dynamically loading CSS and JS files. Also provides the ability to load multiple files from a CDN with multiple fallback options and shimming!",
"homepage": "http://fallback.io/",
"keywords": [
"fallback",
"failover",
"ondemand",
"require",
"ajax",
"component"
],
"maintainers": [
{
"name": "Salvatore Garbesi",
"email": "sal@dolox.com",
"twitter": "sgarbesi"
}
],
"repositories": [
{
"type": "git",
"url": "git://github.com/dolox/fallback.git"
}
]
}
+12
View File
File diff suppressed because one or more lines are too long
+12
View File
File diff suppressed because one or more lines are too long
+12
View File
File diff suppressed because one or more lines are too long
+16
View File
File diff suppressed because one or more lines are too long
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: beta 1.9.3
* DATE: 2013-04-02
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine("easing.Back",["easing.Ease"],function(t){var e,i,s,r=window.GreenSockGlobals||window,n=r.com.greensock,a=2*Math.PI,o=Math.PI/2,h=n._class,l=function(e,i){var s=h("easing."+e,function(){},!0),r=s.prototype=new t;return r.constructor=s,r.getRatio=i,s},_=t.register||function(){},u=function(t,e,i,s){var r=h("easing."+t,{easeOut:new e,easeIn:new i,easeInOut:new s},!0);return _(r,t),r},c=function(t,e,i){this.t=t,this.v=e,i&&(this.next=i,i.prev=this,this.c=i.v-e,this.gap=i.t-t)},p=function(e,i){var s=h("easing."+e,function(t){this._p1=t||0===t?t:1.70158,this._p2=1.525*this._p1},!0),r=s.prototype=new t;return r.constructor=s,r.getRatio=i,r.config=function(t){return new s(t)},s},f=u("Back",p("BackOut",function(t){return(t-=1)*t*((this._p1+1)*t+this._p1)+1}),p("BackIn",function(t){return t*t*((this._p1+1)*t-this._p1)}),p("BackInOut",function(t){return 1>(t*=2)?.5*t*t*((this._p2+1)*t-this._p2):.5*((t-=2)*t*((this._p2+1)*t+this._p2)+2)})),m=h("easing.SlowMo",function(t,e,i){e=e||0===e?e:.7,null==t?t=.7:t>1&&(t=1),this._p=1!==t?e:0,this._p1=(1-t)/2,this._p2=t,this._p3=this._p1+this._p2,this._calcEnd=i===!0},!0),d=m.prototype=new t;return d.constructor=m,d.getRatio=function(t){var e=t+(.5-t)*this._p;return this._p1>t?this._calcEnd?1-(t=1-t/this._p1)*t:e-(t=1-t/this._p1)*t*t*t*e:t>this._p3?this._calcEnd?1-(t=(t-this._p3)/this._p1)*t:e+(t-e)*(t=(t-this._p3)/this._p1)*t*t*t:this._calcEnd?1:e},m.ease=new m(.7,.7),d.config=m.config=function(t,e,i){return new m(t,e,i)},e=h("easing.SteppedEase",function(t){t=t||1,this._p1=1/t,this._p2=t+1},!0),d=e.prototype=new t,d.constructor=e,d.getRatio=function(t){return 0>t?t=0:t>=1&&(t=.999999999),(this._p2*t>>0)*this._p1},d.config=e.config=function(t){return new e(t)},i=h("easing.RoughEase",function(e){e=e||{};for(var i,s,r,n,a,o,h=e.taper||"none",l=[],_=0,u=0|(e.points||20),p=u,f=e.randomize!==!1,m=e.clamp===!0,d=e.template instanceof t?e.template:null,g="number"==typeof e.strength?.4*e.strength:.4;--p>-1;)i=f?Math.random():1/u*p,s=d?d.getRatio(i):i,"none"===h?r=g:"out"===h?(n=1-i,r=n*n*g):"in"===h?r=i*i*g:.5>i?(n=2*i,r=.5*n*n*g):(n=2*(1-i),r=.5*n*n*g),f?s+=Math.random()*r-.5*r:p%2?s+=.5*r:s-=.5*r,m&&(s>1?s=1:0>s&&(s=0)),l[_++]={x:i,y:s};for(l.sort(function(t,e){return t.x-e.x}),o=new c(1,1,null),p=u;--p>-1;)a=l[p],o=new c(a.x,a.y,o);this._prev=new c(0,0,0!==o.t?o:o.next)},!0),d=i.prototype=new t,d.constructor=i,d.getRatio=function(t){var e=this._prev;if(t>e.t){for(;e.next&&t>=e.t;)e=e.next;e=e.prev}else for(;e.prev&&e.t>=t;)e=e.prev;return this._prev=e,e.v+(t-e.t)/e.gap*e.c},d.config=function(t){return new i(t)},i.ease=new i,u("Bounce",l("BounceOut",function(t){return 1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375}),l("BounceIn",function(t){return 1/2.75>(t=1-t)?1-7.5625*t*t:2/2.75>t?1-(7.5625*(t-=1.5/2.75)*t+.75):2.5/2.75>t?1-(7.5625*(t-=2.25/2.75)*t+.9375):1-(7.5625*(t-=2.625/2.75)*t+.984375)}),l("BounceInOut",function(t){var e=.5>t;return t=e?1-2*t:2*t-1,t=1/2.75>t?7.5625*t*t:2/2.75>t?7.5625*(t-=1.5/2.75)*t+.75:2.5/2.75>t?7.5625*(t-=2.25/2.75)*t+.9375:7.5625*(t-=2.625/2.75)*t+.984375,e?.5*(1-t):.5*t+.5})),u("Circ",l("CircOut",function(t){return Math.sqrt(1-(t-=1)*t)}),l("CircIn",function(t){return-(Math.sqrt(1-t*t)-1)}),l("CircInOut",function(t){return 1>(t*=2)?-.5*(Math.sqrt(1-t*t)-1):.5*(Math.sqrt(1-(t-=2)*t)+1)})),s=function(e,i,s){var r=h("easing."+e,function(t,e){this._p1=t||1,this._p2=e||s,this._p3=this._p2/a*(Math.asin(1/this._p1)||0)},!0),n=r.prototype=new t;return n.constructor=r,n.getRatio=i,n.config=function(t,e){return new r(t,e)},r},u("Elastic",s("ElasticOut",function(t){return this._p1*Math.pow(2,-10*t)*Math.sin((t-this._p3)*a/this._p2)+1},.3),s("ElasticIn",function(t){return-(this._p1*Math.pow(2,10*(t-=1))*Math.sin((t-this._p3)*a/this._p2))},.3),s("ElasticInOut",function(t){return 1>(t*=2)?-.5*this._p1*Math.pow(2,10*(t-=1))*Math.sin((t-this._p3)*a/this._p2):.5*this._p1*Math.pow(2,-10*(t-=1))*Math.sin((t-this._p3)*a/this._p2)+1},.45)),u("Expo",l("ExpoOut",function(t){return 1-Math.pow(2,-10*t)}),l("ExpoIn",function(t){return Math.pow(2,10*(t-1))-.001}),l("ExpoInOut",function(t){return 1>(t*=2)?.5*Math.pow(2,10*(t-1)):.5*(2-Math.pow(2,-10*(t-1)))})),u("Sine",l("SineOut",function(t){return Math.sin(t*o)}),l("SineIn",function(t){return-Math.cos(t*o)+1}),l("SineInOut",function(t){return-.5*(Math.cos(Math.PI*t)-1)})),h("easing.EaseLookup",{find:function(e){return t.map[e]}},!0),_(r.SlowMo,"SlowMo","ease,"),_(i,"RoughEase","ease,"),_(e,"SteppedEase","ease,"),f},!0)}),window._gsDefine&&window._gsQueue.pop()();
+14
View File
@@ -0,0 +1,14 @@
/*!
* VERSION: 0.1.6
* DATE: 2013-02-13
* UPDATES AND DOCS AT: http://www.greensock.com/jquery-gsap-plugin/
*
* Requires TweenLite version 1.8.0 or higher and CSSPlugin.
*
* @license Copyright (c) 2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
(function(t){"use strict";var e,i,s,r=t.fn.animate,n=t.fn.stop,a=!0,o=function(t,e){"function"==typeof t&&this.each(t),e()},h=function(t,e,i,s,r){r="function"==typeof r?r:null,e="function"==typeof e?e:null,(e||r)&&(s[t]=r?o:i.each,s[t+"Scope"]=i,s[t+"Params"]=r?[e,r]:[e])},l={overwrite:1,delay:1,useFrames:1,runBackwards:1,easeParams:1,yoyo:1,immediateRender:1,repeat:1,repeatDelay:1,autoCSS:1},_=function(t,e){for(var i in l)l[i]&&void 0!==t[i]&&(e[i]=t[i])},u=function(t){return function(e){return t.getRatio(e)}},c={},f=function(){var r,n,a,o=window.GreenSockGlobals||window;if(e=o.TweenMax||o.TweenLite,e&&(r=(e.version+".0.0").split("."),n=!(Number(r[0])>0&&Number(r[1])>7),o=o.com.greensock,i=o.plugins.CSSPlugin,c=o.easing.Ease.map||{}),!e||!i||n)return e=null,!s&&window.console&&(window.console.log("The jquery.gsap.js plugin requires the TweenMax (or at least TweenLite and CSSPlugin) JavaScript file(s)."+(n?" Version "+r.join(".")+" is too old.":"")),s=!0),void 0;if(t.easing){for(a in c)t.easing[a]=u(c[a]);f=!1}};t.fn.animate=function(s,n,o,l){if(s=s||{},f&&(f(),!e||!i))return r.call(this,s,n,o,l);if(!a||s.skipGSAP===!0||"object"==typeof n&&"function"==typeof n.step||null!=s.scrollTop||null!=s.scrollLeft)return r.call(this,s,n,o,l);var u,p,m,d,g=t.speed(n,o,l),v={ease:c[g.easing]||(g.easing===!1?c.linear:c.swing)},T=this,y="object"==typeof n?n.specialEasing:null;for(p in s){if(u=s[p],u instanceof Array&&c[u[1]]&&(y=y||{},y[p]=u[1],u=u[0]),"toggle"===u||"hide"===u||"show"===u)return r.call(this,s,n,o,l);v[-1===p.indexOf("-")?p:t.camelCase(p)]=u}if(y){d=[];for(p in y)u=d[d.length]={},_(v,u),u.ease=c[y[p]]||v.ease,-1!==p.indexOf("-")&&(p=t.camelCase(p)),u[p]=v[p];0===d.length&&(d=null)}return m=function(i){if(d)for(var s=d.length;--s>-1;)e.to(T,t.fx.off?0:g.duration/1e3,d[s]);h("onComplete",g.old,T,v,i),e.to(T,t.fx.off?0:g.duration/1e3,v)},g.queue!==!1?T.queue(g.queue,m):m(),T},t.fn.stop=function(t,i){if(n.call(this,t,i),e){if(i)for(var s,r=e.getTweensOf(this),a=r.length;--a>-1;)s=r[a].totalTime()/r[a].totalDuration(),s>0&&1>s&&r[a].seek(r[a].totalDuration());e.killTweensOf(this)}return this},t.gsap={enabled:function(t){a=t},version:"0.1.6"}})(jQuery);
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: 0.2.0
* DATE: 2013-07-10
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine.plugin({propName:"attr",API:2,init:function(t,e){var i;if("function"!=typeof t.setAttribute)return!1;this._target=t,this._proxy={};for(i in e)this._addTween(this._proxy,i,parseFloat(t.getAttribute(i)),e[i],i)&&this._overwriteProps.push(i);return!0},set:function(t){this._super.setRatio.call(this,t);for(var e,i=this._overwriteProps,s=i.length;--s>-1;)e=i[s],this._target.setAttribute(e,this._proxy[e]+"")}})}),window._gsDefine&&window._gsQueue.pop()();
File diff suppressed because one or more lines are too long
+12
View File
File diff suppressed because one or more lines are too long
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: beta 0.6.0
* DATE: 2013-07-03
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine("plugins.CSSRulePlugin",["plugins.TweenPlugin","TweenLite","plugins.CSSPlugin"],function(t,e,i){var s=function(){t.call(this,"cssRule"),this._overwriteProps.length=0},r=window.document,n=i.prototype.setRatio,a=s.prototype=new i;return a._propName="cssRule",a.constructor=s,s.API=2,s.getRule=function(t){var e,i,s,n,a=r.all?"rules":"cssRules",o=r.styleSheets,l=o.length,h=":"===t.charAt(0);for(t=(h?"":",")+t.toLowerCase()+",",h&&(n=[]);--l>-1;){try{i=o[l][a]}catch(u){console.log(u);continue}for(e=i.length;--e>-1;)if(s=i[e],s.selectorText&&-1!==(","+s.selectorText.split("::").join(":").toLowerCase()+",").indexOf(t)){if(!h)return s.style;n.push(s.style)}}return n},a._onInitTween=function(t,e,s){if(void 0===t.cssText)return!1;var n=r.createElement("div");return this._ss=t,this._proxy=n.style,n.style.cssText=t.cssText,i.prototype._onInitTween.call(this,n,e,s),!0},a.setRatio=function(t){n.call(this,t),this._ss.cssText=this._proxy.cssText},t.activate([s]),s},!0)}),window._gsDefine&&window._gsQueue.pop()();
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: beta 1.2.0
* DATE: 2013-03-01
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=/(\d|\.)+/g,e={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},i=function(t,e,i){return t=0>t?t+1:t>1?t-1:t,0|255*(1>6*t?e+6*(i-e)*t:.5>t?i:2>3*t?e+6*(i-e)*(2/3-t):e)+.5},s=function(s){if(""===s||null==s||"none"===s)return e.transparent;if(e[s])return e[s];if("number"==typeof s)return[s>>16,255&s>>8,255&s];if("#"===s.charAt(0))return 4===s.length&&(s="#"+s.charAt(1)+s.charAt(1)+s.charAt(2)+s.charAt(2)+s.charAt(3)+s.charAt(3)),s=parseInt(s.substr(1),16),[s>>16,255&s>>8,255&s];if("hsl"===s.substr(0,3)){s=s.match(t);var r=Number(s[0])%360/360,n=Number(s[1])/100,a=Number(s[2])/100,o=.5>=a?a*(n+1):a+n-a*n,h=2*a-o;return s.length>3&&(s[3]=Number(s[3])),s[0]=i(r+1/3,h,o),s[1]=i(r,h,o),s[2]=i(r-1/3,h,o),s}return s.match(t)||e.transparent};window._gsDefine.plugin({propName:"colorProps",priority:-1,API:2,init:function(t,e){this._target=t;var i,r,n,a;for(i in e)n=s(e[i]),this._firstPT=a={_next:this._firstPT,p:i,f:"function"==typeof t[i],n:i,r:!1},r=s(a.f?t[i.indexOf("set")||"function"!=typeof t["get"+i.substr(3)]?i:"get"+i.substr(3)]():t[i]),a.s=Number(r[0]),a.c=Number(n[0])-a.s,a.gs=Number(r[1]),a.gc=Number(n[1])-a.gs,a.bs=Number(r[2]),a.bc=Number(n[2])-a.bs,(a.rgba=r.length>3||n.length>3)&&(a.as=4>r.length?1:Number(r[3]),a.ac=(4>n.length?1:Number(n[3]))-a.as),a._next&&(a._next._prev=a);return!0},set:function(t){for(var e,i=this._firstPT;i;)e=(i.rgba?"rgba(":"rgb(")+(i.s+t*i.c>>0)+", "+(i.gs+t*i.gc>>0)+", "+(i.bs+t*i.bc>>0)+(i.rgba?", "+(i.as+t*i.ac):"")+")",i.f?this._target[i.p](e):this._target[i.p]=e,i=i._next}})}),window._gsDefine&&window._gsQueue.pop()();
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: beta 0.2.0
* DATE: 2013-05-07
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";window._gsDefine.plugin({propName:"directionalRotation",API:2,init:function(t,e){"object"!=typeof e&&(e={rotation:e}),this.finals={};var i,s,r,n,a,o,l=e.useRadians===!0?2*Math.PI:360,h=1e-6;for(i in e)"useRadians"!==i&&(o=(e[i]+"").split("_"),s=o[0],r=parseFloat("function"!=typeof t[i]?t[i]:t[i.indexOf("set")||"function"!=typeof t["get"+i.substr(3)]?i:"get"+i.substr(3)]()),n=this.finals[i]="string"==typeof s&&"="===s.charAt(1)?r+parseInt(s.charAt(0)+"1",10)*Number(s.substr(2)):Number(s)||0,a=n-r,o.length&&(s=o.join("_"),-1!==s.indexOf("short")&&(a%=l,a!==a%(l/2)&&(a=0>a?a+l:a-l)),-1!==s.indexOf("_cw")&&0>a?a=(a+9999999999*l)%l-(0|a/l)*l:-1!==s.indexOf("ccw")&&a>0&&(a=(a-9999999999*l)%l-(0|a/l)*l)),(a>h||-h>a)&&(this._addTween(t,i,r,r+a,i),this._overwriteProps.push(i)));return!0},set:function(t){var e;if(1!==t)this._super.setRatio.call(this,t);else for(e=this._firstPT;e;)e.f?e.t[e.p](this.finals[e.p]):e.t[e.p]=this.finals[e.p],e=e._next}})._autoCSS=!0}),window._gsDefine&&window._gsQueue.pop()();
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: beta 0.1.5
* DATE: 2013-08-29
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t,e,i=/(\d|\.)+/g,s=["redMultiplier","greenMultiplier","blueMultiplier","alphaMultiplier","redOffset","greenOffset","blueOffset","alphaOffset"],r={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},n=function(t){return""===t||null==t||"none"===t?r.transparent:r[t]?r[t]:"number"==typeof t?[t>>16,255&t>>8,255&t]:"#"===t.charAt(0)?(4===t.length&&(t="#"+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)+t.charAt(3)+t.charAt(3)),t=parseInt(t.substr(1),16),[t>>16,255&t>>8,255&t]):t.match(i)||r.transparent},a=function(e,i,r){if(!t&&(t=window.ColorFilter||window.createjs.ColorFilter,!t))throw"EaselPlugin error: The EaselJS ColorFilter JavaScript file wasn't loaded.";for(var a,o,l,h,u,_=e.filters||[],p=_.length;--p>-1;)if(_[p]instanceof t){o=_[p];break}if(o||(o=new t,_.push(o),e.filters=_),l=o.clone(),null!=i.tint)a=n(i.tint),h=null!=i.tintAmount?Number(i.tintAmount):1,l.redOffset=Number(a[0])*h,l.greenOffset=Number(a[1])*h,l.blueOffset=Number(a[2])*h,l.redMultiplier=l.greenMultiplier=l.blueMultiplier=1-h;else for(u in i)"exposure"!==u&&"brightness"!==u&&(l[u]=Number(i[u]));for(null!=i.exposure?(l.redOffset=l.greenOffset=l.blueOffset=255*(Number(i.exposure)-1),l.redMultiplier=l.greenMultiplier=l.blueMultiplier=1):null!=i.brightness&&(h=Number(i.brightness)-1,l.redOffset=l.greenOffset=l.blueOffset=h>0?255*h:0,l.redMultiplier=l.greenMultiplier=l.blueMultiplier=1-Math.abs(h)),p=8;--p>-1;)u=s[p],o[u]!==l[u]&&r._addTween(o,u,o[u],l[u],"easel_colorFilter");if(r._overwriteProps.push("easel_colorFilter"),!e.cacheID)throw"EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. "+e},o=[1,0,0,0,0,0,1,0,0,0,0,0,1,0,0,0,0,0,1,0],l=.212671,h=.71516,u=.072169,_=function(t,e){if(!(t instanceof Array&&e instanceof Array))return e;var i,s,r=[],n=0,a=0;for(i=0;4>i;i++){for(s=0;5>s;s++)a=4===s?t[n+4]:0,r[n+s]=t[n]*e[s]+t[n+1]*e[s+5]+t[n+2]*e[s+10]+t[n+3]*e[s+15]+a;n+=5}return r},p=function(t,e){if(isNaN(e))return t;var i=1-e,s=i*l,r=i*h,n=i*u;return _([s+e,r,n,0,0,s,r+e,n,0,0,s,r,n+e,0,0,0,0,0,1,0],t)},f=function(t,e,i){isNaN(i)&&(i=1);var s=n(e),r=s[0]/255,a=s[1]/255,o=s[2]/255,p=1-i;return _([p+i*r*l,i*r*h,i*r*u,0,0,i*a*l,p+i*a*h,i*a*u,0,0,i*o*l,i*o*h,p+i*o*u,0,0,0,0,0,1,0],t)},c=function(t,e){if(isNaN(e))return t;e*=Math.PI/180;var i=Math.cos(e),s=Math.sin(e);return _([l+i*(1-l)+s*-l,h+i*-h+s*-h,u+i*-u+s*(1-u),0,0,l+i*-l+.143*s,h+i*(1-h)+.14*s,u+i*-u+s*-.283,0,0,l+i*-l+s*-(1-l),h+i*-h+s*h,u+i*(1-u)+s*u,0,0,0,0,0,1,0,0,0,0,0,1],t)},d=function(t,e){return isNaN(e)?t:(e+=.01,_([e,0,0,0,128*(1-e),0,e,0,0,128*(1-e),0,0,e,0,128*(1-e),0,0,0,1,0],t))},m=function(t,i,s){if(!e&&(e=window.ColorMatrixFilter||window.createjs.ColorMatrixFilter,!e))throw"EaselPlugin error: The EaselJS ColorMatrixFilter JavaScript file wasn't loaded.";for(var r,n,a,l=t.filters||[],h=l.length;--h>-1;)if(l[h]instanceof e){a=l[h];break}for(a||(a=new e(o.slice()),l.push(a),t.filters=l),n=a.matrix,r=o.slice(),null!=i.colorize&&(r=f(r,i.colorize,Number(i.colorizeAmount))),null!=i.contrast&&(r=d(r,Number(i.contrast))),null!=i.hue&&(r=c(r,Number(i.hue))),null!=i.saturation&&(r=p(r,Number(i.saturation))),h=r.length;--h>-1;)r[h]!==n[h]&&s._addTween(n,h,n[h],r[h],"easel_colorMatrixFilter");if(s._overwriteProps.push("easel_colorMatrixFilter"),!t.cacheID)throw"EaselPlugin warning: for filters to display in EaselJS, you must call the object's cache() method first. "+t;s._matrix=n};window._gsDefine.plugin({propName:"easel",priority:-1,API:2,init:function(t,e){this._target=t;var i,s,r,n;for(i in e)"colorFilter"===i||"tint"===i||"tintAmount"===i||"exposure"===i||"brightness"===i?r||(a(t,e.colorFilter||e,this),r=!0):"saturation"===i||"contrast"===i||"hue"===i||"colorize"===i||"colorizeAmount"===i?n||(m(t,e.colorMatrixFilter||e,this),n=!0):"frame"===i?(this._firstPT=s={_next:this._firstPT,t:t,p:"gotoAndStop",s:t.currentFrame,f:!0,n:"frame",pr:0,type:0,r:!0},s.c="number"==typeof e[i]?e[i]-s.s:"string"==typeof e[i]?parseFloat(e[i].split("=").join("")):0,s._next&&(s._next._prev=s)):null!=t[i]&&(this._firstPT=s={_next:this._firstPT,t:t,p:i,f:"function"==typeof t[i],n:i,pr:0,type:0},s.s=s.f?t[i.indexOf("set")||"function"!=typeof t["get"+i.substr(3)]?i:"get"+i.substr(3)]():parseFloat(t[i]),s.c="number"==typeof e[i]?e[i]-s.s:"string"==typeof e[i]?parseFloat(e[i].split("=").join("")):0,s._next&&(s._next._prev=s));return!0},set:function(t){for(var e,i=this._firstPT,s=1e-6;i;)e=i.c*t+i.s,i.r?e=e+(e>0?.5:-.5)>>0:s>e&&e>-s&&(e=0),i.f?i.t[i.p](e):i.t[i.p]=e,i=i._next;this._target.cacheID&&this._target.updateCache()}})}),window._gsDefine&&window._gsQueue.pop()();
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: 0.4.1
* DATE: 2013-07-10
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t,e,i,r={setScale:1,setShadowOffset:1,setFillPatternOffset:1,setOffset:1,setFill:2,setStroke:2,setShadowColor:2},s={},n={},a={},o=/(\d|\.)+/g,l=/(?:_cw|_ccw|_short)/,h=window._gsDefine.globals.com.greensock.plugins,u={aqua:[0,255,255],lime:[0,255,0],silver:[192,192,192],black:[0,0,0],maroon:[128,0,0],teal:[0,128,128],blue:[0,0,255],navy:[0,0,128],white:[255,255,255],fuchsia:[255,0,255],olive:[128,128,0],yellow:[255,255,0],orange:[255,165,0],gray:[128,128,128],purple:[128,0,128],green:[0,128,0],red:[255,0,0],pink:[255,192,203],cyan:[0,255,255],transparent:[255,255,255,0]},_=function(t,e,i){return t=0>t?t+1:t>1?t-1:t,0|255*(1>6*t?e+6*(i-e)*t:.5>t?i:2>3*t?e+6*(i-e)*(2/3-t):e)+.5},p=function(t){if(""===t||null==t||"none"===t)return u.transparent;if(u[t])return u[t];if("number"==typeof t)return[t>>16,255&t>>8,255&t];if("#"===t.charAt(0))return 4===t.length&&(t="#"+t.charAt(1)+t.charAt(1)+t.charAt(2)+t.charAt(2)+t.charAt(3)+t.charAt(3)),t=parseInt(t.substr(1),16),[t>>16,255&t>>8,255&t];if("hsl"===t.substr(0,3)){t=t.match(o);var e=Number(t[0])%360/360,i=Number(t[1])/100,r=Number(t[2])/100,s=.5>=r?r*(i+1):r+i-r*i,n=2*r-s;return t.length>3&&(t[3]=Number(t[3])),t[0]=_(e+1/3,n,s),t[1]=_(e,n,s),t[2]=_(e-1/3,n,s),t}for(var a=t.match(o)||u.transparent,l=a.length;--l>-1;)a[l]=Number(a[l]);return a},f=function(t,e,i,r){this.getter=e,this.setter=i;var s=p(t[e]());this.proxy={r:s[0],g:s[1],b:s[2],a:s.length>3?s[3]:1},r&&(this._next=r,r._prev=this)},c=[],d=function(){var i=c.length;if(0!==i){for(;--i>-1;)c[i].draw(),c[i]._gsDraw=!1;c.length=0}else t.removeEventListener("tick",d),e=!1},m=function(t,e){var i="x"===e?"y":"x",r=e.toUpperCase(),o="get"+t.substr(3),l="_gs_"+t;s[t+r]=o+r,n[t+r]=function(){return this[o]()[e]},a[t+r]=function(r){var s=this[o](),n=this[l];return n||(n=this[l]={}),n[e]=r,n[i]=s[i],this[t](n),this}},g=function(t,e){var i,o,l,h,u,_=[];for(i in e)if(l=e[i],"bezier"!==i&&"autoDraw"!==i&&"set"!==i.substr(0,3)&&void 0===t[i]&&(_.push(i),delete e[i],i="set"+i.charAt(0).toUpperCase()+i.substr(1),e[i]=l),o=s[i]){if(1===r[i])return e[i+"X"]=e[i+"Y"]=e[i],delete e[i],g(t,e);!t[i]&&a[i]&&(u=t.prototype||t,u[i]=a[i],u[o]=n[i])}else if("bezier"===i)for(l=l instanceof Array?l:l.values||[],h=l.length;--h>-1;)0===h?_=_.concat(g(t,l[h])):g(t,l[h]);return _},v=function(t){var e,i={};for(e in t)i[e]=t[e];return i};for(i in r)s[i]="get"+i.substr(3),1===r[i]&&(m(i,"x"),m(i,"y"));window._gsDefine.plugin({propName:"kinetic",API:2,init:function(e,i,n){var a,o,u,_,c,d;this._overwriteProps=g(e,i),this._target=e,this._layer=i.autoDraw!==!1?e.getLayer():null,!t&&this._layer&&(t=n.constructor.ticker);for(a in i){if(o=i[a],2===r[a])u=s[a],_=this._firstSP=new f(e,u,a,this._firstSP),o=p(o),_.proxy.r!==o[0]&&this._addTween(_.proxy,"r",_.proxy.r,o[0],a),_.proxy.g!==o[1]&&this._addTween(_.proxy,"g",_.proxy.g,o[1],a),_.proxy.b!==o[2]&&this._addTween(_.proxy,"b",_.proxy.b,o[2],a),(o.length>3||1!==_.proxy.a)&&_.proxy.a!==o[3]&&this._addTween(_.proxy,"a",_.proxy.a,o.length>3?o[3]:1,a);else if("bezier"===a){if(c=h.BezierPlugin,!c)throw"BezierPlugin not loaded";c=this._bezier=new c,"object"==typeof o&&o.autoRotate===!0&&(o.autoRotate=["setX","setY","setRotation",0,!0]),c._onInitTween(e,o,n),this._overwriteProps=this._overwriteProps.concat(c._overwriteProps),this._addTween(c,"setRatio",0,1,a)}else if("setRotation"!==a&&"setRotationDeg"!==a||"string"!=typeof o||!l.test(o))"autoDraw"!==a&&this._addTween(e,a,("function"==typeof e[a]?e["get"+a.substr(3)]():e[a])||0,o,a);else{if(d=h.DirectionalRotationPlugin,!d)throw"DirectionalRotationPlugin not loaded";d=this._directionalRotation=new d,u={useRadians:"setRotation"===a},u[a]=o,d._onInitTween(e,u,n),this._addTween(d,"setRatio",0,1,a)}this._overwriteProps.push(a)}return!0},kill:function(t){return t=v(t),g(this._target,t),this._bezier&&this._bezier._kill(t),this._directionalRotation&&this._directionalRotation._kill(t),this._super._kill.call(this,t)},round:function(t,e){return t=v(t),g(this._target,t),this._bezier&&this._bezier._roundProps(t,e),this._super._roundProps.call(this,t,e)},set:function(i){this._super.setRatio.call(this,i);var r,s,n=this._firstSP,a=this._layer;if(n)for(r=this._target;n;)s=n.proxy,r[n.setter]((1!==s.a?"rgba(":"rgb(")+(0|s.r)+", "+(0|s.g)+", "+(0|s.b)+(1!==s.a?", "+s.a:"")+")"),n=n._next;a&&!a._gsDraw&&(c.push(a),a._gsDraw=!0,e||(t.addEventListener("tick",d),e=!0))}})}),window._gsDefine&&window._gsQueue.pop()();
File diff suppressed because one or more lines are too long
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: beta 1.4.0
* DATE: 2013-02-27
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=window._gsDefine.plugin({propName:"roundProps",priority:-1,API:2,init:function(t,e,i){return this._tween=i,!0}}),e=t.prototype;e._onInitAllProps=function(){for(var t,e,i,r=this._tween,s=r.vars.roundProps instanceof Array?r.vars.roundProps:r.vars.roundProps.split(","),n=s.length,a={},o=r._propLookup.roundProps;--n>-1;)a[s[n]]=1;for(n=s.length;--n>-1;)for(t=s[n],e=r._firstPT;e;)i=e._next,e.pg?e.t._roundProps(a,!0):e.n===t&&(this._add(e.t,t,e.s,e.c),i&&(i._prev=e._prev),e._prev?e._prev._next=i:r._firstPT===e&&(r._firstPT=i),e._next=e._prev=null,r._propLookup[t]=o),e=i;return!1},e._add=function(t,e,i,r){this._addTween(t,e,i,i+r,e,!0),this._overwriteProps.push(e)}}),window._gsDefine&&window._gsQueue.pop()();
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: beta 1.7.1
* DATE: 2013-10-23
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
**/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=document.documentElement,e=window,i=function(i,s){var r="x"===s?"Width":"Height",n="scroll"+r,a="client"+r,o=document.body;return i===e||i===t||i===o?Math.max(t[n],o[n])-(e["inner"+r]||Math.max(t[a],o[a])):i[n]-i["offset"+r]},s=window._gsDefine.plugin({propName:"scrollTo",API:2,init:function(t,s,r){return this._wdw=t===e,this._target=t,this._tween=r,"object"!=typeof s&&(s={y:s}),this._autoKill=s.autoKill!==!1,this.x=this.xPrev=this.getX(),this.y=this.yPrev=this.getY(),null!=s.x?this._addTween(this,"x",this.x,"max"===s.x?i(t,"x"):s.x,"scrollTo_x",!0):this.skipX=!0,null!=s.y?this._addTween(this,"y",this.y,"max"===s.y?i(t,"y"):s.y,"scrollTo_y",!0):this.skipY=!0,!0},set:function(t){this._super.setRatio.call(this,t);var i=this._wdw||!this.skipX?this.getX():this.xPrev,s=this._wdw||!this.skipY?this.getY():this.yPrev,r=s-this.yPrev,n=i-this.xPrev;this._autoKill&&(!this.skipX&&(n>7||-7>n)&&(this.skipX=!0),!this.skipY&&(r>7||-7>r)&&(this.skipY=!0),this.skipX&&this.skipY&&this._tween.kill()),this._wdw?e.scrollTo(this.skipX?i:this.x,this.skipY?s:this.y):(this.skipY||(this._target.scrollTop=this.y),this.skipX||(this._target.scrollLeft=this.x)),this.xPrev=this.x,this.yPrev=this.y}}),r=s.prototype;s.max=i,r.getX=function(){return this._wdw?null!=e.pageXOffset?e.pageXOffset:null!=t.scrollLeft?t.scrollLeft:document.body.scrollLeft:this._target.scrollLeft},r.getY=function(){return this._wdw?null!=e.pageYOffset?e.pageYOffset:null!=t.scrollTop?t.scrollTop:document.body.scrollTop:this._target.scrollTop},r._kill=function(t){return t.scrollTo_x&&(this.skipX=!0),t.scrollTo_y&&(this.skipY=!0),this._super._kill.call(this,t)}}),window._gsDefine&&window._gsQueue.pop()();
+12
View File
@@ -0,0 +1,12 @@
/*!
* VERSION: 0.5.0
* DATE: 2013-07-10
* UPDATES AND DOCS AT: http://www.greensock.com
*
* @license Copyright (c) 2008-2013, GreenSock. All rights reserved.
* This work is subject to the terms at http://www.greensock.com/terms_of_use.html or for
* Club GreenSock members, the software agreement that was issued with your membership.
*
* @author: Jack Doyle, jack@greensock.com
*/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=function(e){var i=e.nodeType,s="";if(1===i||9===i||11===i){if("string"==typeof e.textContent)return e.textContent;for(e=e.firstChild;e;e=e.nextSibling)s+=t(e)}else if(3===i||4===i)return e.nodeValue;return s},e=window._gsDefine.plugin({propName:"text",API:2,init:function(e,i,s){var r,n;if(!("innerHTML"in e))return!1;if(this._target=e,"object"!=typeof i&&(i={value:i}),void 0===i.value)return this._text=this._original=[""],!0;for(this._delimiter=i.delimiter||"",this._original=t(e).replace(/\s+/g," ").split(this._delimiter),this._text=i.value.replace(/\s+/g," ").split(this._delimiter),this._runBackwards=s.vars.runBackwards===!0,this._runBackwards&&(r=this._original,this._original=this._text,this._text=r),"string"==typeof i.newClass&&(this._newClass=i.newClass,this._hasClass=!0),"string"==typeof i.oldClass&&(this._oldClass=i.oldClass,this._hasClass=!0),r=this._original.length-this._text.length,n=0>r?this._original:this._text,this._fillChar=i.fillChar||(i.padSpace?"&nbsp;":""),0>r&&(r=-r);--r>-1;)n.push(this._fillChar);return!0},set:function(t){t>1?t=1:0>t&&(t=0),this._runBackwards&&(t=1-t);var e,i,s,r=this._text.length,n=0|t*r+.5;this._hasClass?(e=this._newClass&&0!==n,i=this._oldClass&&n!==r,s=(e?"<span class='"+this._newClass+"'>":"")+this._text.slice(0,n).join(this._delimiter)+(e?"</span>":"")+(i?"<span class='"+this._oldClass+"'>":"")+this._delimiter+this._original.slice(n).join(this._delimiter)+(i?"</span>":"")):s=this._text.slice(0,n).join(this._delimiter)+this._delimiter+this._original.slice(n).join(this._delimiter),this._target.innerHTML="&nbsp;"===this._fillChar&&-1!==s.indexOf(" ")?s.split(" ").join("&nbsp;&nbsp;"):s}}),i=e.prototype;i._newClass=i._oldClass=i._delimiter=""}),window._gsDefine&&window._gsQueue.pop()();
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -9,4 +9,4 @@
*
* @author: Jack Doyle, jack@greensock.com
**/
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=window._gsDefine.plugin({propName:"roundProps",priority:-1,API:2,init:function(t,e,i){return this._tween=i,!0}}),e=t.prototype;e._onInitAllProps=function(){for(var t,e,i,s=this._tween,r=s.vars.roundProps instanceof Array?s.vars.roundProps:s.vars.roundProps.split(","),n=r.length,a={},o=s._propLookup.roundProps;--n>-1;)a[r[n]]=1;for(n=r.length;--n>-1;)for(t=r[n],e=s._firstPT;e;)i=e._next,e.pg?e.t._roundProps(a,!0):e.n===t&&(this._add(e.t,t,e.s,e.c),i&&(i._prev=e._prev),e._prev?e._prev._next=i:s._firstPT===e&&(s._firstPT=i),e._next=e._prev=null,s._propLookup[t]=o),e=i;return!1},e._add=function(t,e,i,s){this._addTween(t,e,i,i+s,e,!0),this._overwriteProps.push(e)}}),window._gsDefine&&window._gsQueue.pop()();
(window._gsQueue||(window._gsQueue=[])).push(function(){"use strict";var t=window._gsDefine.plugin({propName:"roundProps",priority:-1,API:2,init:function(t,e,i){return this._tween=i,!0}}),e=t.prototype;e._onInitAllProps=function(){for(var t,e,i,r=this._tween,s=r.vars.roundProps instanceof Array?r.vars.roundProps:r.vars.roundProps.split(","),n=s.length,a={},o=r._propLookup.roundProps;--n>-1;)a[s[n]]=1;for(n=s.length;--n>-1;)for(t=s[n],e=r._firstPT;e;)i=e._next,e.pg?e.t._roundProps(a,!0):e.n===t&&(this._add(e.t,t,e.s,e.c),i&&(i._prev=e._prev),e._prev?e._prev._next=i:r._firstPT===e&&(r._firstPT=i),e._next=e._prev=null,r._propLookup[t]=o),e=i;return!1},e._add=function(t,e,i,r){this._addTween(t,e,i,i+r,e,!0),this._overwriteProps.push(e)}}),window._gsDefine&&window._gsQueue.pop()();
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -1,7 +1,7 @@
{
"name": "gsap",
"filename": "TweenMax.min.js",
"version": "1.11.1",
"version": "1.11.2",
"description": "GreenSock Animation Platform (GSAP) is a suite of tools for scripted animation, including TweenLite, TweenMax, TimelineLite, TimelineMax, various easing equations (EasePack), plugins for things like animating along Bezier paths, tweening RaphaelJS objects, etc. and it also includes a jQuery plugin that hijacks the native jQuery.animate() method so that animations perform much better and additional properties can be tweened, like colors, transforms (2D and 3D), boxShadow, borderRadius, clip, and lots more. GSAP has no dependencies on jQuery and it can animate ANY numeric property of ANY object.",
"homepage": "http://www.greensock.com/gsap-js/",
"keywords": [
Binary file not shown.
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+29
View File
@@ -0,0 +1,29 @@
{
"name": "hydna",
"filename": "hydna.min.js",
"version": "1.0.0",
"author": "Johan Dahlberg",
"description": "A multi-transport Hydna client library with support for WebSockets, Flash and Comet",
"homepage": "https://www.hydna.com",
"keywords": [
"wink",
"messaging",
"real-time",
"hydna",
"networking",
"pubsub",
"websockets"
],
"maintainers": [
{
"name": "Johan Dahlberg",
"web": "http://jfd.github.io"
}
],
"repositories": [
{
"type": "git",
"url": "https://github.com/hydna/hydnajs.git"
}
]
}
View File
+1
View File
@@ -0,0 +1 @@
*.js
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
@@ -0,0 +1,112 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
/* Base input element Styles */
.ui-input-datebox { width: 97%; background-image: none; padding: .4em; line-height: 1.4; font-size: 16px; display: block; padding-top: 0px; padding-bottom: 0px; background-color: transparent; }
.ui-input-datebox { min-height: 38px; } /* Fix for IE8 */
.ui-datebox-container > .ui-header:first-child { -webkit-border-top-left-radius: 3px; border-top-left-radius: 3px; -webkit-border-top-right-radius: 3px; border-top-right-radius: 3px; }
/*.ui-input-datebox .ui-btn-icon-notext { margin-top: 5px !important; margin-bottom: 5px !important; }*/
.ui-input-datebox input { width: 100% !important; padding: 0 !important; margin-top: 5px !important; margin-right: -40px !important; border: 1px solid transparent !important; vertical-align: middle; display: inline-block !important; background-color: transparent; zoom: 1; *display: inline; }
.ui-input-datebox input:focus { outline: none;}
.ui-input-datebox .ui-btn-text {display: none;}
.ui-input-datebox.ui-mini { min-height: 20px; font-size: 14px; }
/*.ui-input-datebox.ui-mini .ui-btn-icon-notext { margin-top: 2px !important; margin-bottom: 2px !important; }*/
.ui-icon-datebox { background-image: url('image/datebox.png') !important; background-repeat: no-repeat !important; background-position: 99% 8px !important; }
.ui-icon-datebox-alt { background-image: url('image/datebox.png') !important; background-repeat: no-repeat !important; background-position: 99% -28px !important; }
.ui-mini.ui-icon-datebox { background-position: 99% 6px; }
.ui-mini.ui-icon-datebox-alt { background-position: 99% -30px; }
@media all and (min-width: 450px){
.ui-field-contain .ui-input-datebox { width: 74.7%; display: inline-block; }
.ui-hide-label .ui-input-datebox { width: 100%; }
}
/* Full width if in a grid, ignore the media query */
.ui-grid-a .ui-input-datebox { width: 97%; }
.ui-grid-b .ui-input-datebox { width: 97%; }
.ui-grid-c .ui-input-datebox { width: 97%; }
.ui-grid-d .ui-input-datebox { width: 97%; }
.ui-grid-e .ui-input-datebox { width: 97%; }
/* Define a grid, just in case. */
/* grid d: 16.65/16.65/16.65/16.65/16.65/16.65 */
.ui-grid-e .ui-block-a, .ui-grid-e .ui-block-b, .ui-grid-e .ui-block-c, .ui-grid-e .ui-block-d, .ui-grid-e .ui-block-e, .ui-grid-e .ui-block-f { width: 16.65%; }
.ui-grid-e > :nth-child(n) { width: 16.65%; }
.ui-grid-e .ui-block-a { clear: left; }
.ui-grid-e { overflow: hidden; }
.ui-block-f { margin: 0; padding: 0; border: 0; float: left; min-height: 1px; -webkit-box-sizing: border-box; -moz-box-sizing: border-box; -ms-box-sizing: border-box; box-sizing: border-box; }
/* Calendar Mode Styles */
.ui-datebox-gridheader { text-align: center; }
.ui-datebox-gridheader h4 { text-align: center; display: inline-block; margin-top: 10px; margin-bottom: 10px; zoom:1; *display: inline;}
.ui-datebox-gridplus { float: right; }
.ui-datebox-gridminus { float: left; }
.ui-datebox-gridplus-rtl { float: left; }
.ui-datebox-gridminus-rtl { float: right; }
.ui-datebox-gridrow { margin-left: 5px; margin-right: 5px; margin-bottom: -7px; }
.ui-datebox-grid { clear: both; margin-bottom: 5px; }
.ui-datebox-griddate { width: 36px; height: 30px; padding: 0px; display: inline-block; vertical-align: middle; text-align: center; line-height: 30px; font-weight: bold; font-size: 12px; zoom:1; *display: inline;}
.ui-datebox-griddate-week { width: 31px; height: 30px; display: inline-block; vertical-align: middle; text-align: center; line-height: 30px; font-weight: bold; font-size: 12px; zoom:1; *display: inline;}
.ui-datebox-griddate-empty { border: 1px solid transparent; color: #888; }
.ui-datebox-griddate-label { height: 15px !important; line-height: 15px !important; color: black;}
.ui-datebox-griddate-disable { color: #888; }
/* Android Mode Styles */
.ui-datebox-header h4 { margin-top: 5px; margin-bottom: 5px; text-align: center; }
.ui-datebox-container fieldset div { margin: 0px !important; }
.ui-datebox-dboxin input { padding: .4em 0 !important; text-align: center; width:95%; }
.ui-datebox-dboxin label { width: 100%; text-align: center; display: block; margin-top: 5px; margin-bottom: -8px; }
.ui-datebox-controls { text-align: center; }
.ui-datebox-controls div { width: 77px; text-align: center; display: inline-block; zoom: 1; *display: inline;}
.ui-datebox-scontrols { text-align: center; }
.ui-datebox-scontrols div { width: 55px; text-align: center; display: inline-block; zoom: 1; *display: inline;}
.ui-datebox-scontrols .ui-datebox-sinput { width: 68px; }
.ui-datebox-scontrols .ui-datebox-sinput input { width: 48px; text-align: center; margin-left: 3px; }
.ui-datebox-input { width: 74px !important; margin-left: 1px; margin-right: 1px; text-align: center !important; display: inline-block !important; zoom:1; *display: inline; }
/* Slide Mode Styles */
.ui-datebox-slide { width: 280px; margin-left: auto; margin-right: auto;}
.ui-datebox-sliderow-d { margin-bottom: 5px; text-align: center; height: 40px; width: 280px; overflow: hidden;}
.ui-datebox-sliderow-ym { margin-bottom: 5px; text-align: center; height: 32px; width: 280px; overflow: hidden;}
.ui-datebox-sliderow-hi { text-align: center; height: 32px; width: 280px; overflow: hidden;}
.ui-datebox-sliderow-int { display: inline-block; white-space: nowrap;}
.ui-datebox-slide .ui-btn { margin: 0px; padding: 0px 1em; }
.ui-datebox-slideyear { text-align: center; display: inline-block; zoom:1; *display:inline; width: 84px; vertical-align: middle; line-height: 30px; height: 30px; font-size: 14px; font-weight: bold; }
.ui-datebox-slidemonth { text-align: center; display: inline-block; zoom:1; *display:inline; width: 51px; vertical-align: middle; line-height: 30px; height: 30px; font-size: 12px; font-weight: bold; }
.ui-datebox-slideday { text-align: center; display: inline-block; zoom:1; *display:inline; width: 32px; vertical-align: middle; line-height: 20px; height: 38px; font-size: 14px; font-weight: bold; }
.ui-datebox-slidehour { text-align: center; display: inline-block; zoom:1; *display:inline; width: 32px; vertical-align: middle; line-height: 22px; height: 24px; font-size: 14px; font-weight: bold; }
.ui-datebox-slidemins { text-align: center; display: inline-block; zoom:1; *display:inline; width: 32px; vertical-align: middle; line-height: 22px; height: 24px; font-size: 14px; font-weight: bold; }
.ui-datebox-slidearrow { text-align: center; display: inline-block; zoom:1; *display:inline; width: 10px; vertical-align: middle; line-height: 38px; height: 38px; font-size: 10px; font-weight: bold; }
.ui-datebox-slidewday { font-size: 10px; font-weight: normal; }
/* Flip Mode Styles */
.ui-datebox-flipcontent { text-align: center; height: 125px; margin-bottom: -40px;}
.ui-datebox-flipcontent div { margin-left: 3px; margin-right: 3px; width: 77px; height: 120px; display: inline-block; text-align: center; zoom: 1; *display: inline; overflow: hidden;}
.ui-datebox-flipcontentd div { width: 60px; }
.ui-datebox-flipcenter { border: 1px solid #eee; height: 40px; margin-left: 10px; width: 260px; margin-right: auto; margin-left: auto; position: relative; top: -45px;}
.ui-datebox-flipcontent ul { list-style-type: none; display: inline; }
.ui-datebox-flipcontent li { height: 30px; }
.ui-datebox-flipcontent li span { margin-top: 7px; display: block; }
/* Shared Styles */
.ui-datebox-container { border: 5px solid #111 !important; width: 280px; -webkit-transform:translate3d(0,0,0); }
.ui-datebox-screen { position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; }
.ui-datebox-screen-modal { background-color: black; -moz-opacity: 0.8; opacity:.80; filter: alpha(opacity=80); }
.ui-datebox-hidden { display: none; }
.ui-dialog .ui-datebox-container { border: none !important; }
.ui-popup-container .ui-datebox-container { border: none !important; }
.ui-popup-container .ui-datebox-gridrow { margin-left: 0px; margin-right: 0px; }
.ui-datebox-collapse a { display: inline-block; width: 45% }
.ui-datebox-inline { margin-top: 5px; border: 5px solid #111111 !important; margin-left: auto; margin-right: auto; text-align: center; }
.ui-datebox-inlineblind { margin-top: 5px; border: 5px solid #111111 !important; margin-left: auto; margin-right: auto; text-align: center; }
File diff suppressed because one or more lines are too long
@@ -0,0 +1,375 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
/* CALBOX Mode */
// Version Notes: <140 :: New button theme method, still use _hoover
(function($) {
$.extend( $.mobile.datebox.prototype.options, {
themeDateToday: 'b',
themeDayHigh: 'b',
themeDatePick: 'b',
themeDateHigh: 'b',
themeDateHighAlt: 'b',
themeDateHighRec: 'b',
themeDate: 'a',
calHighToday: true,
calHighPick: true,
calShowDays: true,
calOnlyMonth: false,
calWeekMode: false,
calWeekModeDay: 1,
calWeekHigh: false,
calControlGroup: false,
calShowWeek: false,
calUsePickers: false,
calNoHeader: false,
useTodayButton: false,
useCollapsedBut: false,
highDays: false,
highDates: false,
highDatesRec: false,
highDatesAlt: false,
enableDates: false,
calDateList: false,
calShowDateList: false,
});
$.extend( $.mobile.datebox.prototype, {
_cal_gen: function (start,prev,last,other,month) {
var rc = 0, cc = 0, day = 1,
next = 1, cal = [], row = [], stop = false;
for ( rc = 0; rc <= 5; rc++ ) {
if ( stop === false ) {
row = [];
for ( cc = 0; cc <= 6; cc++ ) {
if ( rc === 0 && cc < start ) {
if ( other === true ) {
row.push([prev + (cc - start) + 1,month-1]);
} else {
row.push(false);
}
} else if ( rc > 3 && day > last ) {
if ( other === true ) {
row.push([next,month+1]); next++;
} else {
row.push(false);
}
stop = true;
} else {
row.push([day,month]); day++;
if ( day > last ) { stop = true; }
}
}
cal.push(row);
}
}
return cal;
},
_cal_check : function (cal, year, month, date) {
var w = this, i,
o = this.options,
ret = {},
day = new this._date(year,month,date,0,0,0,0).getDay();
ret.ok = true;
ret.iso = year + '-' + w._zPad(month+1) + '-' + w._zPad(date);
ret.comp = parseInt(ret.iso.replace(/-/g, ''),10);
ret.theme = o.themeDate;
ret.recok = true;
ret.rectheme = false;
if ( o.blackDatesRec !== false ) {
for ( i=0; i<o.blackDatesRec.length; i++ ) {
if (
( o.blackDatesRec[i][0] === -1 || o.blackDatesRec[i][0] === year ) &&
( o.blackDatesRec[i][1] === -1 || o.blackDatesRec[i][1] === month ) &&
( o.blackDatesRec[i][2] === -1 || o.blackDatesRec[i][2] === date )
) { ret.recok = false; }
}
}
if ( $.isArray(o.enableDates) && $.inArray(ret.iso, o.enableDates) < 0 ) {
ret.ok = false;
} else if ( cal.checkDates ) {
if (
( ret.recok !== true ) ||
( o.afterToday === true && cal.thisDate.comp() > ret.comp ) ||
( o.beforeToday === true && cal.thisDate.comp() < ret.comp ) ||
( o.notToday === true && cal.thisDate.comp() === ret.comp ) ||
( o.maxDays !== false && cal.maxDate.comp() < ret.comp ) ||
( o.minDays !== false && cal.minDate.comp() > ret.comp ) ||
( $.isArray(o.blackDays) && $.inArray(day, o.blackDays) > -1 ) ||
( $.isArray(o.blackDates) && $.inArray(ret.iso, o.blackDates) > -1 )
) {
ret.ok = false;
}
}
if ( ret.ok ) {
if ( o.highDatesRec !== false ) {
for ( i=0; i<o.highDatesRec.length; i++ ) {
if (
( o.highDatesRec[i][0] === -1 || o.highDatesRec[i][0] === year ) &&
( o.highDatesRec[i][1] === -1 || o.highDatesRec[i][1] === month ) &&
( o.highDatesRec[i][2] === -1 || o.highDatesRec[i][2] === date )
) { ret.rectheme = true; }
}
}
if ( o.calHighPick && date === cal.presetDay && ( w.d.input.val() !== "" | o.defaultValue !== false )) {
ret.theme = o.themeDatePick;
} else if ( o.calHighToday && ret.comp === cal.thisDate.comp() ) {
ret.theme = o.themeDateToday;
} else if ( $.isArray(o.highDatesAlt) && ($.inArray(ret.iso, o.highDatesAlt) > -1) ) {
ret.theme = o.themeDateHighAlt;
} else if ( $.isArray(o.highDates) && ($.inArray(ret.iso, o.highDates) > -1) ) {
ret.theme = o.themeDateHigh;
} else if ( $.isArray(o.highDays) && ($.inArray(day, o.highDays) > -1) ) {
ret.theme = o.themeDayHigh;
} else if ( $.isArray(o.highDatesRec) && ret.rectheme === true ) {
ret.theme = o.themeDateHighRec;
}
}
return ret;
}
});
$.extend( $.mobile.datebox.prototype._build, {
'calbox': function () {
var w = this,
o = this.options, i,
cal = false,
uid = 'ui-datebox-',
temp = false, row = false, col = false, hRow = false, checked = false;
if ( typeof w.d.intHTML !== 'boolean' ) {
w.d.intHTML.remove();
}
w.d.headerText = ((w._grabLabel() !== false)?w._grabLabel():w.__('titleDateDialogLabel'));
w.d.intHTML = $('<span>');
$('<div class="'+uid+'gridheader"><div class="'+uid+'gridlabel"><h4>' +
w._formatter(w.__('calHeaderFormat'), w.theDate) +
'</h4></div></div>').appendTo(w.d.intHTML);
// Previous and next month buttons, define booleans to decide if they should do anything
$("<div class='"+uid+"gridplus"+(w.__('isRTL')?'-rtl':'')+"'><a href='#'>"+w.__('nextMonth')+"</a></div>")
.prependTo(w.d.intHTML.find('.'+uid+'gridheader'))
.buttonMarkup({theme: o.themeDate, icon: 'arrow-r', inline: true, iconpos: 'notext', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
if ( w.calNext ) {
if ( w.theDate.getDate() > 28 ) { w.theDate.setDate(1); }
w._offset('m',1);
}
});
$("<div class='"+uid+"gridminus"+(w.__('isRTL')?'-rtl':'')+"'><a href='#'>"+w.__('prevMonth')+"</a></div>")
.prependTo(w.d.intHTML.find('.'+uid+'gridheader'))
.buttonMarkup({theme: o.themeDate, icon: 'arrow-l', inline: true, iconpos: 'notext', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
if ( w.calPrev ) {
if ( w.theDate.getDate() > 28 ) { w.theDate.setDate(1); }
w._offset('m',-1);
}
});
if ( o.calNoHeader === true ) { w.d.intHTML.find('.'+uid+'gridheader').remove(); }
cal = {'today': -1, 'highlightDay': -1, 'presetDay': -1, 'startDay': w.__('calStartDay'),
'thisDate': new w._date(), 'maxDate': w.initDate.copy(), 'minDate': w.initDate.copy(),
'currentMonth': false, 'weekMode': 0, 'weekDays': null };
cal.start = (w.theDate.copy([0],[0,0,1]).getDay() - w.__('calStartDay') + 7) % 7;
cal.thisMonth = w.theDate.getMonth();
cal.thisYear = w.theDate.getFullYear();
cal.wk = w.theDate.copy([0],[0,0,1]).adj(2,(-1*cal.start)+(w.__('calStartDay')===0?1:0)).getDWeek(4);
cal.end = 32 - w.theDate.copy([0],[0,0,32,13]).getDate();
cal.lastend = 32 - w.theDate.copy([0,-1],[0,0,32,13]).getDate();
cal.presetDate = (w.d.input.val() === "") ? w._startOffset(w._makeDate(w.d.input.val())) : w._makeDate(w.d.input.val());
cal.thisDateArr = cal.thisDate.getArray();
cal.theDateArr = w.theDate.getArray();
cal.checkDates = ( $.inArray(false, [o.afterToday, o.beforeToday, o.notToday, o.maxDays, o.minDays, o.blackDates, o.blackDays]) > -1 );
w.calNext = true;
w.calPrev = true;
if ( cal.thisDateArr[0] === cal.theDateArr[0] && cal.thisDateArr[1] === cal.theDateArr[1] ) { cal.currentMonth = true; }
if ( cal.presetDate.comp() === w.theDate.comp() ) { cal.presetDay = cal.presetDate.getDate(); }
if ( o.afterToday === true &&
( cal.currentMonth === true || ( cal.thisDateArr[1] >= cal.theDateArr[1] && cal.theDateArr[0] === cal.thisDateArr[0] ) ) ) {
w.calPrev = false; }
if ( o.beforeToday === true &&
( cal.currentMonth === true || ( cal.thisDateArr[1] <= cal.theDateArr[1] && cal.theDateArr[0] === cal.thisDateArr[0] ) ) ) {
w.calNext = false; }
if ( o.minDays !== false ) {
cal.minDate.adj(2, -1*o.minDays);
if ( cal.theDateArr[0] === cal.minDate.getFullYear() && cal.theDateArr[1] <= cal.minDate.getMonth() ) { w.calPrev = false;}
}
if ( o.maxDays !== false ) {
cal.maxDate.adj(2, o.maxDays);
if ( cal.theDateArr[0] === cal.maxDate.getFullYear() && cal.theDateArr[1] >= cal.maxDate.getMonth() ) { w.calNext = false;}
}
if ( o.calUsePickers === true ) {
cal.picker = $('<div>', {'class': 'ui-grid-a ui-datebox-grid','style':'padding-top: 5px; padding-bottom: 5px;'});
cal.picker1 = $('<div class="ui-block-a"><select name="pickmon"></select></div>').appendTo(cal.picker).find('select');
cal.picker2 = $('<div class="ui-block-b"><select name="pickyar"></select></div>').appendTo(cal.picker).find('select');
for ( i=0; i<=11; i++ ) {
cal.picker1.append($('<option value="'+i+'"'+((cal.thisMonth===i)?' selected="selected"':'')+'>'+w.__('monthsOfYear')[i]+'</option>'));
}
for ( i=(cal.thisYear-6); i<=cal.thisYear+6; i++ ) {
cal.picker2.append($('<option value="'+i+'"'+((cal.thisYear===i)?' selected="selected"':'')+'>'+i+'</option>'));
}
cal.picker1.on('change', function () { w.theDate.setMonth($(this).val()); w.refresh(); });
cal.picker2.on('change', function () { w.theDate.setFullYear($(this).val()); w.refresh(); });
cal.picker.find('select').selectmenu({mini:true, nativeMenu: true});
cal.picker.appendTo(w.d.intHTML);
}
temp = $('<div class="'+uid+'grid">').appendTo(w.d.intHTML);
if ( o.calShowDays ) {
w._cal_days = w.__('daysOfWeekShort').concat(w.__('daysOfWeekShort'));
cal.weekDays = $("<div>", {'class':uid+'gridrow'}).appendTo(temp);
if ( w.__('isRTL') === true ) { cal.weekDays.css('direction', 'rtl'); }
if ( o.calShowWeek ) {
$("<div>").addClass(uid+'griddate '+uid+'griddate-empty '+uid+'griddate-label').appendTo(cal.weekDays);
}
for ( i=0; i<=6;i++ ) {
$("<div>"+w._cal_days[(i+cal.startDay)%7]+"</div>").addClass(uid+'griddate '+uid+'griddate-empty '+uid+'griddate-label').appendTo(cal.weekDays);
}
}
cal.gen = w._cal_gen(cal.start, cal.lastend, cal.end, !o.calOnlyMonth, w.theDate.getMonth());
for ( var row=0, rows=cal.gen.length; row < rows; row++ ) {
hRow = $('<div>', {'class': uid+'gridrow'});
if ( w.__('isRTL') ) { hRow.css('direction', 'rtl'); }
if ( o.calShowWeek ) {
$('<div>', {'class':uid+'griddate '+uid+'griddate-empty'}).text('W'+cal.wk).appendTo(hRow);
cal.wk++;
if ( cal.wk > 52 && typeof cal.gen[parseInt(row,10)+1] !== 'undefined' ) { cal.wk = new Date(cal.theDateArr[0],cal.theDateArr[1],((w.__('calStartDay')===0)?cal.gen[parseInt(row,10)+1][1][0]:cal.gen[parseInt(row,10)+1][0][0])).getDWeek(4); }
}
for ( var col=0, cols=cal.gen[row].length; col<cols; col++ ) {
if ( o.calWeekMode ) { cal.weekMode = cal.gen[row][o.calWeekModeDay][0]; }
if ( typeof cal.gen[row][col] === 'boolean' ) {
$('<div>', {'class':uid+'griddate '+uid+'griddate-empty'}).appendTo(hRow);
} else {
checked = w._cal_check(cal, cal.theDateArr[0], cal.gen[row][col][1], cal.gen[row][col][0]);
if (cal.gen[row][col][0]) {
$("<div>"+String(cal.gen[row][col][0])+"</div>")
.addClass( cal.thisMonth === cal.gen[row][col][1] ?
(uid+'griddate ui-corner-all ui-btn ui-btn-'+(o.mobVer<140?'up-':'')+checked.theme + (checked.ok?'':' '+uid+'griddate-disable')):
(uid+'griddate '+uid+'griddate-empty')
)
.jqmData('date', ((o.calWeekMode)?cal.weekMode:cal.gen[row][col][0]))
.jqmData('theme', cal.thisMonth === cal.gen[row][col][1] ? checked.theme : '-')
.jqmData('enabled', checked.ok)
.jqmData('month', cal.gen[row][((o.calWeekMode)?o.calWeekModeDay:col)][1])
.appendTo(hRow);
}
}
}
if ( o.calControlGroup === true ) {
hRow.find('.ui-corner-all').removeClass('ui-corner-all').eq(0).addClass('ui-corner-left').end().last().addClass('ui-corner-right').addClass('ui-controlgroup-last');
}
hRow.appendTo(temp);
}
if ( o.calShowWeek ) { temp.find('.'+uid+'griddate').addClass(uid+'griddate-week'); }
if ( o.calShowDateList === true && o.calDateList !== false ) {
cal.datelist = $('<div>');
cal.datelistpick = $('<select name="pickdate"></select>').appendTo(cal.datelist);
cal.datelistpick.append('<option value="false" selected="selected">'+w.__('calDateListLabel')+'</option>');
for ( i=0; i<o.calDateList.length; i++ ) {
cal.datelistpick.append($('<option value="'+o.calDateList[i][0]+'">'+o.calDateList[i][1]+'</option>'));
}
cal.datelistpick.on('change', function() {
cal.datelistdate = $(this).val().split('-');
w.theDate = new w._date(cal.datelistdate[0], cal.datelistdate[1]-1, cal.datelistdate[2], 0,0,0,0);
w.d.input.trigger('datebox',{'method':'doset'});
});
cal.datelist.find('select').selectmenu({mini:true, nativeMenu:true});
cal.datelist.appendTo(w.d.intHTML);
}
if ( o.useTodayButton || o.useClearButton ) {
hRow = $('<div>', {'class':uid+'controls'});
if ( o.useTodayButton ) {
$('<a href="#">'+w.__('calTodayButtonLabel')+'</a>')
.appendTo(hRow).buttonMarkup({theme: o.theme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEvent, function(e) {
e.preventDefault();
w.theDate = new w._date();
w.theDate = new w._date(w.theDate.getFullYear(), w.theDate.getMonth(), w.theDate.getDate(),0,0,0,0);
w.d.input.trigger('datebox',{'method':'doset'});
});
}
if ( o.useClearButton ) {
$('<a href="#">'+w.__('clearButton')+'</a>')
.appendTo(hRow).buttonMarkup({theme: o.theme, icon: 'delete', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.val('');
w.d.input.trigger('datebox',{'method':'clear'});
w.d.input.trigger('datebox',{'method':'close'});
});
}
if ( o.useCollapsedBut ) {
hRow.addClass('ui-datebox-collapse');
}
hRow.appendTo(temp);
}
w.d.intHTML.on(o.clickEventAlt+' vmouseover vmouseout', 'div.'+uid+'griddate', function(e) {
if ( e.type === o.clickEventAlt ) {
e.preventDefault();
if ( $(this).jqmData('enabled') ) {
w.theDate.setD(2,1).setD(1,$(this).jqmData('month')).setD(2,$(this).jqmData('date'));
w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(w.__fmt(),w.theDate), 'date':w.theDate});
w.d.input.trigger('datebox', {'method':'close'});
}
} else {
if ( $(this).jqmData('enabled') && typeof $(this).jqmData('theme') !== 'undefined' && o.mobVer < 140 ) {
if ( o.calWeekMode !== false && o.calWeekHigh === true ) {
$(this).parent().find('div').each(function() { w._hoover(this); });
} else { w._hoover(this); }
}
}
});
w.d.intHTML
.on('swipeleft', function() { if ( w.calNext ) { w._offset('m', 1); } })
.on('swiperight', function() { if ( w.calPrev ) { w._offset('m', -1); } });
if ( w.wheelExists) { // Mousewheel operations, if plugin is loaded
w.d.intHTML.on('mousewheel', function(e,d) {
e.preventDefault();
if ( d > 0 && w.calNext ) {
w.theDate.setD(2,1);
w._offset('m', 1);
}
if ( d < 0 && w.calPrev ) {
w.theDate.setD(2,1);
w._offset('m', -1);
}
});
}
}
});
})( jQuery );
File diff suppressed because one or more lines are too long
@@ -0,0 +1,157 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
(function($) {
$.extend( $.mobile.datebox.prototype.options, {
themeButton: 'a',
themeInput: 'a',
useSetButton: true,
customData: [
{'input': true, 'name':'Letter', 'data':['a','b','c','d','e']},
{'input': true, 'name':'Text', 'data':['some','bull','shtuff','here']},
{'input': false, 'name':'Image', 'data':['<img src="img/slot1.png" />','<img src="img/slot2.png" />','<img src="img/slot3.png" />','<img src="img/slot4.png" />']}
],
customDefault: [0,0,0],
customFormat: false,
customboxlang: {
// This structure interfaces with __() -> if it exists, strings are looked up here after i8n fails,
// and before going to 'default' - the name syntax is <mode>lang
'customSet':'Looks Good'
}
});
$.extend( $.mobile.datebox.prototype, {
_cbox_offset: function (fld,amount) {
// This is *not* an automatic override, used below specificly.
var w = this, x,
o = this.options;
tmp = (w.customCurrent[fld] + amount) % o.customData[fld]['data'].length;
if ( tmp < 0 ) { tmp = o.customData[fld]['data'].length + tmp; }
w.customCurrent[fld] = tmp;
if ( o.useImmediate ) { w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(o.customFormat,w.customCurrent), 'date':w.customCurrent}); }
w.refresh();
}
});
$.extend( $.mobile.datebox.prototype._parser, {
// If this stucture exists, it is called instead of the usual date input parser.
// The name of the structure is the same as the mode name - it recieves a string
// as the input, which is the current value of the input element, pre-sanitized
'custombox' : function ( str ) {
return ( str.length < 1 || ! str.match(/,/) ) ? this.options.customDefault : str.split(",");
}
});
$.extend( $.mobile.datebox.prototype._customformat, {
// If this stucture exists, the formatter will call it when it encounters a special string
// %X<whatever> - it recieves the single letter operater, and the current "date" value
'custombox' : function ( oper, val ) {
return val[oper-1];
}
});
$.extend( $.mobile.datebox.prototype._build, {
'custombox': function () {
var w = this,
o = this.options, i, y, tmp, cnt = -2,
uid = 'ui-datebox-',
divBase = $("<div>"),
divPlus = $('<fieldset>'),
divIn = divBase.clone(),
divMinus = divPlus.clone(),
customCurrent = this._makeDate(this.d.input.val()),
inBase = $("<input type='text' />").addClass('ui-input-text ui-corner-all ui-shadow-inset ui-body-'+o.themeInput),
inDiv = $("<div>").addClass('ui-input-text ui-corner-all ui-shadow-inset ui-body-'+o.themeInput).css({'padding':'.4em','margin':'.5em 0','text-align':'center'}),
butBase = $("<div>"),
butPTheme = {theme: o.themeButton, icon: 'plus', iconpos: 'bottom', corners:true, shadow:true},
butMTheme = $.extend({}, butPTheme, {icon: 'minus', iconpos: 'top'});
if ( typeof w.customCurrent === "undefined" ) { w.customCurrent = customCurrent; }
if ( o.customFormat === false ) {
tmp = [];
for ( i = 0; i<o.customData.length; i++ ) {
tmp.push('%X'+(i+1));
}
o.customFormat = tmp.join(',');
}
if ( typeof w.d.intHTML !== 'boolean' ) {
w.d.intHTML.empty().remove();
}
w.d.headerText = ((w._grabLabel() !== false)?w._grabLabel():((o.mode==='datebox')?w.__('titleDateDialogLabel'):w.__('titleTimeDialogLabel')));
w.d.intHTML = $('<span>');
for(i=0; i<o.customData.length; i++) {
tmp = ['a','b','c','d','e','f'][i];
if ( o.customData[i]['input'] === true ) {
$('<div>').append(inBase.clone().attr('value', o.customData[i]['data'][w.customCurrent[i]])).addClass('ui-block-'+tmp).appendTo(divIn);
} else {
$('<div>').append(inDiv.clone().html(o.customData[i]['data'][w.customCurrent[i]])).addClass('ui-block-'+tmp).appendTo(divIn);
}
w._makeEl(butBase, {'attr': {'field':i, 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butPTheme).appendTo(divPlus);
w._makeEl(butBase, {'attr': {'field':i, 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butMTheme).appendTo(divMinus);
cnt++;
}
divPlus.addClass('ui-grid-'+['a','b','c','d','e'][cnt]).appendTo(w.d.intHTML);
divIn.addClass('ui-datebox-dboxin').addClass('ui-grid-'+['a','b','c','d','e'][cnt]).appendTo(w.d.intHTML);
divMinus.addClass('ui-grid-'+['a','b','c','d','e'][cnt]).appendTo(w.d.intHTML);
if (o.mobVer >= 140) {
divMinus.find('div').css({'min-height': '2.3em'});
divPlus.find('div').css({'min-height': '2.3em'});
}
if (o.mobVer >= 140) {
divMinus.find('div').css({'min-height': '2.3em'});
divPlus.find('div').css({'min-height': '2.3em'});
}
if ( o.useSetButton || o.useClearButton ) {
y = $('<div>', {'class':uid+'controls'});
if ( o.useSetButton ) {
$('<a href="#">'+w.__('customSet')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(o.customFormat,w.customCurrent), 'date':w.customCurrent});
w.d.input.trigger('datebox', {'method':'close'});
});
}
if ( o.useClearButton ) {
$('<a href="#">'+w.__('clearButton')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'delete', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.val('');
w.d.input.trigger('datebox',{'method':'clear'});
w.d.input.trigger('datebox',{'method':'close'});
});
}
if ( o.useCollapsedBut ) {
y.addClass('ui-datebox-collapse');
}
y.appendTo(w.d.intHTML);
}
divIn.on('change', 'input', function() { w.refresh(); });
divPlus.on(o.clickEvent, 'div', function(e) {
e.preventDefault();
w._cbox_offset($(this).jqmData('field'), $(this).jqmData('amount'));
});
divMinus.on(o.clickEvent, 'div', function(e) {
e.preventDefault();
w._cbox_offset($(this).jqmData('field'), $(this).jqmData('amount')*-1);
});
}
});
})( jQuery );
@@ -0,0 +1,7 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
(function(a){a.extend(a.mobile.datebox.prototype.options,{themeButton:"a",themeInput:"a",useSetButton:true,customData:[{input:true,name:"Letter",data:["a","b","c","d","e"]},{input:true,name:"Text",data:["some","bull","shtuff","here"]},{input:false,name:"Image",data:['<img src="img/slot1.png" />','<img src="img/slot2.png" />','<img src="img/slot3.png" />','<img src="img/slot4.png" />']}],customDefault:[0,0,0],customFormat:false,customboxlang:{customSet:"Looks Good"}});a.extend(a.mobile.datebox.prototype,{_cbox_offset:function(e,d){var c=this,b,f=this.options;tmp=(c.customCurrent[e]+d)%f.customData[e]["data"].length;if(tmp<0){tmp=f.customData[e]["data"].length+tmp}c.customCurrent[e]=tmp;if(f.useImmediate){c.d.input.trigger("datebox",{method:"set",value:c._formatter(f.customFormat,c.customCurrent),date:c.customCurrent})}c.refresh()}});a.extend(a.mobile.datebox.prototype._parser,{custombox:function(b){return(b.length<1||!b.match(/,/))?this.options.customDefault:b.split(",")}});a.extend(a.mobile.datebox.prototype._customformat,{custombox:function(c,b){return b[c-1]}});a.extend(a.mobile.datebox.prototype._build,{custombox:function(){var t=this,f=this.options,l,s,m,g=-2,q="ui-datebox-",r=a("<div>"),c=a("<fieldset>"),j=r.clone(),k=c.clone(),n=this._makeDate(this.d.input.val()),e=a("<input type='text' />").addClass("ui-input-text ui-corner-all ui-shadow-inset ui-body-"+f.themeInput),h=a("<div>").addClass("ui-input-text ui-corner-all ui-shadow-inset ui-body-"+f.themeInput).css({padding:".4em",margin:".5em 0","text-align":"center"}),p=a("<div>"),b={theme:f.themeButton,icon:"plus",iconpos:"bottom",corners:true,shadow:true},d=a.extend({},b,{icon:"minus",iconpos:"top"});if(typeof t.customCurrent==="undefined"){t.customCurrent=n}if(f.customFormat===false){m=[];for(l=0;l<f.customData.length;l++){m.push("%X"+(l+1))}f.customFormat=m.join(",")}if(typeof t.d.intHTML!=="boolean"){t.d.intHTML.empty().remove()}t.d.headerText=((t._grabLabel()!==false)?t._grabLabel():((f.mode==="datebox")?t.__("titleDateDialogLabel"):t.__("titleTimeDialogLabel")));t.d.intHTML=a("<span>");for(l=0;l<f.customData.length;l++){m=["a","b","c","d","e","f"][l];if(f.customData[l]["input"]===true){a("<div>").append(e.clone().attr("value",f.customData[l]["data"][t.customCurrent[l]])).addClass("ui-block-"+m).appendTo(j)}else{a("<div>").append(h.clone().html(f.customData[l]["data"][t.customCurrent[l]])).addClass("ui-block-"+m).appendTo(j)}t._makeEl(p,{attr:{field:l,amount:1}}).addClass("ui-block-"+m).buttonMarkup(b).appendTo(c);t._makeEl(p,{attr:{field:l,amount:1}}).addClass("ui-block-"+m).buttonMarkup(d).appendTo(k);g++}c.addClass("ui-grid-"+["a","b","c","d","e"][g]).appendTo(t.d.intHTML);j.addClass("ui-datebox-dboxin").addClass("ui-grid-"+["a","b","c","d","e"][g]).appendTo(t.d.intHTML);k.addClass("ui-grid-"+["a","b","c","d","e"][g]).appendTo(t.d.intHTML);if(f.mobVer>=140){k.find("div").css({"min-height":"2.3em"});c.find("div").css({"min-height":"2.3em"})}if(f.mobVer>=140){k.find("div").css({"min-height":"2.3em"});c.find("div").css({"min-height":"2.3em"})}if(f.useSetButton||f.useClearButton){s=a("<div>",{"class":q+"controls"});if(f.useSetButton){a('<a href="#">'+t.__("customSet")+"</a>").appendTo(s).buttonMarkup({theme:f.theme,icon:"check",iconpos:"left",corners:true,shadow:true}).on(f.clickEventAlt,function(i){i.preventDefault();t.d.input.trigger("datebox",{method:"set",value:t._formatter(f.customFormat,t.customCurrent),date:t.customCurrent});t.d.input.trigger("datebox",{method:"close"})})}if(f.useClearButton){a('<a href="#">'+t.__("clearButton")+"</a>").appendTo(s).buttonMarkup({theme:f.theme,icon:"delete",iconpos:"left",corners:true,shadow:true}).on(f.clickEventAlt,function(i){i.preventDefault();t.d.input.val("");t.d.input.trigger("datebox",{method:"clear"});t.d.input.trigger("datebox",{method:"close"})})}if(f.useCollapsedBut){s.addClass("ui-datebox-collapse")}s.appendTo(t.d.intHTML)}j.on("change","input",function(){t.refresh()});c.on(f.clickEvent,"div",function(i){i.preventDefault();t._cbox_offset(a(this).jqmData("field"),a(this).jqmData("amount"))});k.on(f.clickEvent,"div",function(i){i.preventDefault();t._cbox_offset(a(this).jqmData("field"),a(this).jqmData("amount")*-1)})}})})(jQuery);
@@ -0,0 +1,294 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
/* CUSTOMFLIP Mode */
(function($) {
$.extend( $.mobile.datebox.prototype.options, {
themeOptPick: 'b',
themeOpt: 'a',
useSetButton: true,
customData: [
{'input': true, 'name':'Letter', 'data':['a','b','c','d','e']},
{'input': true, 'name':'Text', 'data':['some','bull','shtuff','here']},
{'input': false, 'name':'Image', 'data':['<img src="img/slot1.png" />','<img src="img/slot2.png" />','<img src="img/slot3.png" />','<img src="img/slot4.png" />']}
],
customDefault: [0,0,0],
customFormat: false,
customfliplang: {
// This structure interfaces with __() -> if it exists, strings are looked up here after i8n fails,
// and before going to 'default' - the name syntax is <mode>lang
'customSet':'Looks Good'
}
});
$.extend( $.mobile.datebox.prototype, {
'_customflipDoSet': function () {
// If this function exists, it overrides the 'doset' method of the 'datebox' event.
// The name syntax is _<mode>DoSet
var w = this, o = this.options;
if ( typeof w.customCurrent === 'undefined' ) { w.customCurrent = this._makeDate(this.d.input.val()); }
w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(o.customFormat,w.customCurrent), 'date':w.customCurrent});
},
'_cubox_offset': function (fld, amount) {
// This is *not* an automatic override, used below specificly.
var w = this, x,
o = this.options;
tmp = (w.customCurrent[fld] + amount) % o.customData[fld]['data'].length;
if ( tmp < 0 ) { tmp = o.customData[fld]['data'].length + tmp; }
w.customCurrent[fld] = tmp;
if ( o.useImmediate ) { w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(o.customFormat,w.customCurrent), 'date':w.customCurrent}); }
w.refresh();
},
'_cubox_arr': function (data, choice) {
var base = data, x,
before = data.slice(0,choice),
after = data.slice(choice+1);
while ( before.length < 10 ) {
for ( x = base.length; x > 0; x-- ) {
before.unshift(base[x-1]);
}
}
while ( before.length > 10 ) {
before.shift();
}
while ( after.length < 10 ) {
for ( x = 0; x < base.length; x++ ) {
after.push(base[x]);
}
}
after.length = 10;
before.push(data[choice]);
return $.merge($.merge([], before), after);
},
'_cubox_pos': function () {
var w = this,
ech = null,
top = null,
par = this.d.intHTML.find('.ui-datebox-flipcontent').innerHeight(),
tot = null;
w.d.intHTML.find('.ui-datebox-flipcenter').each(function() {
ech = $(this);
top = ech.innerHeight();
ech.css('top', ((par/2)-(top/2)+4)*-1);
});
w.d.intHTML.find('ul').each(function () {
ech = $(this);
par = ech.parent().innerHeight();
top = ech.find('li').first();
tot = ech.find('li').size() * top.outerHeight();
top.css('marginTop', ((tot/2)-(par/2)+(top.outerHeight()/2))*-1);
});
}
});
$.extend( $.mobile.datebox.prototype._parser, {
// If this stucture exists, it is called instead of the usual date input parser.
// The name of the structure is the same as the mode name - it recieves a string
// as the input, which is the current value of the input element, pre-sanitized
'customflip' : function ( str ) {
var w = this,
o = this.options,
adv = o.customFormat,
exp_input, exp_format, tmp, tmp2, retty_val=[0,0,0,0,0,0];
if ( typeof(adv) !== 'string' ) { adv = ''; }
adv = adv.replace(/%X([0-9a-f])/gi, function(match, oper) {
switch (oper) {
case 'a':
case 'b':
case 'c':
case 'd':
case 'e':
case 'f':
return '(' + match + '|' + '.+?' + ')'; break;
case '0':
case '1':
case '2':
case '3':
case '4':
case '5':
return '(' + match + '|' + '[0-9]+' + ')'; break;
default:
return '.+?';
}
});
adv = new RegExp('^' + adv + '$');
exp_input = adv.exec(str);
exp_format = adv.exec(o.customFormat);
if ( exp_input !== null ) {
for ( var x = 1; x<exp_input.length; x++ ) {
tmp = exp_format[x].charAt(2);
console.log(tmp);
if ( isNaN(parseInt(tmp)) ) {
tmp2 = $.inArray(tmp, ['a','b','c','d','e','f']);
retty_val[tmp2] = $.inArray(exp_input[x], o.customData[tmp2].data);
} else {
retty_val[parseInt(tmp)-1] = parseInt(exp_input[x]);
}
}
}
//outputty = { 'in': exp_input, 'fmt': o.customFormat, 'str': str, 'format': exp_format, 'retty': retty_val };
return ( str.length < 1 || retty_val.length < 1 ) ? this.options.customDefault : retty_val;
}
});
$.extend( $.mobile.datebox.prototype._customformat, {
// If this stucture exists, the formatter will call it when it encounters a special string
// %X<whatever> - it recieves the single letter operater, and the current "date" value
'customflip' : function ( oper, val, o ) {
var per = parseInt(oper), tmp;
if ( typeof(per) === 'number' && !isNaN(per) ) {
return val[oper-1];
} else {
tmp = $.inArray(oper, ['a','b','c','d','e','f']);
return o.customData[tmp].data[val[tmp]];
}
}
});
$.extend( $.mobile.datebox.prototype._build, {
// This builds the actual interface, and is called on *every* refresh. (after each "movement")
'customflip': function () {
var w = this,
o = this.options, i, y, hRow, tmp, lineArr,
uid = 'ui-datebox-',
customCurrent = this._makeDate(this.d.input.val()),
flipBase = $("<div class='ui-overlay-shadow'><ul></ul></div>"),
ctrl = $("<div>", {"class":uid+'flipcontent'});
if ( typeof w.customCurrent === "undefined" ) { w.customCurrent = customCurrent; }
if ( o.customFormat === false ) {
tmp = [];
for ( i = 0; i<o.customData.length; i++ ) {
tmp.push('%X'+(i+1));
}
o.customFormat = tmp.join(',');
}
if ( typeof w.d.intHTML !== 'boolean' ) {
w.d.intHTML.empty().remove();
}
w.d.input.on('datebox', function (e,p) {
if ( p.method === 'postrefresh' ) {
w._cubox_pos();
}
});
w.d.headerText = ((w._grabLabel() !== false)?w._grabLabel():w.__('tireTitleString'));
w.d.intHTML = $('<span>');
w.fldOrder = o.tireFieldOrder;
tmp = $('<div class="'+uid+'header ui-grid-'+[0,0,'a','b','c'][o.customData.length]+'"></div>');
for ( y=0; y<o.customData.length; y++ ) {
$('<div class="ui-block-'+['a','b','c','d'][y]+'">'+o.customData[y]['name']+'</div>').css('textAlign','center').appendTo(tmp);
}
tmp.appendTo(w.d.intHTML);
w.d.intHTML.append(ctrl);
for ( y=0; y<o.customData.length; y++ ) {
lineArr = w._cubox_arr(o.customData[y]['data'], w.customCurrent[y]);
hRow = w._makeEl(flipBase, {'attr': {'field':y,'amount':1} });
for ( i in lineArr ) {
tmp = (i!=10)?o.themeOpt:o.themeOptPick;
$('<li>', {'class':'ui-body-'+tmp})
.html('<span>'+lineArr[i]+'</span>').appendTo(hRow.find('ul'));
}
hRow.appendTo(ctrl);
}
$("<div>", {"class":uid+'flipcenter ui-overlay-shadow'}).css('pointerEvents', 'none').appendTo(w.d.intHTML);
if ( o.useSetButton ) {
y = $('<div>', {'class':uid+'controls'});
if ( o.useSetButton ) {
$('<a href="#">'+w.__('customSet')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(o.customFormat,w.customCurrent), 'date':w.tireChoice});
w.d.input.trigger('datebox', {'method':'close'});
});
}
y.appendTo(w.d.intHTML);
}
if ( w.wheelExists ) { // Mousewheel operation, if plugin is loaded
w.d.intHTML.on('mousewheel', '.ui-overlay-shadow', function(e,d) {
e.preventDefault();
w._cubox_offset($(this).jqmData('field'), ((d<0)?1:-1)*$(this).jqmData('amount'));
});
}
w.d.intHTML.on(w.drag.eStart, 'ul', function(e,f) {
if ( !w.drag.move ) {
if ( typeof f !== "undefined" ) { e = f; }
w.drag.move = true;
w.drag.target = $(this).find('li').first();
w.drag.pos = parseInt(w.drag.target.css('marginTop').replace(/px/i, ''),10);
w.drag.start = w.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
w.drag.end = false;
e.stopPropagation();
e.preventDefault();
}
});
w.d.intHTML.on(w.drag.eStart, '.'+uid+'flipcenter', function(e) { // Used only on old browsers and IE.
if ( !w.drag.move ) {
w.drag.target = w.touch ? e.originalEvent.changedTouches[0].pageX - $(e.currentTarget).offset().left : e.pageX - $(e.currentTarget).offset().left;
w.drag.tmp = w.d.intHTML.find('.'+uid+'flipcenter').innerWidth() / (( $.inArray('a', w.fldOrder) > -1 && w.__('timeFormat') !== 12 )?w.fldOrder.length-1:w.fldOrder.length);
$(w.d.intHTML.find('ul').get(parseInt(w.drag.target / w.drag.tmp,10))).trigger(w.drag.eStart,e);
}
});
}
});
$.extend( $.mobile.datebox.prototype._drag, {
// This contains the code that the drag and drop (or touch move) code uses
'customflip': function() {
var w = this,
o = this.options,
g = this.drag;
$(document).on(g.eMove, function(e) {
if ( g.move && o.mode === 'customflip' ) {
g.end = w.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
g.target.css('marginTop', (g.pos + g.end - g.start) + 'px');
e.preventDefault();
e.stopPropagation();
return false;
}
});
$(document).on(g.eEnd, function(e) {
if ( g.move && o.mode === 'customflip' ) {
g.move = false;
if ( g.end !== false ) {
e.preventDefault();
e.stopPropagation();
g.tmp = g.target.parent().parent();
w._cubox_offset(g.tmp.jqmData('field'), (parseInt((g.start - g.end) / g.target.innerHeight(),10) * g.tmp.jqmData('amount')));
}
g.start = false;
g.end = false;
}
});
}
});
})( jQuery );
File diff suppressed because one or more lines are too long
@@ -0,0 +1,319 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
(function($) {
$.extend( $.mobile.datebox.prototype.options, {
themeButton: 'a',
themeInput: 'a',
useSetButton: true,
validHours: false,
repButton: true
});
$.extend( $.mobile.datebox.prototype, {
_dbox_run: function() {
var w = this;
w.drag.didRun = true;
w._offset(w.drag.target[0], w.drag.target[1], false);
w._dbox_run_update();
w.runButton = setTimeout(function() {w._dbox_run();}, 150);
},
_dbox_run_update: function() {
var w = this,
o = this.options;
if ( o.mode === 'datebox' ) {
w.d.intHTML.find('.ui-datebox-header').find('h4').text(w._formatter(w.__('headerFormat'), w.theDate));
}
w.d.divIn.find('input').each(function () {
switch ( $(this).jqmData('field') ) {
case 'y':
$(this).val(w.theDate.getFullYear()); break;
case 'm':
$(this).val(w.theDate.getMonth() + 1); break;
case 'd':
$(this).val(w.theDate.getDate()); break;
case 'h':
if ( w.__('timeFormat') === 12 ) {
if ( w.theDate.getHours() > 12 ) {
$(this).val(w.theDate.getHours()-12); break;
} else if ( w.theDate.getHours() === 0 ) {
$(this).val(12); break;
}
}
$(this).val(w.theDate.getHours()); break;
case 'i':
$(this).val(w._zPad(w.theDate.getMinutes())); break;
case 'M':
$(this).val(w.__('monthsOfYearShort')[w.theDate.getMonth()]); break;
case 'a':
$(this).val((w.theDate.getHours() > 11)?w.__('meridiem')[1]:w.__('meridiem')[0]);
break;
}
});
},
_dbox_vhour: function (delta) {
var w = this,
o = this.options, tmp,
closeya = [25,0],
closenay = [25,0];
if ( o.validHours === false ) { return true; }
if ( $.inArray(w.theDate.getHours(), o.validHours) > -1 ) { return true; }
tmp = w.theDate.getHours();
$.each(o.validHours, function(){
if ( ((tmp < this)?1:-1) === delta ) {
if ( closeya[0] > Math.abs(this-tmp) ) {
closeya = [Math.abs(this-tmp),parseInt(this,10)];
}
} else {
if ( closenay[0] > Math.abs(this-tmp) ) {
closenay = [Math.abs(this-tmp),parseInt(this,10)];
}
}
});
if ( closeya[1] !== 0 ) { w.theDate.setHours(closeya[1]); }
else { w.theDate.setHours(closenay[1]); }
},
_dbox_enter: function (item) {
var w = this;
if ( item.jqmData('field') === 'M' && $.inArray(item.val(), w.__('monthsOfYearShort')) > -1 ) {
w.theDate.setMonth($.inArray(item.val(), w.__('monthsOfYearShort')));
}
if ( item.val() !== '' && item.val().toString().search(/^[0-9]+$/) === 0 ) {
switch ( item.jqmData('field') ) {
case 'y':
w.theDate.setFullYear(parseInt(item.val(),10)); break;
case 'm':
w.theDate.setMonth(parseInt(item.val(),10)-1); break;
case 'd':
w.theDate.setDate(parseInt(item.val(),10)); break;
case 'h':
w.theDate.setHours(parseInt(item.val(),10)); break;
case 'i':
w.theDate.setMinutes(parseInt(item.val(),10)); break;
}
}
w.refresh();
}
});
$.extend( $.mobile.datebox.prototype._build, {
'timebox': function () {
this._build.datebox.apply(this,[]);
},
'datebox': function () {
var w = this,
g = this.drag,
o = this.options, i, y, tmp, cnt = -2,
uid = 'ui-datebox-',
divBase = $("<div>"),
divPlus = $('<fieldset>'),
divIn = divBase.clone(),
divMinus = divPlus.clone(),
inBase = $("<input type='"+w.inputType+"' />").addClass('ui-input-text ui-corner-all ui-shadow-inset ui-body-'+o.themeInput),
inBaseT = $("<input type='text' />").addClass('ui-input-text ui-corner-all ui-shadow-inset ui-body-'+o.themeInput),
butBase = $("<div></div>"),
butPTheme = {theme: o.themeButton, icon: 'plus', iconpos: 'bottom', corners:true, shadow:true, inline:true},
butMTheme = $.extend({}, butPTheme, {icon: 'minus', iconpos: 'top'});
if ( typeof w.d.intHTML !== 'boolean' ) {
w.d.intHTML.empty().remove();
}
w.d.headerText = ((w._grabLabel() !== false)?w._grabLabel():((o.mode==='datebox')?w.__('titleDateDialogLabel'):w.__('titleTimeDialogLabel')));
w.d.intHTML = $('<span>');
if ( w.inputType !== 'number' ) { inBase.attr('pattern', '[0-9]*'); }
w.fldOrder = ((o.mode==='datebox')?w.__('dateFieldOrder'):w.__('timeFieldOrder'));
w._check();
w._minStepFix();
w._dbox_vhour(typeof w._dbox_delta !== 'undefined'?w._dbox_delta:1);
if ( o.mode === 'datebox' ) { $('<div class="'+uid+'header"><h4>'+w._formatter(w.__('headerFormat'), w.theDate)+'</h4></div>').appendTo(w.d.intHTML); }
for(i=0; i<=w.fldOrder.length; i++) {
tmp = ['a','b','c','d','e','f'][i];
switch (w.fldOrder[i]) {
case 'y':
case 'm':
case 'd':
case 'h':
$('<div>').append(w._makeEl(inBase, {'attr': {'field':w.fldOrder[i], 'amount':1}})).addClass('ui-block-'+tmp).appendTo(divIn);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butPTheme).appendTo(divPlus);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butMTheme).appendTo(divMinus);
cnt++;
break;
case 'a':
if ( w.__('timeFormat') === 12 ) {
$('<div>').append(w._makeEl(inBaseT, {'attr': {'field':w.fldOrder[i], 'amount':1}})).addClass('ui-block-'+tmp).appendTo(divIn);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butPTheme).appendTo(divPlus);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butMTheme).appendTo(divMinus);
cnt++;
}
break;
case 'M':
$('<div>').append(w._makeEl(inBaseT, {'attr': {'field':w.fldOrder[i], 'amount':1}})).addClass('ui-block-'+tmp).appendTo(divIn);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butPTheme).appendTo(divPlus);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':1}}).addClass('ui-block-'+tmp).buttonMarkup(butMTheme).appendTo(divMinus);
cnt++;
break;
case 'i':
$('<div>').append(w._makeEl(inBase, {'attr': {'field':w.fldOrder[i], 'amount':o.minuteStep}})).addClass('ui-block-'+tmp).appendTo(divIn);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':o.minuteStep}}).addClass('ui-block-'+tmp).buttonMarkup(butPTheme).appendTo(divPlus);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i], 'amount':o.minuteStep}}).addClass('ui-block-'+tmp).buttonMarkup(butMTheme).appendTo(divMinus);
cnt++;
break;
}
}
divPlus.addClass('ui-grid-'+['a','b','c','d','e'][cnt]).appendTo(w.d.intHTML);
divIn.addClass('ui-datebox-dboxin').addClass('ui-grid-'+['a','b','c','d','e'][cnt]).appendTo(w.d.intHTML);
divMinus.addClass('ui-grid-'+['a','b','c','d','e'][cnt]).appendTo(w.d.intHTML);
if ( o.mobVer >= 140 ) {
divMinus.find('div').css({'min-height':'2.3em'});
divPlus.find('div').css({'min-height':'2.3em'});
}
divIn.find('input').each(function () {
switch ( $(this).jqmData('field') ) {
case 'y':
$(this).val(w.theDate.getFullYear()); break;
case 'm':
$(this).val(w.theDate.getMonth() + 1); break;
case 'd':
$(this).val(w.theDate.getDate()); break;
case 'h':
if ( w.__('timeFormat') === 12 ) {
if ( w.theDate.getHours() > 12 ) {
$(this).val(w.theDate.getHours()-12); break;
} else if ( w.theDate.getHours() === 0 ) {
$(this).val(12); break;
}
}
$(this).val(w.theDate.getHours()); break;
case 'i':
$(this).val(w._zPad(w.theDate.getMinutes())); break;
case 'M':
$(this).val(w.__('monthsOfYearShort')[w.theDate.getMonth()]); break;
case 'a':
$(this).val((w.theDate.getHours() > 11)?w.__('meridiem')[1]:w.__('meridiem')[0]);
break;
}
});
w.d.divIn = divIn;
if ( w.dateOK !== true ) {
divIn.find('input').addClass(uid+'griddate-disable');
} else {
divIn.find('.'+uid+'griddate-disable').removeClass(uid+'griddate-disable');
}
if ( o.useSetButton || o.useClearButton ) {
y = $('<div>', {'class':uid+'controls'});
if ( o.useSetButton ) {
$('<a href="#">'+((o.mode==='datebox')?w.__('setDateButtonLabel'):w.__('setTimeButtonLabel'))+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
if ( w.dateOK === true ) {
w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(w.__fmt(),w.theDate), 'date':w.theDate});
w.d.input.trigger('datebox', {'method':'close'});
}
});
}
if ( o.useClearButton ) {
$('<a href="#">'+w.__('clearButton')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'delete', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.val('');
w.d.input.trigger('datebox',{'method':'clear'});
w.d.input.trigger('datebox',{'method':'close'});
});
}
if ( o.useCollapsedBut ) {
y.addClass('ui-datebox-collapse');
}
y.appendTo(w.d.intHTML);
}
if ( o.repButton === false ) {
divPlus.on(o.clickEvent, 'div', function(e) {
e.preventDefault();
w._dbox_delta = 1;
w._offset($(this).jqmData('field'), $(this).jqmData('amount'));
});
divMinus.on(o.clickEvent, 'div', function(e) {
e.preventDefault();
w._dbox_delta = -1;
w._offset($(this).jqmData('field'), $(this).jqmData('amount')*-1);
});
}
divIn.on('change', 'input', function() { w._dbox_enter($(this)); });
if ( w.wheelExists ) { // Mousewheel operation, if plugin is loaded
divIn.on('mousewheel', 'input', function(e,d) {
e.preventDefault();
w._dbox_delta = d<0?-1:1;
w._offset($(this).jqmData('field'), ((d<0)?-1:1)*$(this).jqmData('amount'));
});
}
if ( o.repButton === true ) {
divPlus.on(w.drag.eStart, 'div', function(e) {
tmp = [$(this).jqmData('field'), $(this).jqmData('amount')];
w.drag.move = true;
w._dbox_delta = 1;
w._offset(tmp[0], tmp[1], false);
w._dbox_run_update();
if ( !w.runButton ) {
w.drag.target = tmp;
w.runButton = setTimeout(function() {w._dbox_run();}, 500);
}
});
divMinus.on(w.drag.eStart, 'div', function(e) {
tmp = [$(this).jqmData('field'), $(this).jqmData('amount')*-1];
w.drag.move = true;
w._dbox_delta = -1;
w._offset(tmp[0], tmp[1], false);
w._dbox_run_update();
if ( !w.runButton ) {
w.drag.target = tmp;
w.runButton = setTimeout(function() {w._dbox_run();}, 500);
}
});
divPlus.on(g.eEndA, function(e) {
if ( g.move ) {
e.preventDefault();
clearTimeout(w.runButton);
w.runButton = false;
g.move = false;
}
});
divMinus.on(g.eEndA, function(e) {
if ( g.move ) {
e.preventDefault();
clearTimeout(w.runButton);
w.runButton = false;
g.move = false;
}
});
}
}
});
})( jQuery );
File diff suppressed because one or more lines are too long
@@ -0,0 +1,247 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
/* DurationBox Mode */
(function($) {
$.extend( $.mobile.datebox.prototype.options, {
themeButton: 'a',
themeInput: 'a',
useSetButton: true,
repButton: true,
durationSteppers: {'d': 1, 'h': 1, 'i': 1, 's': 1}
});
$.extend( $.mobile.datebox.prototype, {
_durbox_run: function() {
var w = this;
w.drag.didRun = true;
w._offset(w.drag.target[0], w.drag.target[1], false);
w._durbox_run_update();
w.runButton = setTimeout(function() {w._durbox_run();}, 100);
},
_durbox_run_update: function () {
var w = this, i, cDur = [],
ival = {'d': 60*60*24, 'h': 60*60, 'i': 60};
i = w.theDate.getEpoch() - w.initDate.getEpoch();
if ( i<0 ) { i = 0; w.theDate.setTime(w.initDate.getTime()); }
w.lastDuration = i; // Let the number of seconds be sort of public.
// DAYS
cDur[0] = parseInt( i / ival.d,10); i = i % ival.d;
// HOURS
cDur[1] = parseInt( i / ival.h, 10); i = i % ival.h;
// MINS AND SECS
cDur[2] = parseInt( i / ival.i, 10);
cDur[3] = i % ival.i;
w.d.divIn.find('input').each(function () {
switch ( $(this).parent().jqmData('field') ) {
case 'd':
$(this).val(cDur[0]); break;
case 'h':
$(this).val(cDur[1]); break;
case 'i':
$(this).val(cDur[2]); break;
case 's':
$(this).val(cDur[3]); break;
}
});
},
_durbox_valid: function (num) {
if ( num.toString().search(/^[0-9]+$/) === 0 ) { return parseInt(num,10); }
return 0;
},
_durbox_enter: function (item) {
var w = this,
t = w.initDate.getEpoch();
w.d.intHTML.find('input').each( function() {
switch ( $(this).parent().jqmData('field') ) {
case 'd':
t += (60*60*24) * w._durbox_valid($(this).val()); break;
case 'h':
t += (60*60) * w._durbox_valid($(this).val()); break;
case 'i':
t += (60) * w._durbox_valid($(this).val()); break;
case 's':
t += w._durbox_valid($(this).val()); break;
}
});
w.theDate.setTime( t * 1000 );
w.refresh();
}
});
$.extend( $.mobile.datebox.prototype._build, {
'durationbox': function () {
var w = this,
g = this.drag,
o = this.options, i, y, cDur = [0,0,0,0], tmp,
ival = {'d': 60*60*24, 'h': 60*60, 'i': 60},
uid = 'ui-datebox-',
divBase = $("<div>"),
divPlus = $('<fieldset>'),
divIn = divBase.clone().addClass('ui-datebox-dboxin'),
divMinus = divPlus.clone(),
inBase = $("<input type='"+w.inputType+"' />").addClass('ui-input-text ui-corner-all ui-shadow-inset ui-body-'+o.themeInput),
butBase = $("<div><a href='#'> </a></div>"),
butPTheme = {theme: o.themeButton, icon: 'plus', iconpos: 'bottom', corners:true, shadow:true},
butMTheme = $.extend({}, butPTheme, {icon: 'minus', iconpos: 'top'});
if ( typeof w.d.intHTML !== 'boolean' ) {
w.d.intHTML.empty().remove();
}
w.d.headerText = ((w._grabLabel() !== false)?w._grabLabel():w.__('titleDateDialogLabel'));
w.d.intHTML = $('<span>');
if ( w.inputType !== 'number' ) { inBase.attr('pattern', '[0-9]*'); }
w.fldOrder = w.__('durationOrder');
for(i=0; i<=w.fldOrder.length; i++) {
switch (w.fldOrder[i]) {
case 'd':
case 'h':
case 'i':
case 's':
y = $.inArray(w.fldOrder[i], ['d','h','i','s']);
$('<div>').jqmData('field', w.fldOrder[i]).addClass('ui-block-'+['a','b','c','d'][i]).append(inBase.clone()).appendTo(divIn).prepend('<label>'+w.__('durationLabel')[y]+'</label>');
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i]}}).addClass('ui-block-'+['a','b','c','d'][i]).buttonMarkup(butPTheme).appendTo(divPlus);
w._makeEl(butBase, {'attr': {'field':w.fldOrder[i]}}).addClass('ui-block-'+['a','b','c','d'][i]).buttonMarkup(butMTheme).appendTo(divMinus);
break;
}
}
i = w.theDate.getEpoch() - w.initDate.getEpoch();
if ( i<0 ) { i = 0; w.theDate.setTime(w.initDate.getTime()); }
w.lastDuration = i; // Let the number of seconds be sort of public.
// DAYS
cDur[0] = parseInt( i / ival.d,10); i = i % ival.d;
// HOURS
cDur[1] = parseInt( i / ival.h, 10); i = i % ival.h;
// MINS AND SECS
cDur[2] = parseInt( i / ival.i, 10);
cDur[3] = i % ival.i;
divIn.find('input').each(function () {
switch ( $(this).parent().jqmData('field') ) {
case 'd':
$(this).val(cDur[0]); break;
case 'h':
$(this).val(cDur[1]); break;
case 'i':
$(this).val(cDur[2]); break;
case 's':
$(this).val(cDur[3]); break;
}
});
w.d.divIn = divIn;
divPlus.addClass('ui-grid-'+['a','b','c'][w.fldOrder.length-2]).appendTo(w.d.intHTML);
divIn.addClass('ui-grid-'+['a','b','c'][w.fldOrder.length-2]).appendTo(w.d.intHTML);
divMinus.addClass('ui-grid-'+['a','b','c'][w.fldOrder.length-2]).appendTo(w.d.intHTML);
if (o.mobVer >= 140) {
divMinus.find('div').css({'min-height': '2.3em'});
divPlus.find('div').css({'min-height': '2.3em'});
}
if ( o.useSetButton || o.useClearButton ) {
y = $('<div>', {'class':uid+'controls'});
if ( o.useSetButton ) {
$('<a href="#">'+w.__('setDurationButtonLabel')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(w.__fmt(),w.theDate), 'date':w.theDate});
w.d.input.trigger('datebox', {'method':'close'});
});
}
if ( o.useClearButton ) {
$('<a href="#">'+w.__('clearButton')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'delete', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.val('');
w.d.input.trigger('datebox',{'method':'clear'});
w.d.input.trigger('datebox',{'method':'close'});
});
}
if ( o.useCollapsedBut ) {
y.addClass('ui-datebox-collapse');
}
y.appendTo(w.d.intHTML);
}
if ( o.repButton === false ) {
divPlus.on(o.clickEvent, 'div', function(e) {
e.preventDefault();
w._offset($(this).jqmData('field'), o.durationSteppers[$(this).jqmData('field')]);
});
divMinus.on(o.clickEvent, 'div', function(e) {
e.preventDefault();
w._offset($(this).jqmData('field'), o.durationSteppers[$(this).jqmData('field')]*-1);
});
}
divIn.on('change', 'input', function() { w._durbox_enter($(this)); });
if ( w.wheelExists ) { // Mousewheel operation, if plugin is loaded
divIn.on('mousewheel', 'input', function(e,d) {
e.preventDefault();
w._offset($(this).parent().jqmData('field'), ((d<0)?-1:1)*o.durationSteppers[$(this).parent().jqmData('field')]);
});
}
if ( o.repButton === true ) {
divPlus.on(w.drag.eStart, 'div', function(e) {
tmp = [$(this).jqmData('field'), o.durationSteppers[$(this).jqmData('field')]];
w.drag.move = true;
w._dbox_delta = 1;
w._offset(tmp[0], tmp[1], false);
w._durbox_run_update();
if ( !w.runButton ) {
w.drag.target = tmp;
w.runButton = setTimeout(function() {w._durbox_run();}, 500);
}
});
divMinus.on(w.drag.eStart, 'div', function(e) {
tmp = [$(this).jqmData('field'), o.durationSteppers[$(this).jqmData('field')]*-1];
w.drag.move = true;
w._dbox_delta = -1;
w._offset(tmp[0], tmp[1], false);
w._durbox_run_update();
if ( !w.runButton ) {
w.drag.target = tmp;
w.runButton = setTimeout(function() {w._durbox_run();}, 500);
}
});
divPlus.on(g.eEndA, function(e) {
if ( g.move ) {
e.preventDefault();
clearTimeout(w.runButton);
w.runButton = false;
g.move = false;
}
});
divMinus.on(g.eEndA, function(e) {
if ( g.move ) {
e.preventDefault();
clearTimeout(w.runButton);
w.runButton = false;
g.move = false;
}
});
}
}
});
})( jQuery );
File diff suppressed because one or more lines are too long
@@ -0,0 +1,206 @@
/*
* jQuery Mobile Framework : plugin to provide a date and time picker.
* Copyright (c) JTSage
* CC 3.0 Attribution. May be relicensed without permission/notification.
* https://github.com/jtsage/jquery-mobile-datebox
*/
/* DurationFlipBox Mode */
(function($) {
$.extend( $.mobile.datebox.prototype.options, {
themeDatePick: 'b',
themeDate: 'a',
useSetButton: true,
durationSteppers: {'d': 1, 'h': 1, 'i': 1, 's': 1}
});
$.extend( $.mobile.datebox.prototype, {
'_durfbox_pos': function () {
var w = this,
ech = null,
top = null,
par = this.d.intHTML.find('.ui-datebox-flipcontent').innerHeight(),
tot = null;
w.d.intHTML.find('.ui-datebox-flipcenter').each(function() {
ech = $(this);
top = ech.innerHeight();
ech.css('top', ((par/2)-(top/2)+4)*-1);
});
w.d.intHTML.find('ul').each(function () {
ech = $(this);
par = ech.parent().innerHeight();
top = ech.find('li').first();
tot = ech.find('li').size() * top.outerHeight();
top.css('marginTop', ((tot/2)-(par/2)+(top.outerHeight()/2))*-1);
});
},
'_durfbox_series': function (middle, side, type) {
var w = this,
o = this.options,
ret = [[middle.toString(), middle]], nxt, prv;
for ( var i = 1; i <= side; i++ ) {
nxt = middle + ( i * o.durationSteppers[type] );
prv = middle - ( i * o.durationSteppers[type] );
ret.unshift([nxt.toString(), nxt]);
if ( prv > -1 ) {
ret.push([prv.toString(), prv]);
} else {
ret.push(['',-1]);
}
}
return ret;
}
});
$.extend( $.mobile.datebox.prototype._build, {
'durationflipbox': function () {
var w = this,
o = this.options, i, y, tt, hRow, tmp, testDate,
sel = ['d','h','i','s'],
cDur = [0,0,0,0],
cDurS = {},
ival = {'d': 60*60*24, 'h': 60*60, 'i': 60},
uid = 'ui-datebox-',
flipBase = $("<div class='ui-overlay-shadow'><ul></ul></div>"),
ctrl = $("<div>", {"class":uid+'flipcontent'+' '+uid+'flipcontentd'});
if ( typeof w.d.intHTML !== 'boolean' ) {
w.d.intHTML.empty().remove();
}
w.d.input.on('datebox', function (e,p) {
if ( p.method === 'postrefresh' ) { w._durfbox_pos(); }
});
w.d.headerText = ((w._grabLabel() !== false)?w._grabLabel():w.__('titleDateDialogLabel'));
w.d.intHTML = $('<span>');
w.fldOrder = w.__('durationOrder');
tmp = $('<div class="'+uid+'header ui-grid-'+[0,0,'a','b','c'][w.fldOrder.length]+'"></div>');
for ( y=0; y<w.fldOrder.length; y++ ) {
$('<div class="ui-block-'+['a','b','c','d'][y]+'">'+w.__('durationLabel')[jQuery.inArray(w.fldOrder[y],['d','h','i','s'])]+'</div>').css('textAlign','center').appendTo(tmp);
}
tmp.appendTo(w.d.intHTML);
w.d.intHTML.append(ctrl);
i = w.theDate.getEpoch() - w.initDate.getEpoch();
if ( i<0 ) { i = 0; w.theDate.setTime(w.initDate.getTime()); }
w.lastDuration = i; // Let the number of seconds be sort of public.
// SPLIT TIME INTO DAYS, HRS, MIN, SEC
cDur[0] = parseInt( i / ival.d, 10); i = i % ival.d;
cDur[1] = parseInt( i / ival.h, 10); i = i % ival.h;
cDur[2] = parseInt( i / ival.i, 10);
cDur[3] = i % ival.i;
cDurS.d = w._durfbox_series(cDur[0],16,'d');
cDurS.h = w._durfbox_series(cDur[1],16,'h');
cDurS.i = w._durfbox_series(cDur[2],20,'i');
cDurS.s = w._durfbox_series(cDur[3],20,'s');
for ( y=0; y<w.fldOrder.length; y++ ) {
tt = w.fldOrder[y];
sel = cDur[jQuery.inArray(tt,['d','h','i','s'])];
hRow = w._makeEl(flipBase, {'attr': {'field':tt,'amount':o.durationSteppers[tt]} });
for ( i in cDurS[tt] ) {
tmp = (cDurS[tt][i][1]!==sel)?o.themeDate:o.themeDatePick;
$("<li>", { 'class' : 'ui-body-'+tmp})
.html("<span>"+cDurS[tt][i][0] +"</span>").appendTo(hRow.find('ul'));
}
hRow.appendTo(ctrl);
}
$("<div>", {"class":uid+'flipcenter ui-overlay-shadow'}).css('pointerEvents', 'none').appendTo(w.d.intHTML);
if ( o.useSetButton || o.useClearButton ) {
y = $('<div>', {'class':uid+'controls'});
if ( o.useSetButton ) {
$('<a href="#">'+w.__('setDurationButtonLabel')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'check', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.trigger('datebox', {'method':'set', 'value':w._formatter(w.__fmt(),w.theDate), 'date':w.theDate});
w.d.input.trigger('datebox', {'method':'close'});
});
}
if ( o.useClearButton ) {
$('<a href="#">'+w.__('clearButton')+'</a>')
.appendTo(y).buttonMarkup({theme: o.theme, icon: 'delete', iconpos: 'left', corners:true, shadow:true})
.on(o.clickEventAlt, function(e) {
e.preventDefault();
w.d.input.val('');
w.d.input.trigger('datebox',{'method':'clear'});
w.d.input.trigger('datebox',{'method':'close'});
});
}
if ( o.useCollapsedBut ) {
y.addClass('ui-datebox-collapse');
}
y.appendTo(w.d.intHTML);
}
if ( w.wheelExists ) { // Mousewheel operation, if plugin is loaded
w.d.intHTML.on('mousewheel', '.ui-overlay-shadow', function(e,d) {
e.preventDefault();
w._offset($(this).jqmData('field'), ((d<0)?-1:1)*$(this).jqmData('amount'));
});
}
w.d.intHTML.on(w.drag.eStart, 'ul', function(e,f) {
if ( !w.drag.move ) {
if ( typeof f !== "undefined" ) { e = f; }
w.drag.move = true;
w.drag.target = $(this).find('li').first();
w.drag.pos = parseInt(w.drag.target.css('marginTop').replace(/px/i, ''),10);
w.drag.start = w.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
w.drag.end = false;
e.stopPropagation();
e.preventDefault();
}
});
w.d.intHTML.on(w.drag.eStart, '.'+uid+'flipcenter', function(e) { // Used only on old browsers and IE.
if ( !w.drag.move ) {
w.drag.target = w.touch ? e.originalEvent.changedTouches[0].pageX - $(e.currentTarget).offset().left : e.pageX - $(e.currentTarget).offset().left;
w.drag.tmp = w.d.intHTML.find('.'+uid+'flipcenter').innerWidth() / (( $.inArray('a', w.fldOrder) > -1 && w.__('timeFormat') !== 12 )?w.fldOrder.length-1:w.fldOrder.length);
$(w.d.intHTML.find('ul').get(parseInt(w.drag.target / w.drag.tmp,10))).trigger(w.drag.eStart,e);
}
});
}
});
$.extend( $.mobile.datebox.prototype._drag, {
'durationflipbox': function() {
var w = this,
o = this.options,
g = this.drag;
$(document).on(g.eMove, function(e) {
if ( g.move && o.mode === 'durationflipbox' ) {
g.end = w.touch ? e.originalEvent.changedTouches[0].pageY : e.pageY;
g.target.css('marginTop', (g.pos + g.end - g.start) + 'px');
e.preventDefault();
e.stopPropagation();
return false;
}
});
$(document).on(g.eEnd, function(e) {
if ( g.move && o.mode === 'durationflipbox' ) {
g.move = false;
if ( g.end !== false ) {
e.preventDefault();
e.stopPropagation();
g.tmp = g.target.parent().parent();
w._offset(g.tmp.jqmData('field'), (parseInt((g.start - g.end) / g.target.innerHeight(),10) * g.tmp.jqmData('amount') *-1 ));
}
g.start = false;
g.end = false;
}
});
}
});
})( jQuery );

Some files were not shown because too many files have changed in this diff Show More