This commit is contained in:
John Bintz 2011-12-06 14:57:28 -05:00
parent 9df6157745
commit f1f337c871
7 changed files with 493 additions and 798 deletions

View File

@ -10,3 +10,4 @@ Every other project is owned by the original owner, I'm just aggregating for my
* [Ajax File Upload](http://phpletter.com/Our-Projects/AjaxFileUpload/)
* [jQuery UI Timepicker Addon](http://trentrichardson.com/examples/timepicker/)
* [underscore.string](https://github.com/edtsech/underscore.string)
* [jScroll](http://www.wduffy.co.uk/jScroll/)

View File

@ -2,30 +2,6 @@ require "bundler/gem_tasks"
require 'httparty'
require 'zip/zip'
def process_zip_url(url, entries = {})
mkdir_p 'tmp'
response = HTTParty.get(url)
File.open(target = 'tmp/elastic.zip', 'wb') { |fh| fh.print response.body }
Zip::ZipFile.foreach(target) do |entry|
entries.each do |search_entry, target_filename|
if entry.name[search_entry]
case File.extname(search_entry)
when '.js'
target = 'vendor/assets/javascripts'
when '.css'
target = 'vendor/assets/stylesheets'
end
entry.extract(File.join(target, target_filename))
end
yield entry if block_given?
end
end
end
sources = {
'jquery.cookies' => [
'http://cookies.googlecode.com/svn/trunk/jquery.cookies.js'
@ -55,9 +31,36 @@ sources = {
],
'underscore.string' => [
'https://raw.github.com/edtsech/underscore.string/master/lib/underscore.string.js'
],
'jScroll' => [
'https://github.com/downloads/wduffy/jScroll/jquery.jscroll.js'
]
}
def process_zip_url(url, entries = {})
mkdir_p 'tmp'
response = HTTParty.get(url)
File.open(target = 'tmp/elastic.zip', 'wb') { |fh| fh.print response.body }
Zip::ZipFile.foreach(target) do |entry|
entries.each do |search_entry, target_filename|
if entry.name[search_entry]
case File.extname(search_entry)
when '.js'
target = 'vendor/assets/javascripts'
when '.css'
target = 'vendor/assets/stylesheets'
end
entry.extract(File.join(target, target_filename))
end
yield entry if block_given?
end
end
end
desc 'Update verything'
task :update do
rm_rf 'vendor/assets'

View File

@ -1,8 +1,8 @@
/*
* jQuery timepicker addon
* By: Trent Richardson [http://trentrichardson.com]
* Version 0.9.7
* Last Modified: 10/02/2011
* Version 0.9.8
* Last Modified: 12/03/2011
*
* Copyright 2011 Trent Richardson
* Dual licensed under the MIT and GPL licenses.
@ -12,15 +12,15 @@
* HERES THE CSS:
* .ui-timepicker-div .ui-widget-header { margin-bottom: 8px; }
* .ui-timepicker-div dl { text-align: left; }
* .ui-timepicker-div dl dt { height: 25px; }
* .ui-timepicker-div dl dd { margin: -25px 10px 10px 65px; }
* .ui-timepicker-div dl dt { height: 25px; margin-bottom: -25px; }
* .ui-timepicker-div dl dd { margin: 0 10px 10px 65px; }
* .ui-timepicker-div td { font-size: 90%; }
* .ui-tpicker-grid-label { background: none; border: none; margin: 0; padding: 0; }
*/
(function($) {
$.extend($.ui, { timepicker: { version: "0.9.7" } });
$.extend($.ui, { timepicker: { version: "0.9.8" } });
/* Time picker manager.
Use the singleton instance of this class, $.timepicker, to interact with the time picker.
@ -54,10 +54,10 @@ function Timepicker() {
showMillisec: false,
showTimezone: false,
showTime: true,
stepHour: 0.05,
stepMinute: 0.05,
stepSecond: 0.05,
stepMillisec: 0.5,
stepHour: 1,
stepMinute: 1,
stepSecond: 1,
stepMillisec: 1,
hour: 0,
minute: 0,
second: 0,
@ -83,7 +83,9 @@ function Timepicker() {
altFieldTimeOnly: true,
showTimepicker: true,
timezoneIso8609: false,
timezoneList: null
timezoneList: null,
addSliderAccess: false,
sliderAccessArgs: null
};
$.extend(this._defaults, this.regional['']);
}
@ -341,10 +343,10 @@ $.extend(Timepicker.prototype, {
// Added by Peter Medeiros:
// - Figure out what the hour/minute/second max should be based on the step values.
// - Example: if stepMinute is 15, then minMax is 45.
hourMax = (o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)).toFixed(0),
minMax = (o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)).toFixed(0),
secMax = (o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)).toFixed(0),
millisecMax = (o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)).toFixed(0),
hourMax = parseInt((o.hourMax - ((o.hourMax - o.hourMin) % o.stepHour)) ,10),
minMax = parseInt((o.minuteMax - ((o.minuteMax - o.minuteMin) % o.stepMinute)) ,10),
secMax = parseInt((o.secondMax - ((o.secondMax - o.secondMin) % o.stepSecond)) ,10),
millisecMax = parseInt((o.millisecMax - ((o.millisecMax - o.millisecMin) % o.stepMillisec)) ,10),
dp_id = this.inst.id.toString().replace(/([^A-Za-z0-9_])/g, '');
// Prevent displaying twice
@ -365,10 +367,10 @@ $.extend(Timepicker.prototype, {
size;
// Hours
html += '<dd class="ui_tpicker_hour"><div id="ui_tpicker_hour_' + dp_id + '"' +
((o.showHour) ? '' : noDisplay) + '></div>';
if (o.showHour && o.hourGrid > 0) {
html += '<dd class="ui_tpicker_hour">' +
'<div id="ui_tpicker_hour_' + dp_id + '"' + ((o.showHour) ? '' : noDisplay) + '></div>' +
'<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
for (var h = o.hourMin; h <= hourMax; h += parseInt(o.hourGrid,10)) {
hourGridSize++;
@ -382,70 +384,63 @@ $.extend(Timepicker.prototype, {
html += '<td>' + tmph + '</td>';
}
html += '</tr></table></div>' +
'</dd>';
} else html += '<dd class="ui_tpicker_hour" id="ui_tpicker_hour_' + dp_id + '"' +
((o.showHour) ? '' : noDisplay) + '></dd>';
html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>';
html += '</tr></table></div>';
}
html += '</dd>';
// Minutes
html += '<dt class="ui_tpicker_minute_label" id="ui_tpicker_minute_label_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '>' + o.minuteText + '</dt>'+
'<dd class="ui_tpicker_minute"><div id="ui_tpicker_minute_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '></div>';
if (o.showMinute && o.minuteGrid > 0) {
html += '<dd class="ui_tpicker_minute ui_tpicker_minute_' + o.minuteGrid + '">' +
'<div id="ui_tpicker_minute_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '></div>' +
'<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
html += '<div style="padding-left: 1px"><table class="ui-tpicker-grid-label"><tr>';
for (var m = o.minuteMin; m <= minMax; m += parseInt(o.minuteGrid,10)) {
minuteGridSize++;
html += '<td>' + ((m < 10) ? '0' : '') + m + '</td>';
}
html += '</tr></table></div>' +
'</dd>';
} else html += '<dd class="ui_tpicker_minute" id="ui_tpicker_minute_' + dp_id + '"' +
((o.showMinute) ? '' : noDisplay) + '></dd>';
html += '</tr></table></div>';
}
html += '</dd>';
// Seconds
html += '<dt class="ui_tpicker_second_label" id="ui_tpicker_second_label_' + dp_id + '"' +
((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>';
((o.showSecond) ? '' : noDisplay) + '>' + o.secondText + '</dt>'+
'<dd class="ui_tpicker_second"><div id="ui_tpicker_second_' + dp_id + '"'+
((o.showSecond) ? '' : noDisplay) + '></div>';
if (o.showSecond && o.secondGrid > 0) {
html += '<dd class="ui_tpicker_second ui_tpicker_second_' + o.secondGrid + '">' +
'<div id="ui_tpicker_second_' + dp_id + '"' +
((o.showSecond) ? '' : noDisplay) + '></div>' +
'<div style="padding-left: 1px"><table><tr>';
html += '<div style="padding-left: 1px"><table><tr>';
for (var s = o.secondMin; s <= secMax; s += parseInt(o.secondGrid,10)) {
secondGridSize++;
html += '<td>' + ((s < 10) ? '0' : '') + s + '</td>';
}
html += '</tr></table></div>' +
'</dd>';
} else html += '<dd class="ui_tpicker_second" id="ui_tpicker_second_' + dp_id + '"' +
((o.showSecond) ? '' : noDisplay) + '></dd>';
html += '</tr></table></div>';
}
html += '</dd>';
// Milliseconds
html += '<dt class="ui_tpicker_millisec_label" id="ui_tpicker_millisec_label_' + dp_id + '"' +
((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>';
((o.showMillisec) ? '' : noDisplay) + '>' + o.millisecText + '</dt>'+
'<dd class="ui_tpicker_millisec"><div id="ui_tpicker_millisec_' + dp_id + '"'+
((o.showMillisec) ? '' : noDisplay) + '></div>';
if (o.showMillisec && o.millisecGrid > 0) {
html += '<dd class="ui_tpicker_millisec ui_tpicker_millisec_' + o.millisecGrid + '">' +
'<div id="ui_tpicker_millisec_' + dp_id + '"' +
((o.showMillisec) ? '' : noDisplay) + '></div>' +
'<div style="padding-left: 1px"><table><tr>';
html += '<div style="padding-left: 1px"><table><tr>';
for (var l = o.millisecMin; l <= millisecMax; l += parseInt(o.millisecGrid,10)) {
millisecGridSize++;
html += '<td>' + ((l < 10) ? '0' : '') + s + '</td>';
html += '<td>' + ((l < 10) ? '0' : '') + l + '</td>';
}
html += '</tr></table></div>' +
'</dd>';
} else html += '<dd class="ui_tpicker_millisec" id="ui_tpicker_millisec_' + dp_id + '"' +
((o.showMillisec) ? '' : noDisplay) + '></dd>';
html += '</tr></table></div>';
}
html += '</dd>';
// Timezone
html += '<dt class="ui_tpicker_timezone_label" id="ui_tpicker_timezone_label_' + dp_id + '"' +
@ -477,6 +472,7 @@ $.extend(Timepicker.prototype, {
}
});
// Updated by Peter Medeiros:
// - Pass in Event and UI instance into slide function
this.minute_slider = $tp.find('#ui_tpicker_minute_'+ dp_id).slider({
@ -486,7 +482,6 @@ $.extend(Timepicker.prototype, {
max: minMax,
step: o.stepMinute,
slide: function(event, ui) {
// update the global minute slider instance value with the current slider value
tp_inst.minute_slider.slider( "option", "value", ui.value);
tp_inst._onTimeChange();
}
@ -639,6 +634,32 @@ $.extend(Timepicker.prototype, {
this.minute_slider.bind('slidestop',onSelectDelegate);
this.second_slider.bind('slidestop',onSelectDelegate);
this.millisec_slider.bind('slidestop',onSelectDelegate);
// slideAccess integration: http://trentrichardson.com/2011/11/11/jquery-ui-sliders-and-touch-accessibility/
if (this._defaults.addSliderAccess){
var sliderAccessArgs = this._defaults.sliderAccessArgs;
setTimeout(function(){ // fix for inline mode
if($tp.find('.ui-slider-access').length == 0){
$tp.find('.ui-slider:visible').sliderAccess(sliderAccessArgs);
// fix any grids since sliders are shorter
var sliderAccessWidth = $tp.find('.ui-slider-access:eq(0)').outerWidth(true);
if(sliderAccessWidth){
$tp.find('table:visible').each(function(){
var $g = $(this),
oldWidth = $g.outerWidth(),
oldMarginLeft = $g.css('marginLeft').toString().replace('%',''),
newWidth = oldWidth - sliderAccessWidth,
newMarginLeft = ((oldMarginLeft * newWidth)/oldWidth) + '%';
$g.css({ width: newWidth, marginLeft: newMarginLeft });
});
}
}
},0);
}
// end slideAccess integration
}
},
@ -732,10 +753,10 @@ $.extend(Timepicker.prototype, {
}
if(adjustSliders !== undefined && adjustSliders === true){
var hourMax = (this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)).toFixed(0),
minMax = (this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)).toFixed(0),
secMax = (this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)).toFixed(0),
millisecMax = (this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)).toFixed(0);
var hourMax = parseInt((this._defaults.hourMax - ((this._defaults.hourMax - this._defaults.hourMin) % this._defaults.stepHour)) ,10),
minMax = parseInt((this._defaults.minuteMax - ((this._defaults.minuteMax - this._defaults.minuteMin) % this._defaults.stepMinute)) ,10),
secMax = parseInt((this._defaults.secondMax - ((this._defaults.secondMax - this._defaults.secondMin) % this._defaults.stepSecond)) ,10),
millisecMax = parseInt((this._defaults.millisecMax - ((this._defaults.millisecMax - this._defaults.millisecMin) % this._defaults.stepMillisec)) ,10);
if(this.hour_slider)
this.hour_slider.slider("option", { min: this._defaults.hourMin, max: hourMax }).slider('value', this.hour);
@ -859,8 +880,8 @@ $.extend(Timepicker.prototype, {
// update our input with the new date time..
//########################################################################
_updateDateTime: function(dp_inst) {
dp_inst = this.inst || dp_inst,
dt = new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay),
dp_inst = this.inst || dp_inst;
var dt = $.datepicker._daylightSavingAdjust(new Date(dp_inst.selectedYear, dp_inst.selectedMonth, dp_inst.selectedDay)),
dateFmt = $.datepicker._get(dp_inst, 'dateFormat'),
formatCfg = $.datepicker._getFormatConfig(dp_inst),
timeAvailable = dt !== null && this.timeDefined;
@ -1204,7 +1225,7 @@ $.datepicker._formatDate = function(inst, day, month, year){
{
if(day)
var b = this._base_formatDate(inst, day, month, year);
tp_inst._updateDateTime();
tp_inst._updateDateTime(inst);
return tp_inst.$input.val();
}
return this._base_formatDate(inst);
@ -1255,7 +1276,9 @@ $.datepicker._optionDatepicker = function(target, name, value) {
else if (onselect)
tp_inst._defaults.onSelect=onselect;
}
this._base_optionDatepicker(target, name, value);
if (value === undefined)
return this._base_optionDatepicker(target, name);
return this._base_optionDatepicker(target, name, value);
};
//#######################################################################################
@ -1270,7 +1293,7 @@ function extendRemove(target, props) {
}
$.timepicker = new Timepicker(); // singleton instance
$.timepicker.version = "0.9.7";
$.timepicker.version = "0.9.8";
})(jQuery);

View File

@ -1,488 +1,27 @@
/**
* jquery.cookies.js
*
* Copyright (c) 2005 - 2011, James Auldridge
* All rights reserved.
*
* Licensed under the BSD, MIT, and GPL (your choice!) Licenses:
* @link http://code.google.com/p/cookies/wiki/License
*
* Last eror free JSHint: 20110418 12:14
* @link http://jshint.com/
* Checked Options:
* Disallow bitwise operators
* Require curly braces around all blocks
* Require ===
* Require for..in statements to be filtered
* Require variables to be declared before usage
* Environment
* Browser
* jQuery
*/
( function( global )
{
"use strict";
var document, Object, jaaulde;
/* localize 3rd party support */
var $ = global.jQuery,
/* localize first party support */
jaaulde = global.jaaulde,
cookies = jaaulde.utils.cookies,
/* declarations */
NameTokenAttrResolver;
/*
* localize global variables which are used more than once
*/
document = global.document;
Object = global.Object;
/*
* jaaulde Namespace preparation - the only var introduced into global space
*/
jaaulde = global.jaaulde = ( global.jaaulde || {} );
jaaulde.utils = jaaulde.utils || {};
jaaulde.utils.cookies = ( function()
{
/* Private vars */
var defaultOptions,
/* Private functions */
resolveOptions, assembleOptionsString, isNaN, trim, parseCookies, Constructor;
defaultOptions = {
expiresAt: null,
path: '/',
domain: null,
secure: false
};
/**
* resolveOptions - receive an options object and ensure all options are present and valid, replacing with defaults where necessary
* would prefer jQuery.extend here, but we want this library to work without jQuery
* @access private
* @static
* @parameter Object options - optional options to start with
* @return Object complete and valid options object
*/
resolveOptions = function( options )
{
var returnValue, expireDate;
if( typeof options !== 'object' || options === null )
{
returnValue = defaultOptions;
}
else
{
returnValue = {
expiresAt: defaultOptions.expiresAt,
path: defaultOptions.path,
domain: defaultOptions.domain,
secure: defaultOptions.secure
};
if( typeof options.expiresAt === 'object' && options.expiresAt instanceof Date )
{
returnValue.expiresAt = options.expiresAt;
}
else if( typeof options.hoursToLive === 'number' && options.hoursToLive !== 0 )
{
expireDate = new global.Date();
expireDate.setTime( expireDate.getTime() + ( options.hoursToLive * 60 * 60 * 1000 ) );
returnValue.expiresAt = expireDate;
}
if( typeof options.path === 'string' && options.path !== '' )
{
returnValue.path = options.path;
}
if( typeof options.domain === 'string' && options.domain !== '' )
{
returnValue.domain = options.domain;
}
if( options.secure === true )
{
returnValue.secure = options.secure;
}
}
return returnValue;
};
/**
* assembleOptionsString - analyze options and assemble appropriate string for setting a cookie with those options
*
* @access private
* @static
* @parameter options OBJECT - optional options to start with
* @return STRING - complete and valid cookie setting options
*/
assembleOptionsString = function( options )
{
options = resolveOptions( options );
return (
( typeof options.expiresAt === 'object' && options.expiresAt instanceof Date ? '; expires=' + options.expiresAt.toGMTString() : '' ) +
'; path=' + options.path +
( typeof options.domain === 'string' ? '; domain=' + options.domain : '' ) +
( options.secure === true ? '; secure' : '' )
);
};
/**
* trim - remove left and right whitespace
* Some logic borrowed from http://jquery.com/
*
* @access private
* @static
* @parameter data STRING
* @return STRING
*/
trim = global.String.prototype.trim ?
function( data )
{
return global.String.prototype.trim.call( data );
} :
( function()
{
var trimLeft, trimRight;
trimLeft = /^\s+/;
trimRight = /\s+$/;
return function( data )
{
return data.replace( trimLeft, '' ).replace( trimRight, '' );
};
}() );
/**
* isNaN - check if given value is not a number
* Borrowed from http://jquery.com/
*
* @access private
* @static
* @parameter obj MIXED
* @return BOOL
*/
isNaN = ( function()
{
var rdigit = /\d/, isNaN = global.isNaN;
return function( obj )
{
return ( obj === null || ! rdigit.test( obj ) || isNaN( obj ) );
};
}() );
/**
* parseCookies - retrieve document.cookie string and break it into a hash with values decoded and unserialized
*
* @access private
* @static
* @return OBJECT - hash of cookies from document.cookie
*/
parseCookies = ( function()
{
var parseJSON, rbrace;
parseJSON = global.JSON && global.JSON.parse ?
( function()
{
var rvalidchars, rvalidescape, rvalidtokens, rvalidbraces;
rvalidchars = /^[\],:{}\s]*$/;
rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g;
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g;
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g;
return function( data )
{
var returnValue, validJSON;
returnValue = null;
if( typeof data === 'string' && data !== '' )
{
// Make sure leading/trailing whitespace is removed (IE can't handle it)
data = trim( data );
if( data !== '' )
{
try
{
// Make sure the incoming data is actual JSON. Logic borrowed from http://json.org/json2.js
validJSON = rvalidchars.test( data.replace( rvalidescape, '@' ).replace( rvalidtokens, ']' ).replace( rvalidbraces, '' ) );
returnValue = validJSON ?
global.JSON.parse( data ) :
null;
}
catch( e1 )
{
returnValue = null;
}
}
}
return returnValue;
};
}() ) :
function()
{
return null;
};
rbrace = /^(?:\{.*\}|\[.*\])$/;
return function()
{
var cookies, splitOnSemiColons, cookieCount, i, splitOnEquals, name, rawValue, value;
cookies = {};
splitOnSemiColons = document.cookie.split( ';' );
cookieCount = splitOnSemiColons.length;
for( i = 0; i < cookieCount; i = i + 1 )
{
splitOnEquals = splitOnSemiColons[i].split( '=' );
name = trim( splitOnEquals.shift() );
if( splitOnEquals.length >= 1 )
{
rawValue = splitOnEquals.join( '=' );
}
else
{
rawValue = '';
}
try
{
value = decodeURIComponent( rawValue );
}
catch( e2 )
{
value = rawValue;
}
//Logic borrowed from http://jquery.com/ dataAttr method
try
{
value = value === 'true' ?
true :
value === 'false' ?
false :
! isNaN( value ) ?
parseFloat( value ) :
rbrace.test( value ) ?
parseJSON( value ) :
value;
}
catch( e3 ) {}
cookies[name] = value;
}
return cookies;
};
}() );
Constructor = function(){};
/**
* get - get one, several, or all cookies
*
* @access public
* @paramater Mixed cookieName - String:name of single cookie; Array:list of multiple cookie names; Void (no param):if you want all cookies
* @return Mixed - Value of cookie as set; Null:if only one cookie is requested and is not found; Object:hash of multiple or all cookies (if multiple or all requested);
*/
Constructor.prototype.get = function( cookieName )
{
var returnValue, item, cookies;
cookies = parseCookies();
if( typeof cookieName === 'string' )
{
returnValue = ( typeof cookies[cookieName] !== 'undefined' ) ? cookies[cookieName] : null;
}
else if( typeof cookieName === 'object' && cookieName !== null )
{
returnValue = {};
for( item in cookieName )
{
if( Object.prototype.hasOwnProperty.call( cookieName, item ) )
{
if( typeof cookies[cookieName[item]] !== 'undefined' )
{
returnValue[cookieName[item]] = cookies[cookieName[item]];
}
else
{
returnValue[cookieName[item]] = null;
}
}
}
}
else
{
returnValue = cookies;
}
return returnValue;
};
/**
* filter - get array of cookies whose names match the provided RegExp
*
* @access public
* @paramater Object RegExp - The regular expression to match against cookie names
* @return Mixed - Object:hash of cookies whose names match the RegExp
*/
Constructor.prototype.filter = function( cookieNameRegExp )
{
var cookieName, returnValue, cookies;
returnValue = {};
cookies = parseCookies();
if( typeof cookieNameRegExp === 'string' )
{
cookieNameRegExp = new RegExp( cookieNameRegExp );
}
for( cookieName in cookies )
{
if( Object.prototype.hasOwnProperty.call( cookies, cookieName ) && cookieName.match( cookieNameRegExp ) )
{
returnValue[cookieName] = cookies[cookieName];
}
}
return returnValue;
};
/**
* set - set or delete a cookie with desired options
*
* @access public
* @paramater String cookieName - name of cookie to set
* @paramater Mixed value - Any JS value. If not a string, will be JSON encoded (http://code.google.com/p/cookies/wiki/JSON); NULL to delete
* @paramater Object options - optional list of cookie options to specify
* @return void
*/
Constructor.prototype.set = function( cookieName, value, options )
{
if( typeof options !== 'object' || options === null )
{
options = {};
}
// TODO: consider value serialization method to parallel parse cookies
if( typeof value === 'undefined' || value === null )
{
value = '';
options.hoursToLive = -8760;
}
else
{
//Logic borrowed from http://jquery.com/ dataAttr method and reversed
value = value === true ?
'true' :
value === false ?
'false' :
! isNaN( value ) ?
'' + value :
value;
if( typeof value !== 'string' )
{
if( typeof JSON === 'object' && JSON !== null && typeof JSON.stringify === 'function' )
{
value = JSON.stringify( value );
}
else
{
throw new Error( 'cookies.set() received value which could not be serialized.' );
}
}
}
var optionsString = assembleOptionsString( options );
document.cookie = cookieName + '=' + encodeURIComponent( value ) + optionsString;
};
/**
* del - delete a cookie (domain and path options must match those with which the cookie was set; this is really an alias for set() with parameters simplified for this use)
*
* @access public
* @paramater MIxed cookieName - String name of cookie to delete, or Bool true to delete all
* @paramater Object options - optional list of cookie options to specify ( path, domain )
* @return void
*/
Constructor.prototype.del = function( cookieName, options )
{
var allCookies, name;
allCookies = {};
if( typeof options !== 'object' || options === null )
{
options = {};
}
if( typeof cookieName === 'boolean' && cookieName === true )
{
allCookies = this.get();
}
else if( typeof cookieName === 'string' )
{
allCookies[cookieName] = true;
}
for( name in allCookies )
{
if( Object.prototype.hasOwnProperty.call( allCookies, name ) && typeof name === 'string' && name !== '' )
{
this.set( name, null, options );
}
}
};
/**
* test - test whether the browser is accepting cookies
*
* @access public
* @return Boolean
*/
Constructor.prototype.test = function()
{
var returnValue, testName, testValue;
testName = 'cookiesCT';
testValue = 'data';
this.set( testName, testValue );
if( this.get( testName ) === testValue )
{
this.del( testName );
returnValue = true;
}
return returnValue;
};
/**
* setOptions - set default options for calls to cookie methods
*
* @access public
* @param Object options - list of cookie options to specify
* @return void
*/
Constructor.prototype.setOptions = function( options )
{
if( typeof options !== 'object' )
{
options = null;
}
defaultOptions = resolveOptions( options );
};
return new Constructor();
}() );
if( global.jQuery )
{
( function( $ )
{
var NameTokenAttrResolver, cookies, extensions;
/* alias cookies lib under jQ to meet general audience expectations */
$.cookies = cookies;
NameTokenAttrResolver = function()
{
@ -495,9 +34,7 @@
};
};
cookies = $.cookies = jaaulde.utils.cookies;
extensions = {
$.each( {
/**
* $( 'selector' ).cookify - set the value of an input field, or the innerHTML of an element, to a cookie by the name or id of the field or element
* (field or element MUST have name or id attribute)
@ -694,13 +231,8 @@
} );
} );
}
};
$.each( extensions, function( i )
}, function( i )
{
$.fn[i] = this;
} );
}( global.jQuery ) );
}
}( window ) );

View File

@ -0,0 +1,80 @@
// ####################################################################################
// ####### #######
// ####### Plugin: jScroll #######
// ####### Author: William Duffy #######
// ####### Website: http://www.wduffy.co.uk/jScroll #######
// ####### Version: 1.1 #######
// ####### #######
// ####### Copyright (c) 2011, William Duffy - www.wduffy.co.uk #######
// ####### #######
// ####### Permission is hereby granted, free of charge, to any person #######
// ####### obtaining a copy of this software and associated documentation #######
// ####### files (the "Software"), to deal in the Software without #######
// ####### restriction, including without limitation the rights to use, #######
// ####### copy, modify, merge, publish, distribute, sublicense, and/or sell #######
// ####### copies of the Software, and to permit persons to whom the #######
// ####### Software is furnished to do so, subject to the following #######
// ####### conditions: #######
// ####### #######
// ####### The above copyright notice and this permission notice shall be #######
// ####### included in all copies or substantial portions of the Software. #######
// ####### #######
// ####### THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, #######
// ####### EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES #######
// ####### OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND #######
// ####### NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT #######
// ####### HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, #######
// ####### WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #######
// ####### FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR #######
// ####### OTHER DEALINGS IN THE SOFTWARE. #######
// ####### #######
// ####################################################################################
(function($) {
// Public: jScroll Plugin
$.fn.jScroll = function(options) {
var opts = $.extend({}, $.fn.jScroll.defaults, options);
return this.each(function() {
var $element = $(this);
var $window = $(window);
var locator = new location($element);
$window.scroll(function() {
$element
.stop()
.animate(locator.getMargin($window), opts.speed);
});
});
// Private
function location($element)
{
this.min = $element.offset().top;
this.originalMargin = parseInt($element.css("margin-top"), 10) || 0;
this.getMargin = function ($window)
{
var max = $element.parent().height() - $element.outerHeight();
var margin = this.originalMargin;
if ($window.scrollTop() >= this.min)
margin = margin + opts.top + $window.scrollTop() - this.min;
if (margin > max)
margin = max;
return ({"marginTop" : margin + 'px'});
}
}
};
// Public: Default values
$.fn.jScroll.defaults = {
speed : "slow",
top : 10
};
})(jQuery);

View File

@ -3,7 +3,7 @@
// (c) 2011 Tim Wood
// Moment.js is freely distributable under the terms of the MIT license.
//
// Version 1.1.2
// Version 1.2.0
(function (Date, undefined) {
@ -13,7 +13,7 @@
hasModule = (typeof module !== 'undefined'),
paramsToParse = 'months|monthsShort|weekdays|weekdaysShort|longDateFormat|relativeTime|ordinal|meridiem'.split('|'),
i,
VERSION = "1.1.2",
VERSION = "1.2.0",
shortcuts = 'Month|Date|Hours|Minutes|Seconds'.split('|');
// left zero fill a number
@ -30,21 +30,24 @@
function dateAddRemove(date, _input, adding, val) {
var isString = (typeof _input === 'string'),
input = isString ? {} : _input,
ms, M, currentDate;
ms, d, M, currentDate;
if (isString && val) {
input[_input] = val;
}
ms = (input.ms || input.milliseconds || 0) +
(input.s || input.seconds || 0) * 1e3 + // 1000
(input.m || input.minutes || 0) * 6e4 + // 1000 * 60
(input.h || input.hours || 0) * 36e5 + // 1000 * 60 * 60
(input.d || input.days || 0) * 864e5 + // 1000 * 60 * 60 * 24
(input.w || input.weeks || 0) * 6048e5; // 1000 * 60 * 60 * 24 * 7
(input.h || input.hours || 0) * 36e5; // 1000 * 60 * 60
d = (input.d || input.days || 0) +
(input.w || input.weeks || 0) * 7;
M = (input.M || input.months || 0) +
(input.y || input.years || 0) * 12;
if (ms) {
date.setTime(+date + ms * adding);
}
if (d) {
date.setDate(date.getDate() + d * adding);
}
if (M) {
currentDate = date.getDate();
date.setDate(1);
@ -76,7 +79,8 @@
currentHours = date.getHours(),
currentMinutes = date.getMinutes(),
currentSeconds = date.getSeconds(),
charactersToReplace = /(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|LL?L?L?)/g,
currentZone = date.getTimezoneOffset(),
charactersToReplace = /(\\)?(Mo|MM?M?M?|Do|DDDo|DD?D?D?|dddd?|do?|w[o|w]?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|zz?|ZZ?|LL?L?L?)/g,
nonuppercaseLetters = /[^A-Z]/g,
timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
ordinal = moment.ordinal,
@ -173,6 +177,10 @@
// depreciating 'zz' fall through to 'z'
case 'z' :
return (date.toString().match(timezoneRegex) || [''])[0].replace(nonuppercaseLetters, '');
case 'Z' :
return (currentZone > 0 ? '+' : '-') + leftZeroFill(~~(currentZone / 60), 2) + ':' + leftZeroFill(~~(currentZone % 60), 2);
case 'ZZ' :
return (currentZone > 0 ? '+' : '-') + leftZeroFill(~~(10 * currentZone / 6), 4);
// LONG DATES
case 'L' :
case 'LL' :
@ -189,9 +197,13 @@
// date from string and format string
function makeDateFromStringAndFormat(string, format) {
var inArray = [0],
tokenCharacters = /(\\)?(MM?|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?)/g,
inputCharacters = /(\\)?([0-9]+|am|pm)/gi,
var inArray = [0, 0, 1, 0, 0, 0, 0],
timezoneHours = 0,
timezoneMinutes = 0,
isUsingUTC = false,
tokenCharacters = /(\\)?(MM?|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?|ZZ?)/g,
inputCharacters = /(\\)?([0-9]+|am|pm|([\+\-]\d\d:?\d\d))/gi,
timezoneParseRegex = /([\+\-]|\d\d)/gi,
inputParts = string.match(inputCharacters),
formatParts = format.match(tokenCharacters),
i,
@ -199,6 +211,7 @@
// function to convert string input to date
function addTime(format, input) {
var a;
switch (format) {
// MONTH
case 'M' :
@ -222,7 +235,7 @@
inArray[0] = input + (input > 70 ? 1900 : 2000);
break;
case 'YYYY' :
inArray[0] = ~~input;
inArray[0] = ~~Math.abs(input);
break;
// AM / PM
case 'a' :
@ -252,6 +265,24 @@
case 'ss' :
inArray[5] = ~~input;
break;
// TIMEZONE
case 'Z' :
// fall through to ZZ
case 'ZZ' :
isUsingUTC = true;
a = input.match(timezoneParseRegex);
if (a[1]) {
timezoneHours = ~~a[1];
}
if (a[2]) {
timezoneMinutes = ~~a[2];
}
// reverse offsets
if (a[0] === '-') {
timezoneHours = -timezoneHours;
timezoneMinutes = -timezoneMinutes;
}
break;
}
}
for (i = 0; i < formatParts.length; i++) {
@ -261,7 +292,15 @@
if (isPm && inArray[3] < 12) {
inArray[3] += 12;
}
return dateFromArray(inArray);
// if is 12 am, change hours to 0
if (! isPm && inArray[3] === 12) {
inArray[3] = 0;
}
// handle timezone
inArray[3] += timezoneHours;
inArray[4] += timezoneMinutes;
// return
return isUsingUTC ? new Date(Date.UTC.apply({}, inArray)) : dateFromArray(inArray);
}
// compare two arrays, return the number of differences
@ -281,7 +320,7 @@
// date from string and array of format strings
function makeDateFromStringAndArray(string, formats) {
var output,
inputCharacters = /(\\)?([0-9]+|am|pm)/gi,
inputCharacters = /(\\)?([0-9]+|am|pm|([\+\-]\d\d:?\d\d))/gi,
inputParts = string.match(inputCharacters),
scores = [],
scoreToBeat = 99,
@ -436,6 +475,14 @@
return this._d;
},
toString : function () {
return this._d.toString();
},
toDate : function () {
return this._d;
},
format : function (inputString) {
return formatDate(this._d, inputString);
},
@ -484,8 +531,12 @@
},
isLeapYear : function () {
var year = this._d.getFullYear();
var year = this.year();
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
},
isDST : function () {
return this.zone() !== moment([this.year()]).zone();
}
};
@ -501,7 +552,7 @@
};
}
// loop through and add shortcuts
// loop through and add shortcuts (Month, Date, Hours, Minutes, Seconds)
for (i = 0; i < shortcuts.length; i ++) {
makeShortcut(shortcuts[i].toLowerCase(), shortcuts[i]);
}
@ -514,6 +565,11 @@
return this._d.getDay();
};
// add shortcut for timezone offset (no setter)
moment.fn.zone = function () {
return this._d.getTimezoneOffset();
};
// CommonJS module is defined
if (hasModule) {
module.exports = moment;

View File

@ -168,7 +168,7 @@
var _s = {
VERSION: '1.2.0',
VERSION: '2.0.0',
isBlank: sArgs(function(str){
return (/^\s*$/).test(str);