/**
* Spiral/plugins 0.1 **CORE**
* Compilation of usefull jQuery plugins
* */
//jquery.dom.js
//jquery.dom.form_params.js
(function( $ ) {
var radioCheck = /radio|checkbox/i,
keyBreaker = /[^\[\]]+/g,
numberMatcher = /^[\-+]?[0-9]*\.?[0-9]+([eE][\-+]?[0-9]+)?$/;
var isNumber = function( value ) {
if ( typeof value == 'number' ) {
return true;
}
if ( typeof value != 'string' ) {
return false;
}
return value.match(numberMatcher);
};
$.fn.extend({
/**
* @parent dom
* @download http://jmvcsite.heroku.com/pluginify?plugins[]=jquery/dom/form_params/form_params.js
* @plugin jquery/dom/form_params
* @test jquery/dom/form_params/qunit.html
*
* Returns an object of name-value pairs that represents values in a form.
* It is able to nest values whose element's name has square brackets.
*
* Example html:
* @codestart html
* <form>
* <input name="foo[bar]" value='2'/>
* <input name="foo[ced]" value='4'/>
* <form/>
* @codeend
* Example code:
*
* $('form').formParams() //-> { foo:{bar:'2', ced: '4'} }
*
*
* @demo jquery/dom/form_params/form_params.html
*
* @param {Boolean} [convert=false] True if strings that look like numbers and booleans should be converted. Defaults to true.
* @return {Object} An object of name-value pairs.
*/
formParams: function( convert ) {
if ( this[0].nodeName.toLowerCase() == 'form' && this[0].elements ) {
return jQuery(jQuery.makeArray(this[0].elements)).getParams(convert);
}
return jQuery("input[name], textarea[name], select[name]", this[0]).getParams(convert);
},
getParams: function( convert ) {
var data = {},
current;
convert = convert === undefined ? false : convert;
this.each(function() {
var el = this,
type = el.type && el.type.toLowerCase();
//if we are submit, ignore
if ((type == 'submit') || !el.name ) {
return;
}
var key = el.name;
var value = $.data(el, "value") || $.fn.val.call($(el)),
isRadioCheck = radioCheck.test(el.type),
parts = key.match(keyBreaker),
write = !isRadioCheck || !! el.checked,
//make an array of values
lastPart;
if ( convert ) {
if ( isNumber(value) ) {
value = parseFloat(value);
} else if ( value === 'true') {
value = true;
} else if ( value === 'false' ) {
value = false;
}
if(value === '') {
value = undefined;
}
}
// go through and create nested objects
current = data;
for ( var i = 0; i < parts.length - 1; i++ ) {
if (!current[parts[i]] ) {
current[parts[i]] = {};
}
current = current[parts[i]];
}
lastPart = parts[parts.length - 1];
//now we are on the last part, set the value
if ( lastPart in current && type === "checkbox" ) {
if (!$.isArray(current[lastPart]) ) {
current[lastPart] = current[lastPart] === undefined ? [] : [current[lastPart]];
}
if ( write ) {
current[lastPart].push(value);
}
} else if ( write || !current[lastPart] ) {
current[lastPart] = write ? value : undefined;
}
});
return data;
}
});
})(jQuery);
/**
* Cookie plugin
*
* Copyright (c) 2006 Klaus Hartl (stilbuero.de)
* Dual licensed under the MIT and GPL licenses:
* http://www.opensource.org/licenses/mit-license.php
* http://www.gnu.org/licenses/gpl.html
*
*/
/**
* Create a cookie with the given name and value and other optional parameters.
*
* @example $.cookie('the_cookie', 'the_value');
* @desc Set the value of a cookie.
* @example $.cookie('the_cookie', 'the_value', { expires: 7, path: '/', domain: 'jquery.com', secure: true });
* @desc Create a cookie with all available options.
* @example $.cookie('the_cookie', 'the_value');
* @desc Create a session cookie.
* @example $.cookie('the_cookie', null);
* @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain
* used when the cookie was set.
*
* @param String name The name of the cookie.
* @param String value The value of the cookie.
* @param Object options An object literal containing key/value pairs to provide optional cookie attributes.
* @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object.
* If a negative value is specified (e.g. a date in the past), the cookie will be deleted.
* If set to null or omitted, the cookie will be a session cookie and will not be retained
* when the the browser exits.
* @option String path The value of the path atribute of the cookie (default: path of page that created the cookie).
* @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie).
* @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will
* require a secure protocol (like HTTPS).
* @type undefined
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
/**
* Get the value of a cookie with the given name.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String name The name of the cookie.
* @return The value of the cookie.
* @type String
*
* @name $.cookie
* @cat Plugins/Cookie
* @author Klaus Hartl/klaus.hartl@stilbuero.de
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {
path: '/'
};
if (value === null) {
value = '';
options.expires = -1;
}
var expires = '';
if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
var date;
if (typeof options.expires == 'number') {
date = new Date();
date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
} else {
date = options.expires;
}
expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
}
// CAUTION: Needed to parenthesize options.path and options.domain
// in the following expressions, otherwise they evaluate to undefined
// in the packed version for some reason...
var path = options.path ? '; path=' + (options.path) : '';
var domain = options.domain ? '; domain=' + (options.domain) : '';
var secure = options.secure ? '; secure' : '';
document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
} else { // only name given, get cookie
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
};
/*
* jQuery selectBox - A cosmetic, styleable replacement for SELECT elements
*
* Copyright 2012 Cory LaViska for A Beautiful Site, LLC.
*
* https://github.com/claviska/jquery-selectBox
*
* Licensed under both the MIT license and the GNU GPLv2 (same as jQuery: http://jquery.org/license)
*
*/
if(jQuery) (function($) {
$.extend($.fn, {
selectBox: function(method, data) {
var typeTimer,
typeSearch = '',
isMac = navigator.platform.match(/mac/i);
//
// Private methods
//
var init = function(select, data) {
var options;
// Disable for iOS devices (their native controls are more suitable for a touch device)
if( navigator.userAgent.match(/iPad|iPhone|Android|IEMobile|BlackBerry/i) ) return false;
// Element must be a select control
if( select.tagName.toLowerCase() !== 'select' ) return false;
select = $(select);
if( select.data('selectBox-control') ) return false;
var control = $(''),
inline = select.attr('multiple') || parseInt(select.attr('size')) > 1;
var settings = data || {};
control
.width(select.outerWidth())
.addClass(select.attr('class'))
.attr('title', select.attr('title') || '')
.attr('tabindex', parseInt(select.attr('tabindex')))
.css('display', 'inline-block')
.bind('focus.selectBox', function() {
if( this !== document.activeElement ) $(document.activeElement).blur();
if( control.hasClass('selectBox-active') ) return;
control.addClass('selectBox-active');
select.trigger('focus');
})
.bind('blur.selectBox', function() {
if( !control.hasClass('selectBox-active') ) return;
control.removeClass('selectBox-active');
select.trigger('blur');
});
if( !$(window).data('selectBox-bindings') ) {
$(window)
.data('selectBox-bindings', true)
.bind('scroll.selectBox', hideMenus)
.bind('resize.selectBox', hideMenus);
}
if( select.attr('disabled') ) control.addClass('selectBox-disabled');
// Focus on control when label is clicked
select.bind('click.selectBox', function(event) {
control.focus();
event.preventDefault();
});
// Generate control
if( inline ) {
//
// Inline controls
//
options = getOptions(select, 'inline');
control
.append(options)
.data('selectBox-options', options)
.addClass('selectBox-inline selectBox-menuShowing')
.bind('keydown.selectBox', function(event) {
handleKeyDown(select, event);
})
.bind('keypress.selectBox', function(event) {
handleKeyPress(select, event);
})
.bind('mousedown.selectBox', function(event) {
if( $(event.target).is('A.selectBox-inline') ) event.preventDefault();
if( !control.hasClass('selectBox-focus') ) control.focus();
})
.insertAfter(select);
// Auto-height based on size attribute
if( !select[0].style.height ) {
var size = select.attr('size') ? parseInt(select.attr('size')) : 5;
// Draw a dummy control off-screen, measure, and remove it
var tmp = control
.clone()
.removeAttr('id')
.css({
position: 'absolute',
top: '-9999em'
})
.show()
.appendTo('body');
tmp.find('.selectBox-options').html('