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/) * [Ajax File Upload](http://phpletter.com/Our-Projects/AjaxFileUpload/)
* [jQuery UI Timepicker Addon](http://trentrichardson.com/examples/timepicker/) * [jQuery UI Timepicker Addon](http://trentrichardson.com/examples/timepicker/)
* [underscore.string](https://github.com/edtsech/underscore.string) * [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 'httparty'
require 'zip/zip' 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 = { sources = {
'jquery.cookies' => [ 'jquery.cookies' => [
'http://cookies.googlecode.com/svn/trunk/jquery.cookies.js' 'http://cookies.googlecode.com/svn/trunk/jquery.cookies.js'
@ -55,9 +31,36 @@ sources = {
], ],
'underscore.string' => [ 'underscore.string' => [
'https://raw.github.com/edtsech/underscore.string/master/lib/underscore.string.js' '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' desc 'Update verything'
task :update do task :update do
rm_rf 'vendor/assets' rm_rf 'vendor/assets'

View File

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

View File

@ -1,706 +1,238 @@
/** /**
* jquery.cookies.js
*
* Copyright (c) 2005 - 2011, James Auldridge * Copyright (c) 2005 - 2011, James Auldridge
* All rights reserved. * All rights reserved.
* *
* Licensed under the BSD, MIT, and GPL (your choice!) Licenses: * Licensed under the BSD, MIT, and GPL (your choice!) Licenses:
* @link http://code.google.com/p/cookies/wiki/License * @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 ) ( function( global )
{ {
"use strict"; "use strict";
var document, Object, jaaulde; /* localize 3rd party support */
var $ = global.jQuery,
/* /* localize first party support */
* localize global variables which are used more than once jaaulde = global.jaaulde,
*/ cookies = jaaulde.utils.cookies,
document = global.document; /* declarations */
Object = global.Object; NameTokenAttrResolver;
/* /* alias cookies lib under jQ to meet general audience expectations */
* jaaulde Namespace preparation - the only var introduced into global space $.cookies = cookies;
*/
jaaulde = global.jaaulde = ( global.jaaulde || {} ); NameTokenAttrResolver = function()
jaaulde.utils = jaaulde.utils || {}; {
var nameTokenAttrs = ['name', 'id'];
jaaulde.utils.cookies = ( function() this.current = null;
{ this.nextAttrName = function()
/* Private vars */ {
var defaultOptions, this.current = nameTokenAttrs.shift();
/* Private functions */ return !! this.current;
resolveOptions, assembleOptionsString, isNaN, trim, parseCookies, Constructor; };
};
defaultOptions = {
expiresAt: null, $.each( {
path: '/', /**
domain: null, * $( '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
secure: false * (field or element MUST have name or id attribute)
}; *
* @access public
/** * @param options OBJECT - list of cookie options to specify
* resolveOptions - receive an options object and ensure all options are present and valid, replacing with defaults where necessary * @return jQuery
* would prefer jQuery.extend here, but we want this library to work without jQuery */
* @access private cookify: function( options )
* @static {
* @parameter Object options - optional options to start with this
* @return Object complete and valid options object .not( ':input' )
*/ /*
resolveOptions = function( options ) Iterate non input elements
{ */
var returnValue, expireDate; .each( function()
{
if( typeof options !== 'object' || options === null ) var $this, NTAR, nameToken, value;
{
returnValue = defaultOptions; $this = $( this );
}
else NTAR = new NameTokenAttrResolver();
{
returnValue = { while( NTAR.nextAttrName() )
expiresAt: defaultOptions.expiresAt, {
path: defaultOptions.path, nameToken = $this.attr( NTAR.current );
domain: defaultOptions.domain, if( typeof nameToken === 'string' && nameToken !== '' )
secure: defaultOptions.secure {
}; value = $this.html();
if( typeof options.expiresAt === 'object' && options.expiresAt instanceof Date ) cookies.set(
{ nameToken,
returnValue.expiresAt = options.expiresAt; ( typeof value === 'string' && value !== '' ) ? value : null,
} options
else if( typeof options.hoursToLive === 'number' && options.hoursToLive !== 0 ) );
{
expireDate = new global.Date(); break;
expireDate.setTime( expireDate.getTime() + ( options.hoursToLive * 60 * 60 * 1000 ) ); }
returnValue.expiresAt = expireDate; }
} } )
.end()
if( typeof options.path === 'string' && options.path !== '' ) .filter( ':input')
{ .filter( ':radio' )
returnValue.path = options.path; /*
} Iterate radio inputs
*/
if( typeof options.domain === 'string' && options.domain !== '' ) .each( function()
{ {
returnValue.domain = options.domain;
} } )
.end()
if( options.secure === true ) .filter( ':checkbox' )
{ /*
returnValue.secure = options.secure; Iterate checkbox inputs
} */
} .each( function()
{
return returnValue;
}; } )
/** .end()
* assembleOptionsString - analyze options and assemble appropriate string for setting a cookie with those options .not( ':radio, :checkbox' )
* /*
* @access private Iterate all other inputs
* @static */
* @parameter options OBJECT - optional options to start with .each( function()
* @return STRING - complete and valid cookie setting options {
*/ var $this, NTAR, nameToken, value;
assembleOptionsString = function( options )
{ $this = $( this );
options = resolveOptions( options );
NTAR = new NameTokenAttrResolver();
return (
( typeof options.expiresAt === 'object' && options.expiresAt instanceof Date ? '; expires=' + options.expiresAt.toGMTString() : '' ) + while( NTAR.nextAttrName() )
'; path=' + options.path + {
( typeof options.domain === 'string' ? '; domain=' + options.domain : '' ) + nameToken = $this.attr( NTAR.current );
( options.secure === true ? '; secure' : '' ) if( typeof nameToken === 'string' && nameToken !== '' )
); {
}; value = $this.val();
/**
* trim - remove left and right whitespace cookies.set(
* Some logic borrowed from http://jquery.com/ nameToken,
* ( typeof value === 'string' && value !== '' ) ? value : null,
* @access private options
* @static );
* @parameter data STRING
* @return STRING break;
*/ }
trim = global.String.prototype.trim ? }
function( data ) } );
{
return global.String.prototype.trim.call( data ); return this;
} : },
( function() /**
{ * $( 'selector' ).cookieFill - set the value of an input field or the innerHTML of an element from a cookie by the name or id of the field or element
var trimLeft, trimRight; *
* @access public
trimLeft = /^\s+/; * @return jQuery
trimRight = /\s+$/; */
cookieFill: function()
return function( data ) {
{ this
return data.replace( trimLeft, '' ).replace( trimRight, '' ); .not( ':input' )
}; /*
}() ); Iterate non input elements
/** */
* isNaN - check if given value is not a number .each( function()
* Borrowed from http://jquery.com/ {
* var $this, NTAR, nameToken, value;
* @access private
* @static $this = $( this );
* @parameter obj MIXED
* @return BOOL NTAR = new NameTokenAttrResolver();
*/
isNaN = ( function() while( NTAR.nextAttrName() )
{ {
var rdigit = /\d/, isNaN = global.isNaN; nameToken = $this.attr( NTAR.current );
return function( obj ) if( typeof nameToken === 'string' && nameToken !== '' )
{ {
return ( obj === null || ! rdigit.test( obj ) || isNaN( obj ) ); value = cookies.get( nameToken );
}; if( value !== null )
}() ); {
/** $this.html( value );
* parseCookies - retrieve document.cookie string and break it into a hash with values decoded and unserialized }
*
* @access private break;
* @static }
* @return OBJECT - hash of cookies from document.cookie }
*/ } )
parseCookies = ( function() .end()
{ .filter( ':input')
var parseJSON, rbrace; .filter( ':radio' )
/*
parseJSON = global.JSON && global.JSON.parse ? Iterate radio inputs
( function() */
{ .each( function()
var rvalidchars, rvalidescape, rvalidtokens, rvalidbraces; {
rvalidchars = /^[\],:{}\s]*$/; } )
rvalidescape = /\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g; .end()
rvalidtokens = /"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g; .filter( ':checkbox' )
rvalidbraces = /(?:^|:|,)(?:\s*\[)+/g; /*
Iterate checkbox inputs
return function( data ) */
{ .each( function()
var returnValue, validJSON; {
returnValue = null; } )
.end()
if( typeof data === 'string' && data !== '' ) .not( ':radio, :checkbox' )
{ /*
// Make sure leading/trailing whitespace is removed (IE can't handle it) Iterate all other inputs
data = trim( data ); */
.each( function()
if( data !== '' ) {
{ var $this, NTAR, nameToken, value;
try
{ $this = $( this );
// 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, '' ) ); NTAR = new NameTokenAttrResolver();
returnValue = validJSON ? while( NTAR.nextAttrName() )
global.JSON.parse( data ) : {
null; nameToken = $this.attr( NTAR.current );
} if( typeof nameToken === 'string' && nameToken !== '' )
catch( e1 ) {
{ value = cookies.get( nameToken );
returnValue = null; if( value !== null )
} {
} $this.val( value );
} }
return returnValue; break;
}; }
}() ) : }
function() } );
{
return null; return this;
}; },
/**
rbrace = /^(?:\{.*\}|\[.*\])$/; * $( 'selector' ).cookieBind - call cookie fill on matching elements, and bind their change events to cookify()
*
return function() * @access public
{ * @param options OBJECT - list of cookie options to specify
var cookies, splitOnSemiColons, cookieCount, i, splitOnEquals, name, rawValue, value; * @return jQuery
*/
cookies = {}; cookieBind: function( options )
splitOnSemiColons = document.cookie.split( ';' ); {
cookieCount = splitOnSemiColons.length; return this.each( function()
{
for( i = 0; i < cookieCount; i = i + 1 ) var $this = $( this );
{ $this.cookieFill().change( function()
splitOnEquals = splitOnSemiColons[i].split( '=' ); {
$this.cookify( options );
name = trim( splitOnEquals.shift() ); } );
if( splitOnEquals.length >= 1 ) } );
{ }
rawValue = splitOnEquals.join( '=' ); }, function( i )
} {
else $.fn[i] = this;
{ } );
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;
NameTokenAttrResolver = function()
{
var nameTokenAttrs = ['name', 'id'];
this.current = null;
this.nextAttrName = function()
{
this.current = nameTokenAttrs.shift();
return !! this.current;
};
};
cookies = $.cookies = jaaulde.utils.cookies;
extensions = {
/**
* $( '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)
*
* @access public
* @param options OBJECT - list of cookie options to specify
* @return jQuery
*/
cookify: function( options )
{
this
.not( ':input' )
/*
Iterate non input elements
*/
.each( function()
{
var $this, NTAR, nameToken, value;
$this = $( this );
NTAR = new NameTokenAttrResolver();
while( NTAR.nextAttrName() )
{
nameToken = $this.attr( NTAR.current );
if( typeof nameToken === 'string' && nameToken !== '' )
{
value = $this.html();
cookies.set(
nameToken,
( typeof value === 'string' && value !== '' ) ? value : null,
options
);
break;
}
}
} )
.end()
.filter( ':input')
.filter( ':radio' )
/*
Iterate radio inputs
*/
.each( function()
{
} )
.end()
.filter( ':checkbox' )
/*
Iterate checkbox inputs
*/
.each( function()
{
} )
.end()
.not( ':radio, :checkbox' )
/*
Iterate all other inputs
*/
.each( function()
{
var $this, NTAR, nameToken, value;
$this = $( this );
NTAR = new NameTokenAttrResolver();
while( NTAR.nextAttrName() )
{
nameToken = $this.attr( NTAR.current );
if( typeof nameToken === 'string' && nameToken !== '' )
{
value = $this.val();
cookies.set(
nameToken,
( typeof value === 'string' && value !== '' ) ? value : null,
options
);
break;
}
}
} );
return this;
},
/**
* $( 'selector' ).cookieFill - set the value of an input field or the innerHTML of an element from a cookie by the name or id of the field or element
*
* @access public
* @return jQuery
*/
cookieFill: function()
{
this
.not( ':input' )
/*
Iterate non input elements
*/
.each( function()
{
var $this, NTAR, nameToken, value;
$this = $( this );
NTAR = new NameTokenAttrResolver();
while( NTAR.nextAttrName() )
{
nameToken = $this.attr( NTAR.current );
if( typeof nameToken === 'string' && nameToken !== '' )
{
value = cookies.get( nameToken );
if( value !== null )
{
$this.html( value );
}
break;
}
}
} )
.end()
.filter( ':input')
.filter( ':radio' )
/*
Iterate radio inputs
*/
.each( function()
{
} )
.end()
.filter( ':checkbox' )
/*
Iterate checkbox inputs
*/
.each( function()
{
} )
.end()
.not( ':radio, :checkbox' )
/*
Iterate all other inputs
*/
.each( function()
{
var $this, NTAR, nameToken, value;
$this = $( this );
NTAR = new NameTokenAttrResolver();
while( NTAR.nextAttrName() )
{
nameToken = $this.attr( NTAR.current );
if( typeof nameToken === 'string' && nameToken !== '' )
{
value = cookies.get( nameToken );
if( value !== null )
{
$this.val( value );
}
break;
}
}
} );
return this;
},
/**
* $( 'selector' ).cookieBind - call cookie fill on matching elements, and bind their change events to cookify()
*
* @access public
* @param options OBJECT - list of cookie options to specify
* @return jQuery
*/
cookieBind: function( options )
{
return this.each( function()
{
var $this = $( this );
$this.cookieFill().change( function()
{
$this.cookify( options );
} );
} );
}
};
$.each( extensions, function( i )
{
$.fn[i] = this;
} );
}( global.jQuery ) );
}
}( window ) ); }( 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 // (c) 2011 Tim Wood
// Moment.js is freely distributable under the terms of the MIT license. // Moment.js is freely distributable under the terms of the MIT license.
// //
// Version 1.1.2 // Version 1.2.0
(function (Date, undefined) { (function (Date, undefined) {
@ -13,7 +13,7 @@
hasModule = (typeof module !== 'undefined'), hasModule = (typeof module !== 'undefined'),
paramsToParse = 'months|monthsShort|weekdays|weekdaysShort|longDateFormat|relativeTime|ordinal|meridiem'.split('|'), paramsToParse = 'months|monthsShort|weekdays|weekdaysShort|longDateFormat|relativeTime|ordinal|meridiem'.split('|'),
i, i,
VERSION = "1.1.2", VERSION = "1.2.0",
shortcuts = 'Month|Date|Hours|Minutes|Seconds'.split('|'); shortcuts = 'Month|Date|Hours|Minutes|Seconds'.split('|');
// left zero fill a number // left zero fill a number
@ -30,21 +30,24 @@
function dateAddRemove(date, _input, adding, val) { function dateAddRemove(date, _input, adding, val) {
var isString = (typeof _input === 'string'), var isString = (typeof _input === 'string'),
input = isString ? {} : _input, input = isString ? {} : _input,
ms, M, currentDate; ms, d, M, currentDate;
if (isString && val) { if (isString && val) {
input[_input] = val; input[_input] = val;
} }
ms = (input.ms || input.milliseconds || 0) + ms = (input.ms || input.milliseconds || 0) +
(input.s || input.seconds || 0) * 1e3 + // 1000 (input.s || input.seconds || 0) * 1e3 + // 1000
(input.m || input.minutes || 0) * 6e4 + // 1000 * 60 (input.m || input.minutes || 0) * 6e4 + // 1000 * 60
(input.h || input.hours || 0) * 36e5 + // 1000 * 60 * 60 (input.h || input.hours || 0) * 36e5; // 1000 * 60 * 60
(input.d || input.days || 0) * 864e5 + // 1000 * 60 * 60 * 24 d = (input.d || input.days || 0) +
(input.w || input.weeks || 0) * 6048e5; // 1000 * 60 * 60 * 24 * 7 (input.w || input.weeks || 0) * 7;
M = (input.M || input.months || 0) + M = (input.M || input.months || 0) +
(input.y || input.years || 0) * 12; (input.y || input.years || 0) * 12;
if (ms) { if (ms) {
date.setTime(+date + ms * adding); date.setTime(+date + ms * adding);
} }
if (d) {
date.setDate(date.getDate() + d * adding);
}
if (M) { if (M) {
currentDate = date.getDate(); currentDate = date.getDate();
date.setDate(1); date.setDate(1);
@ -76,7 +79,8 @@
currentHours = date.getHours(), currentHours = date.getHours(),
currentMinutes = date.getMinutes(), currentMinutes = date.getMinutes(),
currentSeconds = date.getSeconds(), 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, nonuppercaseLetters = /[^A-Z]/g,
timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g, timezoneRegex = /\([A-Za-z ]+\)|:[0-9]{2} [A-Z]{3} /g,
ordinal = moment.ordinal, ordinal = moment.ordinal,
@ -173,6 +177,10 @@
// depreciating 'zz' fall through to 'z' // depreciating 'zz' fall through to 'z'
case 'z' : case 'z' :
return (date.toString().match(timezoneRegex) || [''])[0].replace(nonuppercaseLetters, ''); 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 // LONG DATES
case 'L' : case 'L' :
case 'LL' : case 'LL' :
@ -189,9 +197,13 @@
// date from string and format string // date from string and format string
function makeDateFromStringAndFormat(string, format) { function makeDateFromStringAndFormat(string, format) {
var inArray = [0], var inArray = [0, 0, 1, 0, 0, 0, 0],
tokenCharacters = /(\\)?(MM?|DD?D?D?|YYYY|YY|a|A|hh?|HH?|mm?|ss?)/g, timezoneHours = 0,
inputCharacters = /(\\)?([0-9]+|am|pm)/gi, 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), inputParts = string.match(inputCharacters),
formatParts = format.match(tokenCharacters), formatParts = format.match(tokenCharacters),
i, i,
@ -199,6 +211,7 @@
// function to convert string input to date // function to convert string input to date
function addTime(format, input) { function addTime(format, input) {
var a;
switch (format) { switch (format) {
// MONTH // MONTH
case 'M' : case 'M' :
@ -222,7 +235,7 @@
inArray[0] = input + (input > 70 ? 1900 : 2000); inArray[0] = input + (input > 70 ? 1900 : 2000);
break; break;
case 'YYYY' : case 'YYYY' :
inArray[0] = ~~input; inArray[0] = ~~Math.abs(input);
break; break;
// AM / PM // AM / PM
case 'a' : case 'a' :
@ -252,6 +265,24 @@
case 'ss' : case 'ss' :
inArray[5] = ~~input; inArray[5] = ~~input;
break; 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++) { for (i = 0; i < formatParts.length; i++) {
@ -261,7 +292,15 @@
if (isPm && inArray[3] < 12) { if (isPm && inArray[3] < 12) {
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 // compare two arrays, return the number of differences
@ -281,7 +320,7 @@
// date from string and array of format strings // date from string and array of format strings
function makeDateFromStringAndArray(string, formats) { function makeDateFromStringAndArray(string, formats) {
var output, var output,
inputCharacters = /(\\)?([0-9]+|am|pm)/gi, inputCharacters = /(\\)?([0-9]+|am|pm|([\+\-]\d\d:?\d\d))/gi,
inputParts = string.match(inputCharacters), inputParts = string.match(inputCharacters),
scores = [], scores = [],
scoreToBeat = 99, scoreToBeat = 99,
@ -436,6 +475,14 @@
return this._d; return this._d;
}, },
toString : function () {
return this._d.toString();
},
toDate : function () {
return this._d;
},
format : function (inputString) { format : function (inputString) {
return formatDate(this._d, inputString); return formatDate(this._d, inputString);
}, },
@ -484,8 +531,12 @@
}, },
isLeapYear : function () { isLeapYear : function () {
var year = this._d.getFullYear(); var year = this.year();
return (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0; 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 ++) { for (i = 0; i < shortcuts.length; i ++) {
makeShortcut(shortcuts[i].toLowerCase(), shortcuts[i]); makeShortcut(shortcuts[i].toLowerCase(), shortcuts[i]);
} }
@ -514,6 +565,11 @@
return this._d.getDay(); return this._d.getDay();
}; };
// add shortcut for timezone offset (no setter)
moment.fn.zone = function () {
return this._d.getTimezoneOffset();
};
// CommonJS module is defined // CommonJS module is defined
if (hasModule) { if (hasModule) {
module.exports = moment; module.exports = moment;

View File

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