/**
* jQuery plugin for adding, removing and making changes to CSS rules
*
* @author Vimal Aravindashan
* @version 0.3.6
* @licensed MIT license
*/
(function ($) {
var _ahref = $(document.createElement('a')), /**< tag used for evaluating hrefs */
_styles = _ahref.prop('style'), /**< Collection of styles available on the host */
_sheet = function(s) {
return s.sheet || s.styleSheet;
}($('').appendTo('head')[0]), /**< StyleSheet for adding new rules*/
_rules = ('cssRules' in _sheet) ? 'cssRules' : 'rules', /**< Attribute name for rules collection in a stylesheet */
vendorPrefixes = ["Webkit", "O", "Moz", "ms"]; /**< Case sensitive list of vendor specific prefixes */
/**
* @function filterStyleSheet
* Filter a stylesheet based on accessibility and, ID or location
* @param {String} filter Filter to be applied. id or href of the style element can be used as filters.
* @param {CSSStyleSheet} styleSheet StyleSheet to be filtered
* @returns {Boolean} true if styleSheet matches the filter, false otherwise
*/
function filterStyleSheet(filter, styleSheet) {
try {
if(styleSheet[_rules]) {
filter = filter || '';
var node = $(styleSheet.ownerNode || styleSheet.owningElement);
return (filter === '') || (filter === '*') ||
('#'+(node.prop('id') || '') == filter) ||
((node.prop('href') || '') == _ahref.prop('href', filter).prop('href'));
} else {
return false;
}
} catch(e) {
return false;
}
}
/**
* @function parseSelector
* Splits a jQuery.stylesheet compatible selector into stylesheet filter and selector text
* @param {String} selector Selector text to be parsed
* @returns {Object} object with two properties 'styleSheet' and 'selectorText'
*/
function parseSelector(selector) {
var styleSheet = (/.*?{/.exec(selector) || ['{'])[0],
selectorText = /{.*}/g.exec(selector); //TODO: replace selector with dict object
if(selectorText === null) {
var parts = selector.split('{');
selectorText = '{'+parts[parts.length==1 ? 0 : 1].split('}')[0]+'}';
} else {
selectorText = selectorText[0];
}
return {
styleSheet: $.trim(styleSheet.substr(0, styleSheet.length-1)),
selectorText: normalizeSelector(selectorText.substr(1, selectorText.length-2))
};
}
/**
* @function normalizeSelector
* Normalizes selectorText to work cross-browser
* @param {String} selectorText selector string to normalize
* @returns {String} normalized selector string
*/
function normalizeSelector(selectorText) {
var selector = [], last, len;
last = _sheet[_rules].length;
insertRule.call(_sheet, selectorText, ';'); //NOTE: IE doesn't seem to mind ';' as non-empty
len = _sheet[_rules].length;
for(var i=len-1; i>=last; i--) {
selector.push(_sheet[_rules][i].selectorText);
deleteRule.call(_sheet, i);
}
return selector.reverse().join(', ');
}
/**
* @function matchSelector
* Matches given selector to selectorText of cssRule
* @param {CSSStyleRule} cssRule to match with
* @param {String} selectorText selector string to compare
* @param {Boolean} matchGroups when true, selector is matched in grouped style rules
* @returns true if selectorText of cssRule matches given selector, false otherwise
*/
function matchSelector(cssRule, selectorText, matchGroups) {
if($.type(cssRule.selectorText) !== 'string') {
return false;
}
if(cssRule.selectorText === selectorText) {
return true;
} else if (matchGroups === true) {
return $($.map(cssRule.selectorText.split(','), $.trim)).filter(function(i) {
return this.toString() === selectorText;
}).length > 0;
} else {
return false;
}
}
/**
* @function vendorPropName
* Vendor prefixed style property name.
* Based on similar function in jQuery library.
* @param {String} name camelCased CSS property name
* @returns {String} Vendor specific tag prefixed style name
* if found in styles, else passed name as-is
* @see vendorPrefixes
* @see _styles
*/
function vendorPropName(name) {
var titleName = name[0].toUpperCase() + name.slice(1),
styleName, i = vendorPrefixes.length;
while( --i ) {
styleName = vendorPrefixes[i] + titleName;
if(styleName in _styles) {
return styleName;
}
}
return name;
}
/**
* @function normalizeRule
* Normalizes the CSSStyleRule object to work better across browsers
* @param {CSSStyleRule} rule CSSStyleRule object to be normalized
* @param {StyleSheet} styleSheet parent stylesheet of the rule
* @returns {CSSStyleRule} normalized CSSStyleRule
*/
function normalizeRule(rule, styleSheet) {
//NOTE: this is experimental, however, it does have it's benefits
// for use with $.animate(), be sure to include jquery.stylesheet-animate.js as well
//TODO: move some of the defaults used here to user options
rule.ownerDocument = rule.ownerDocument || document; //XXX: Hack for jQuery.isHidden()
rule.nodeType = rule.nodeType || 1; //XXX: Hack for jQuery's defaultPrefilter()
rule.nodeName = rule.nodeName || 'DIV'; //XXX: Hack for jQuery's acceptData()
rule.parentNode = rule.parentNode || styleSheet.ownerNode || styleSheet.owningElement; //XXX: Hack for jQuery.contains()
rule.parentStyleSheet = rule.parentStyleSheet || styleSheet; //XXX: Fix for IE7
return rule;
}
/*
* Checking for 'instanceof CSSStyleRule' fails in IE7 but not in IE8, however, the call to normalizeRule() fails in both.
* So, we will define our custom CSSStyleRule class on all browsers where normalizeRule() fails.
*/
try {
normalizeRule(_sheet[_rules][0], _sheet);
$.support.nativeCSSStyleRule = true;
} catch(e) {
$.support.nativeCSSStyleRule = false;
CSSStyleRule = function(rule) {
$.extend(this, rule);
this.rule = rule; //XXX: deleteRule() requires the original object
this.currentStyle = rule.style; //XXX: Hack for jQuery's curCSS()/getStyles() for IE7
};
}
/**
* @function insertRule
* Cross-browser function for inserting rules
* @param {String} selector selectorText for the rule
* @param {String} css CSS property-value pair string
* @param {Number} index Index position to insert the string;
* defaults to end of rules collection
*/
function insertRule(selector, css, index) {
if(!selector || !css) {
return -1; //NOTE: IE does not like addRule(selector,'',index)
}
var self = this,
_insfn = self.insertRule ? function (selector, css, index) { this.insertRule(selector+'{'+css+'}', index); } : self.addRule;
index = index || this[_rules].length;
try {
return _insfn.call(self, selector, css, index);
} catch(e) {
$.each(selector.split(','), function(i, sel) {
_insfn.call(self, $.trim(sel), css);
});
return -1;
}
}
/**
* @function deleteRule
* Cross-browser function for deleting rules
* @param {Number|CSSStyleRule} Index of rule to be deleted, or
* reference to rule to be deleted from rules collection
*/
function deleteRule(rule) {
//NOTE: If we are using our custom CSSStyleRule, then CSSStyleRule.rule is the real style rule object
rule = (rule && rule.rule) ? rule.rule : rule;
if(!rule) {
return;
}
var self = this,
_delfn = self.deleteRule || self.removeRule;
if(!_delfn) { //NOTE: IE7 has issues with rule.parentStyleSheet, so we need to search for the parent stylesheet
$(document.styleSheets).each(function (i, styleSheet) {
if($(styleSheet[_rules]).filter(function() {return this === rule;}).length == 1) {
self = styleSheet;
_delfn = self.deleteRule || self.removeRule;
return false;
}
});
}
if($.type(rule) == 'number') {
_delfn.call(self, rule);
} else {
$.each(self[_rules], function (i, _rule) {
if(rule === _rule) {
_delfn.call(self, i);
return false;
}
});
}
}
/**
* jQuery.stylesheet
*
* Constructor/Factory method for initializing a jQuery.stylesheet object.
* Includes a short-cut to apply style changes immediately.
* @param {String} selector CSS rule selector text with optional stylesheet filter
* @param {String|Array|Object} name Name of style property to get/set.
* Also accepts array of property names and object of name/value pairs.
* @param {String} value If defined, then value of the style property
* is updated with it. Unused when name is an object map.
* @returns {jQuery.stylesheet|String|Object} A new jQuery.stylesheet object
* if name/value is not passed, or value of property or object of name/value pairs
*/
$.stylesheet = function (selector, name, value) {
if(!(this instanceof $.stylesheet)) {
return new $.stylesheet(selector, name, value);
}
this.init(selector);
return this.css(name, value);
};
$.extend($.stylesheet, {
/**
* @function jQuery.stylesheet.cssRules
* @param {String} selector CSS rule selector text with optional stylesheet filter
* @returns {Array} Array of CSSStyleRule objects that match the selector text
* and pass the stylesheet filter
*/
cssRules: function (selector) {
var rules = [],
filters = parseSelector(selector);
//NOTE: The stylesheet filter will be treated as case-sensitive
// The selectorText filter's case depends on the browser
$(document.styleSheets).each(function (i, styleSheet) {
if(filterStyleSheet(filters.styleSheet, styleSheet)) {
$.merge(rules, $(styleSheet[_rules]).filter(function() {
return matchSelector(this, filters.selectorText, filters.styleSheet === '*');
}).map(function() {
return normalizeRule($.support.nativeCSSStyleRule ? this : new CSSStyleRule(this), styleSheet);
}));
}
});
return rules.reverse();
},
/**
* @function jQuery.stylesheet.camelCase
* jQuery.camelCase is undocumented and could be removed at any point
* @param {String} str Hypenated string to be camelCased
* @returns {String} camelCased string
*/
camelCase: $.camelCase || function( str ) {
return str.replace(/-([\da-z])/g, function(a){return a.toUpperCase().replace('-','');});
},
/**
* Normalized CSS property names
* jQuery.cssProps is undocumented and could be removed at any point
*/
cssProps: $.cssProps || {},
/**
* @function jQuery.styesheet.cssStyleName
* @param {String} name Hypenated CSS property name
* @returns {String} camelCased or vendor specific name if found in host styles
*/
cssStyleName: function (name) {
if(name) {
var camelcasedName = $.camelCase(name);
if(camelcasedName in _styles) {
return camelcasedName;
} else if (($.cssProps[name] || ($.cssProps[name] = vendorPropName(camelcasedName))) in _styles) {
return $.cssProps[name];
}
}
}
});
$.stylesheet.fn = $.stylesheet.prototype = {
/**
* @function jQuery.stylesheet.fn.init
* Initializes a jQuery.stylesheet object.
* Selects a list of applicable CSS rules for given selector.
* @see jQuery.stylesheet.cssRules
* @param {String|Array|Object} selector CSS rule selector text(s)
* with optional stylesheet filter(s)
*/
init: function (selector) {
var rules = []; /**< Array of CSSStyleRule objects matching the selector initialized with */
switch($.type(selector)) {
case 'string':
rules = $.stylesheet.cssRules(selector);
break;
case 'array':
$.each(selector, function (idx, val) {
if($.type(val) === 'string') {
$.merge(rules, $.stylesheet.cssRules(val));
} else if(val instanceof CSSStyleRule) {
rules.push(val);
}
});
break;
case 'object':
if(selector instanceof CSSStyleRule) {
rules.push(val);
}
break;
}
$.extend(this, {
/**
* @function jQuery.stylesheet.rules
* @returns {Array} Copy of array of CSSStyleRule objects used
* by this instance of jQuery.stylesheet
*/
rules: function() {
return rules.slice();
},
/**
* @function jQuery.stylesheet.css()
* @param {String|Array|Object} name Name of style property to get/set.
* Also accepts array of property names and object of name/value pairs.
* @param {String} value If defined, then value of the style property
* is updated with it. Unused when name is an object map.
* @returns {jQuery.stylesheet|String|Object} A new jQuery.stylesheet object
* if name/value is not passed, or value of property or object of name/value pairs
*/
css: function (name, value) {
var self = this, styles = undefined;
switch($.type(name)) {
case 'null':
$.each(rules, function (idx, rule) {
deleteRule.call(rule.parentStyleSheet, rule);
});
//NOTE: Safari seems to replace the rules collection object on insert/delete
// Refresh our private collection to reflect the changes
rules = $.stylesheet.cssRules(selector);
return self;
case 'string':
var stylename = $.stylesheet.cssStyleName(name);
if(stylename) {
if(rules.length === 0 && value !== undefined) {
var filters = parseSelector(selector),
sheet = $(document.styleSheets).filter(function () {
return filterStyleSheet(filters.styleSheet, this);
});
sheet = (sheet && sheet.length == 1) ? sheet[0] : _sheet;
insertRule.call(sheet, filters.selectorText, name+':'+value+';');
//NOTE: See above note on Safari
// Also, IE has different behaviour for grouped selectors
rules = $.stylesheet.cssRules(selector);
styles = self;
} else {
$.each(rules, function (i, rule) {
if(rule.style[stylename] !== '') {
if(value !== undefined) {
rule.style[stylename] = value;
styles = self;
} else {
styles = rule.style[stylename];
}
return false;
}
});
if(styles === undefined && value !== undefined) {
rules[0].style[stylename] = value;
styles = self;
}
}
}
break;
case 'array':
styles = {};
$.each(name, function (idx, key) {
styles[key] = self.css(key, value);
});
if(value !== undefined) {
styles = self;
}
break;
case 'object':
$.each(name, function (key, val) {
self.css(key, val);
});
return self;
default: /*undefined*/
return self;
}
return styles;
}
});
}
};
})(jQuery);/*
* Depend Class v0.1b : attach class based on first class in list of current element
* File: jquery.dependClass.js
* Copyright (c) 2009 Egor Hmelyoff, hmelyoff@gmail.com
*/
(function($) {
// Init plugin function
$.baseClass = function(obj){
obj = $(obj);
return obj.get(0).className.match(/([^ ]+)/)[1];
};
$.fn.addDependClass = function(className, delimiter){
var options = {
delimiter: delimiter ? delimiter : '-'
}
return this.each(function(){
var baseClass = $.baseClass(this);
if(baseClass)
$(this).addClass(baseClass + options.delimiter + className);
});
};
$.fn.removeDependClass = function(className, delimiter){
var options = {
delimiter: delimiter ? delimiter : '-'
}
return this.each(function(){
var baseClass = $.baseClass(this);
if(baseClass)
$(this).removeClass(baseClass + options.delimiter + className);
});
};
$.fn.toggleDependClass = function(className, delimiter){
var options = {
delimiter: delimiter ? delimiter : '-'
}
return this.each(function(){
var baseClass = $.baseClass(this);
if(baseClass)
if($(this).is("." + baseClass + options.delimiter + className))
$(this).removeClass(baseClass + options.delimiter + className);
else
$(this).addClass(baseClass + options.delimiter + className);
});
};
// end of closure
})(jQuery);;(function($) {
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are intended to be exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').bind('submit', function() {
$(this).ajaxSubmit({
target: '#output'
});
return false; // <-- important!
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
/**
* ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*/
$.fn.ajaxSubmit = function(options) {
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
if (!this.length) {
//log('ajaxSubmit: skipping submit process - no element selected');
return this;
}
if (typeof options == 'function') {
options = { success: options };
}
var url = $.trim(this[0].getAttribute('action')); //BUG: this.attr('action')
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/)||[])[1];
}
url = url || window.location.href || '';
options = $.extend(true, {
url: url,
type: this.attr('method') || 'GET',
iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank'
}, options);
// hook for manipulating the form data before it is extracted;
// convenient for use with rich editors like tinyMCE or FCKEditor
var veto = {};
this.trigger('form-pre-serialize', [this, options, veto]);
if (veto.veto) {
//log('ajaxSubmit: submit vetoed via form-pre-serialize trigger');
return this;
}
// provide opportunity to alter form data before it is serialized
if (options.beforeSerialize && options.beforeSerialize(this, options) === false) {
//log('ajaxSubmit: submit aborted via beforeSerialize callback');
return this;
}
var n,v,a = this.formToArray(options.semantic);
if (options.data) {
options.extraData = options.data;
for (n in options.data) {
if(options.data[n] instanceof Array) {
for (var k in options.data[n]) {
a.push( { name: n, value: options.data[n][k] } );
}
}
else {
v = options.data[n];
v = $.isFunction(v) ? v() : v; // if value is fn, invoke it
a.push( { name: n, value: v } );
}
}
}
// give pre-submit callback an opportunity to abort the submit
if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) {
//log('ajaxSubmit: submit aborted via beforeSubmit callback');
return this;
}
// fire vetoable 'validate' event
this.trigger('form-submit-validate', [a, this, options, veto]);
if (veto.veto) {
//log('ajaxSubmit: submit vetoed via form-submit-validate trigger');
return this;
}
var q = $.param(a);
if (options.type.toUpperCase() == 'GET') {
options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q;
options.data = null; // data is null for 'get'
}
else {
options.data = q; // data is the query string for 'post'
}
var $form = this, callbacks = [];
if (options.resetForm) {
callbacks.push(function() { $form.resetForm(); });
}
if (options.clearForm) {
callbacks.push(function() { $form.clearForm(); });
}
// perform a load on the target only if dataType is not provided
if (!options.dataType && options.target) {
var oldSuccess = options.success || function(){};
callbacks.push(function(data) {
var fn = options.replaceTarget ? 'replaceWith' : 'html';
$(options.target)[fn](data).each(oldSuccess, arguments);
});
}
else if (options.success) {
callbacks.push(options.success);
}
options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg
var context = options.context || options; // jQuery 1.4+ supports scope context
for (var i=0, max=callbacks.length; i < max; i++) {
callbacks[i].apply(context, [data, status, xhr || $form, $form]);
}
};
// are there files to upload?
var fileInputs = $('input:file', this).length > 0;
var mp = 'multipart/form-data';
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
// options.iframe allows user to force iframe mode
// 06-NOV-09: now defaulting to iframe mode if file input is detected
if (options.iframe !== false && (fileInputs || options.iframe || multipart)) {
// hack to fix Safari hang (thanks to Tim Molendijk for this)
// see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d
if (options.closeKeepAlive) {
$.get(options.closeKeepAlive, fileUpload);
}
else {
fileUpload();
}
}
else {
$.ajax(options);
}
// fire 'notify' event
this.trigger('form-submit-notify', [this, options]);
return this;
// private function for handling file uploads (hat tip to YAHOO!)
function fileUpload() {
var form = $form[0];
if ($(':input[name=submit],:input[id=submit]', form).length) {
// if there is an input with a name or id of 'submit' then we won't be
// able to invoke the submit fn on the form (at least not x-browser)
alert('Error: Form elements must not have name or id of "submit".');
return;
}
var s = $.extend(true, {}, $.ajaxSettings, options);
s.context = s.context || s;
var id = 'jqFormIO' + (new Date().getTime()), fn = '_'+id;
window[fn] = function() {
var f = $io.data('form-plugin-onload');
if (f) {
f();
window[fn] = undefined;
try { delete window[fn]; } catch(e){}
}
}
var $io = $('');
var io = $io[0];
$io.css({ position: 'absolute', top: '-1000px', left: '-1000px' });
var xhr = { // mock object
aborted: 0,
responseText: null,
responseXML: null,
status: 0,
statusText: 'n/a',
getAllResponseHeaders: function() {},
getResponseHeader: function() {},
setRequestHeader: function() {},
abort: function() {
this.aborted = 1;
$io.attr('src', s.iframeSrc); // abort op in progress
}
};
var g = s.global;
// trigger ajax global events so that activity/block indicators work like normal
if (g && ! $.active++) {
$.event.trigger("ajaxStart");
}
if (g) {
$.event.trigger("ajaxSend", [xhr, s]);
}
if (s.beforeSend && s.beforeSend.call(s.context, xhr, s) === false) {
if (s.global) {
$.active--;
}
return;
}
if (xhr.aborted) {
return;
}
var cbInvoked = false;
var timedOut = 0;
// add submitting element to data if we know it
var sub = form.clk;
if (sub) {
var n = sub.name;
if (n && !sub.disabled) {
s.extraData = s.extraData || {};
s.extraData[n] = sub.value;
if (sub.type == "image") {
s.extraData[n+'.x'] = form.clk_x;
s.extraData[n+'.y'] = form.clk_y;
}
}
}
// take a breath so that pending repaints get some cpu time before the upload starts
function doSubmit() {
// make sure form attrs are set
var t = $form.attr('target'), a = $form.attr('action');
// update form attrs in IE friendly way
form.setAttribute('target',id);
if (form.getAttribute('method') != 'POST') {
form.setAttribute('method', 'POST');
}
if (form.getAttribute('action') != s.url) {
form.setAttribute('action', s.url);
}
// ie borks in some cases when setting encoding
if (! s.skipEncodingOverride) {
$form.attr({
encoding: 'multipart/form-data',
enctype: 'multipart/form-data'
});
}
// support timout
if (s.timeout) {
setTimeout(function() { timedOut = true; cb(); }, s.timeout);
}
// add "extra" data to form if provided in options
var extraInputs = [];
try {
if (s.extraData) {
for (var n in s.extraData) {
extraInputs.push(
$('')
.appendTo(form)[0]);
}
}
// add iframe to doc and submit the form
$io.appendTo('body');
$io.data('form-plugin-onload', cb);
form.submit();
}
finally {
// reset attrs and remove "extra" input elements
form.setAttribute('action',a);
if(t) {
form.setAttribute('target', t);
} else {
$form.removeAttr('target');
}
$(extraInputs).remove();
}
}
if (s.forceSync) {
doSubmit();
}
else {
setTimeout(doSubmit, 10); // this lets dom updates render
}
var data, doc, domCheckCount = 50;
function cb() {
if (cbInvoked) {
return;
}
$io.removeData('form-plugin-onload');
var ok = true;
try {
if (timedOut) {
throw 'timeout';
}
// extract the server response from the iframe
doc = io.contentWindow ? io.contentWindow.document : io.contentDocument ? io.contentDocument : io.document;
var isXml = s.dataType == 'xml' || doc.XMLDocument || $.isXMLDoc(doc);
//log('isXml='+isXml);
if (!isXml && window.opera && (doc.body == null || doc.body.innerHTML == '')) {
if (--domCheckCount) {
// in some browsers (Opera) the iframe DOM is not always traversable when
// the onload callback fires, so we loop a bit to accommodate
//log('requeing onLoad callback, DOM not available');
setTimeout(cb, 250);
return;
}
// let this fall through because server response could be an empty document
//log('Could not access iframe DOM after mutiple tries.');
//throw 'DOMException: not available';
}
//log('response detected');
cbInvoked = true;
xhr.responseText = doc.documentElement ? doc.documentElement.innerHTML : null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument : doc;
xhr.getResponseHeader = function(header){
var headers = {'content-type': s.dataType};
return headers[header];
};
var scr = /(json|script)/.test(s.dataType);
if (scr || s.textarea) {
// see if user embedded response in textarea
var ta = doc.getElementsByTagName('textarea')[0];
if (ta) {
xhr.responseText = ta.value;
}
else if (scr) {
// account for browsers injecting pre around json response
var pre = doc.getElementsByTagName('pre')[0];
if (pre) {
xhr.responseText = pre.innerHTML;
}
}
}
else if (s.dataType == 'xml' && !xhr.responseXML && xhr.responseText != null) {
xhr.responseXML = toXml(xhr.responseText);
}
data = $.httpData(xhr, s.dataType);
}
catch(e){
//log('error caught:',e);
ok = false;
xhr.error = e;
$.handleError(s, xhr, 'error', e);
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (ok) {
s.success.call(s.context, data, 'success', xhr);
if (g) {
$.event.trigger("ajaxSuccess", [xhr, s]);
}
}
if (g) {
$.event.trigger("ajaxComplete", [xhr, s]);
}
if (g && ! --$.active) {
$.event.trigger("ajaxStop");
}
if (s.complete) {
s.complete.call(s.context, xhr, ok ? 'success' : 'error');
}
// clean up
setTimeout(function() {
$io.removeData('form-plugin-onload');
$io.remove();
xhr.responseXML = null;
}, 100);
}
function toXml(s, doc) {
if (window.ActiveXObject) {
doc = new ActiveXObject('Microsoft.XMLDOM');
doc.async = 'false';
doc.loadXML(s);
}
else {
doc = (new DOMParser()).parseFromString(s, 'text/xml');
}
return (doc && doc.documentElement && doc.documentElement.tagName != 'parsererror') ? doc : null;
}
}
};
/**
* ajaxForm() provides a mechanism for fully automating form submission.
*
* The advantages of using this method instead of ajaxSubmit() are:
*
* 1: This method will include coordinates for elements (if the element
* is used to submit the form).
* 2. This method will include the submit element's name/value data (for the element that was
* used to submit the form).
* 3. This method binds the submit() method to the form for you.
*
* The options argument for ajaxForm works exactly as it does for ajaxSubmit. ajaxForm merely
* passes the options argument along after properly binding events for submit elements and
* the form itself.
*/
$.fn.ajaxForm = function(options) {
// in jQuery 1.3+ we can fix mistakes with the ready state
if (this.length === 0) {
var o = { s: this.selector, c: this.context };
if (!$.isReady && o.s) {
//log('DOM not ready, queuing ajaxForm');
$(function() {
$(o.s,o.c).ajaxForm(options);
});
return this;
}
// is your DOM ready? http://docs.jquery.com/Tutorials:Introducing_$(document).ready()
//log('terminating; zero elements found by selector' + ($.isReady ? '' : ' (DOM not ready)'));
return this;
}
return this.ajaxFormUnbind().bind('submit.form-plugin', function(e) {
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
e.preventDefault();
$(this).ajaxSubmit(options);
}
}).bind('click.form-plugin', function(e) {
var target = e.target;
var $el = $(target);
if (!($el.is(":submit,input:image"))) {
// is this a child element of the submit el? (ex: a span within a button)
var t = $el.closest(':submit');
if (t.length == 0) {
return;
}
target = t[0];
}
var form = this;
form.clk = target;
if (target.type == 'image') {
if (e.offsetX != undefined) {
form.clk_x = e.offsetX;
form.clk_y = e.offsetY;
} else if (typeof $.fn.offset == 'function') { // try to use dimensions plugin
var offset = $el.offset();
form.clk_x = e.pageX - offset.left;
form.clk_y = e.pageY - offset.top;
} else {
form.clk_x = e.pageX - target.offsetLeft;
form.clk_y = e.pageY - target.offsetTop;
}
}
// clear form vars
setTimeout(function() { form.clk = form.clk_x = form.clk_y = null; }, 100);
});
};
// ajaxFormUnbind unbinds the event handlers that were bound by ajaxForm
$.fn.ajaxFormUnbind = function() {
return this.unbind('submit.form-plugin click.form-plugin');
};
/**
* formToArray() gathers form element data into an array of objects that can
* be passed to any of the following ajax functions: $.get, $.post, or load.
* Each object in the array has both a 'name' and 'value' property. An example of
* an array for a simple login form might be:
*
* [ { name: 'username', value: 'jresig' }, { name: 'password', value: 'secret' } ]
*
* It is this array that is passed to pre-submit callback functions provided to the
* ajaxSubmit() and ajaxForm() methods.
*/
$.fn.formToArray = function(semantic) {
var a = [];
if (this.length === 0) {
return a;
}
var form = this[0];
var els = semantic ? form.getElementsByTagName('*') : form.elements;
if (!els) {
return a;
}
var i,j,n,v,el;
for(i=0, max=els.length; i < max; i++) {
el = els[i];
n = el.name;
if (!n) {
continue;
}
if (semantic && form.clk && el.type == "image") {
// handle image inputs on the fly when semantic == true
if(!el.disabled && form.clk == el) {
a.push({name: n, value: $(el).val()});
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
continue;
}
v = $.fieldValue(el, true);
if (v && v.constructor == Array) {
for(j=0, jmax=v.length; j < jmax; j++) {
a.push({name: n, value: v[j]});
}
}
else if (v !== null && typeof v != 'undefined') {
a.push({name: n, value: v});
}
}
if (!semantic && form.clk) {
// input type=='image' are not found in elements array! handle it here
var $input = $(form.clk), input = $input[0];
n = input.name;
if (n && !input.disabled && input.type == 'image') {
a.push({name: n, value: $input.val()});
a.push({name: n+'.x', value: form.clk_x}, {name: n+'.y', value: form.clk_y});
}
}
return a;
};
/**
* Serializes form data into a 'submittable' string. This method will return a string
* in the format: name1=value1&name2=value2
*/
$.fn.formSerialize = function(semantic) {
//hand off to jQuery.param for proper encoding
return $.param(this.formToArray(semantic));
};
/**
* Serializes all field elements in the jQuery object into a query string.
* This method will return a string in the format: name1=value1&name2=value2
*/
$.fn.fieldSerialize = function(successful) {
var a = [];
this.each(function() {
var n = this.name;
if (!n) {
return;
}
var v = $.fieldValue(this, successful);
if (v && v.constructor == Array) {
for (var i=0,max=v.length; i < max; i++) {
a.push({name: n, value: v[i]});
}
}
else if (v !== null && typeof v != 'undefined') {
a.push({name: this.name, value: v});
}
});
//hand off to jQuery.param for proper encoding
return $.param(a);
};
/**
* Returns the value(s) of the element in the matched set. For example, consider the following form:
*
*
*
* var v = $(':text').fieldValue();
* // if no values are entered into the text inputs
* v == ['','']
* // if values entered into the text inputs are 'foo' and 'bar'
* v == ['foo','bar']
*
* var v = $(':checkbox').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v == ['B1', 'B2']
*
* var v = $(':radio').fieldValue();
* // if neither radio is checked
* v === undefined
* // if first radio is checked
* v == ['C1']
*
* The successful argument controls whether or not the field element must be 'successful'
* (per http://www.w3.org/TR/html4/interact/forms.html#successful-controls).
* The default value of the successful argument is true. If this value is false the value(s)
* for each element is returned.
*
* Note: This method *always* returns an array. If no valid value can be determined the
* array will be empty, otherwise it will contain one or more values.
*/
$.fn.fieldValue = function(successful) {
for (var val=[], i=0, max=this.length; i < max; i++) {
var el = this[i];
var v = $.fieldValue(el, successful);
if (v === null || typeof v == 'undefined' || (v.constructor == Array && !v.length)) {
continue;
}
v.constructor == Array ? $.merge(val, v) : val.push(v);
}
return val;
};
/**
* Returns the value of the field element.
*/
$.fieldValue = function(el, successful) {
var n = el.name, t = el.type, tag = el.tagName.toLowerCase();
if (successful === undefined) {
successful = true;
}
if (successful && (!n || el.disabled || t == 'reset' || t == 'button' ||
(t == 'checkbox' || t == 'radio') && !el.checked ||
(t == 'submit' || t == 'image') && el.form && el.form.clk != el ||
tag == 'select' && el.selectedIndex == -1)) {
return null;
}
if (tag == 'select') {
var index = el.selectedIndex;
if (index < 0) {
return null;
}
var a = [], ops = el.options;
var one = (t == 'select-one');
var max = (one ? index+1 : ops.length);
for(var i=(one ? index : 0); i < max; i++) {
var op = ops[i];
if (op.selected) {
var v = op.value;
if (!v) { // extra pain for IE...
v = (op.attributes && op.attributes['value'] && !(op.attributes['value'].specified)) ? op.text : op.value;
}
if (one) {
return v;
}
a.push(v);
}
}
return a;
}
return $(el).val();
};
/**
* Clears the form data. Takes the following actions on the form's input fields:
* - input text fields will have their 'value' property set to the empty string
* - select elements will have their 'selectedIndex' property set to -1
* - checkbox and radio inputs will have their 'checked' property set to false
* - inputs of type submit, button, reset, and hidden will *not* be effected
* - button elements will *not* be effected
*/
$.fn.clearForm = function() {
return this.each(function() {
$('input,select,textarea', this).clearFields();
});
};
/**
* Clears the selected form elements.
*/
$.fn.clearFields = $.fn.clearInputs = function() {
return this.each(function() {
var t = this.type, tag = this.tagName.toLowerCase();
if (t == 'text' || t == 'password' || tag == 'textarea') {
this.value = '';
}
else if (t == 'checkbox' || t == 'radio') {
this.checked = false;
}
else if (tag == 'select') {
this.selectedIndex = -1;
}
});
};
/**
* Resets the form data. Causes all form elements to be reset to their original value.
*/
$.fn.resetForm = function() {
return this.each(function() {
// guard against an input with the name of 'reset'
// note that IE reports the reset function as an 'object'
if (typeof this.reset == 'function' || (typeof this.reset == 'object' && !this.reset.nodeType)) {
this.reset();
}
});
};
/**
* Enables or disables any matching elements.
*/
$.fn.enable = function(b) {
if (b === undefined) {
b = true;
}
return this.each(function() {
this.disabled = !b;
});
};
$.fn.disable = function(b) {
if (b === undefined) {
b = true;
}
return this.each(function() {
this.disabled = b;
});
};
/**
* Checks/unchecks any matching checkboxes or radio buttons and
* selects/deselects and matching option elements.
*/
$.fn.selected = function(select) {
if (select === undefined) {
select = true;
}
return this.each(function() {
var t = this.type;
if (t == 'checkbox' || t == 'radio') {
this.checked = select;
}
else if (this.tagName.toLowerCase() == 'option') {
var $sel = $(this).parent('select');
if (select && $sel[0] && $sel[0].type == 'select-one') {
// deselect all other options
$sel.find('option').selected(false);
}
this.selected = select;
}
});
};
// helper fn for console logging
// set $.fn.ajaxSubmit.debug to true to enable debug logging
/*
function log() {
if ($.fn.ajaxSubmit.debug) {
var msg = '[jquery.form] ' + Array.prototype.join.call(arguments,'');
if (window.console && window.console.log) {
window.console.log(msg);
}
else if (window.opera && window.opera.postError) {
window.opera.postError(msg);
}
}
};
*/
})(jQuery);
(function ($) {
var m = {
'\b': '\\b',
'\t': '\\t',
'\n': '\\n',
'\f': '\\f',
'\r': '\\r',
'"' : '\\"',
'\\': '\\\\'
},
s = {
'array': function (x) {
var a = ['['], b, f, i, l = x.length, v;
for (i = 0; i < l; i += 1) {
v = x[i];
f = s[typeof v];
if (f) {
v = f(v);
if (typeof v == 'string') {
if (b) {
a[a.length] = ',';
}
a[a.length] = v;
b = true;
}
}
}
a[a.length] = ']';
return a.join('');
},
'boolean': function (x) {
return String(x);
},
'null': function (x) {
return "null";
},
'number': function (x) {
return isFinite(x) ? String(x) : 'null';
},
'object': function (x) {
if (x) {
if (x instanceof Array) {
return s.array(x);
}
var a = ['{'], b, f, i, v;
for (i in x) {
v = x[i];
f = s[typeof v];
if (f) {
v = f(v);
if (typeof v == 'string') {
if (b) {
a[a.length] = ',';
}
a.push(s.string(i), ':', v);
b = true;
}
}
}
a[a.length] = '}';
return a.join('');
}
return 'null';
},
'string': function (x) {
if (/["\\\x00-\x1f]/.test(x)) {
x = x.replace(/([\x00-\x1f\\"])/g, function(a, b) {
var c = m[b];
if (c) {
return c;
}
c = b.charCodeAt();
return '\\u00' +
Math.floor(c / 16).toString(16) +
(c % 16).toString(16);
});
}
return '"' + x + '"';
}
};
$.toJSON = function(v) {
var f = isNaN(v) ? s[typeof v] : s['number'];
if (f) return f(v);
};
})(jQuery);
// http://flesler.blogspot.com/2007/10/jqueryscrollto.html
;(function( $ ){
var $scrollTo = $.scrollTo = function( target, duration, settings ){
$(window).scrollTo( target, duration, settings );
};
$scrollTo.defaults = {
axis:'xy',
duration: parseFloat($.fn.jquery) >= 1.3 ? 0 : 1
};
// Returns the element that needs to be animated to scroll the window.
// Kept for backwards compatibility (specially for localScroll & serialScroll)
$scrollTo.window = function( scope ){
return $(window)._scrollable();
};
// Hack, hack, hack :)
// Returns the real elements to scroll (supports window/iframes, documents and regular nodes)
$.fn._scrollable = function(){
return this.map(function(){
var elem = this,
isWin = !elem.nodeName || $.inArray( elem.nodeName.toLowerCase(), ['iframe','#document','html','body'] ) != -1;
if( !isWin )
return elem;
var doc = (elem.contentWindow || elem).document || elem.ownerDocument || elem;
return $.browser.safari || doc.compatMode == 'BackCompat' ?
doc.body :
doc.documentElement;
});
};
$.fn.scrollTo = function( target, duration, settings ){
if( typeof duration == 'object' ){
settings = duration;
duration = 0;
}
if( typeof settings == 'function' )
settings = { onAfter:settings };
if( target == 'max' )
target = 9e9;
settings = $.extend( {}, $scrollTo.defaults, settings );
// Speed is still recognized for backwards compatibility
duration = duration || settings.speed || settings.duration;
// Make sure the settings are given right
settings.queue = settings.queue && settings.axis.length > 1;
if( settings.queue )
// Let's keep the overall duration
duration /= 2;
settings.offset = both( settings.offset );
settings.over = both( settings.over );
return this._scrollable().each(function(){
var elem = this,
$elem = $(elem),
targ = target, toff, attr = {},
win = $elem.is('html,body');
switch( typeof targ ){
// A number will pass the regex
case 'number':
case 'string':
if( /^([+-]=)?\d+(\.\d+)?(px|%)?$/.test(targ) ){
targ = both( targ );
// We are done
break;
}
// Relative selector, no break!
targ = $(targ,this);
case 'object':
// DOMElement / jQuery
if( targ.is || targ.style )
// Get the real position of the target
toff = (targ = $(targ)).offset();
}
$.each( settings.axis.split(''), function( i, axis ){
var Pos = axis == 'x' ? 'Left' : 'Top',
pos = Pos.toLowerCase(),
key = 'scroll' + Pos,
old = elem[key],
max = $scrollTo.max(elem, axis);
if( toff ){// jQuery / DOMElement
attr[key] = toff[pos] + ( win ? 0 : old - $elem.offset()[pos] );
// If it's a dom element, reduce the margin
if( settings.margin ){
attr[key] -= parseInt(targ.css('margin'+Pos)) || 0;
attr[key] -= parseInt(targ.css('border'+Pos+'Width')) || 0;
}
attr[key] += settings.offset[pos] || 0;
if( settings.over[pos] )
// Scroll to a fraction of its width/height
attr[key] += targ[axis=='x'?'width':'height']() * settings.over[pos];
}else{
var val = targ[pos];
// Handle percentage values
attr[key] = val.slice && val.slice(-1) == '%' ?
parseFloat(val) / 100 * max
: val;
}
// Number or 'number'
if( /^\d+$/.test(attr[key]) )
// Check the limits
attr[key] = attr[key] <= 0 ? 0 : Math.min( attr[key], max );
// Queueing axes
if( !i && settings.queue ){
// Don't waste time animating, if there's no need.
if( old != attr[key] )
// Intermediate animation
animate( settings.onAfterFirst );
// Don't animate this axis again in the next iteration.
delete attr[key];
}
});
animate( settings.onAfter );
function animate( callback ){
$elem.animate( attr, duration, settings.easing, callback && function(){
callback.call(this, target, settings);
});
};
}).end();
};
// Max scrolling position, works on quirks mode
// It only fails (not too badly) on IE, quirks mode.
$scrollTo.max = function( elem, axis ){
var Dim = axis == 'x' ? 'Width' : 'Height',
scroll = 'scroll'+Dim;
if( !$(elem).is('html,body') )
return elem[scroll] - $(elem)[Dim.toLowerCase()]();
var size = 'client' + Dim,
html = elem.ownerDocument.documentElement,
body = elem.ownerDocument.body;
return Math.max( html[scroll], body[scroll] )
- Math.min( html[size] , body[size] );
};
function both( val ){
return typeof val == 'object' ? val : { top:val, left:val };
};
})( jQuery );// jQuery Slider Plugin
// Egor Khmelev - http://blog.egorkhmelev.com/ - hmelyoff@gmail.com
(function(){
// Simple Inheritance
Function.prototype.inheritFrom = function(BaseClass, oOverride){
var Inheritance = function() {};
Inheritance.prototype = BaseClass.prototype;
this.prototype = new Inheritance();
this.prototype.constructor = this;
this.prototype.baseConstructor = BaseClass;
this.prototype.superClass = BaseClass.prototype;
if(oOverride){
for(var i in oOverride) {
this.prototype[i] = oOverride[i];
}
}
};
// Format numbers
Number.prototype.jSliderNice=function(iRoundBase){
var re=/^(-)?(\d+)([\.,](\d+))?$/;
var iNum=Number(this);
var sNum=String(iNum);
var aMatches;
var sDecPart='';
var sTSeparator=' ';
if((aMatches = sNum.match(re))){
var sIntPart=aMatches[2];
var iDecPart=(aMatches[4]) ? Number('0.'+aMatches[4]) : 0;
if(iDecPart){
var iRF=Math.pow(10, (iRoundBase) ? iRoundBase : 2);
iDecPart=Math.round(iDecPart*iRF);
sNewDecPart=String(iDecPart);
sDecPart = sNewDecPart;
if(sNewDecPart.length < iRoundBase){
var iDiff = iRoundBase-sNewDecPart.length;
for (var i=0; i < iDiff; i++) {
sDecPart = "0" + sDecPart;
};
}
sDecPart = "," + sDecPart;
} else {
if(iRoundBase && iRoundBase != 0){
for (var i=0; i < iRoundBase; i++) {
sDecPart += "0";
};
sDecPart = "," + sDecPart;
}
}
var sResult;
if(Number(sIntPart) < 1000){
sResult = sIntPart+sDecPart;
}else{
var sNewNum='';
var i;
for(i=1; i*3)[^\t]*)'/g, "$1\r")
.replace(/\t=(.*?)%>/g, "',$1,'")
.split("\t").join("');")
.split("%>").join("p.push('")
.split("\r").join("\\'")
+ "');}return p.join('');");
// Provide some basic currying to the user
return data ? fn( data ) : fn;
};
})();
// Draggable Class
// Egor Khmelev - http://blog.egorkhmelev.com/
(function( $ ){
this.Draggable = function(){
this._init.apply( this, arguments );
};
Draggable.prototype = {
// Methods for re-init in child class
oninit: function(){},
events: function(){},
onmousedown: function(){
this.ptr.css({ position: "absolute" });
},
onmousemove: function( evt, x, y ){
this.ptr.css({ left: x, top: y });
},
onmouseup: function(){},
isDefault: {
drag: false,
clicked: false,
toclick: true,
mouseup: false
},
_init: function(){
if( arguments.length > 0 ){
this.ptr = $(arguments[0]);
this.outer = $(".draggable-outer");
this.is = {};
$.extend( this.is, this.isDefault );
var _offset = this.ptr.offset();
this.d = {
left: _offset.left,
top: _offset.top,
width: this.ptr.width(),
height: this.ptr.height()
};
this.oninit.apply( this, arguments );
this._events();
}
},
_getPageCoords: function( event ){
if( event.targetTouches && event.targetTouches[0] ){
return { x: event.targetTouches[0].pageX, y: event.targetTouches[0].pageY };
} else
return { x: event.pageX, y: event.pageY };
},
_bindEvent: function( ptr, eventType, handler ){
var self = this;
if( this.supportTouches_ )
ptr.get(0).addEventListener( this.events_[ eventType ], handler, false );
else
ptr.bind( this.events_[ eventType ], handler );
},
_events: function(){
var self = this;
this.supportTouches_ = ( $.browser.webkit && navigator.userAgent.indexOf("Mobile") != -1 );
this.events_ = {
"click": this.supportTouches_ ? "touchstart" : "click",
"down": this.supportTouches_ ? "touchstart" : "mousedown",
"move": this.supportTouches_ ? "touchmove" : "mousemove",
"up" : this.supportTouches_ ? "touchend" : "mouseup"
};
this._bindEvent( $( document ), "move", function( event ){
if( self.is.drag ){
event.stopPropagation();
event.preventDefault();
self._mousemove( event );
}
});
this._bindEvent( $( document ), "down", function( event ){
if( self.is.drag ){
event.stopPropagation();
event.preventDefault();
}
});
this._bindEvent( $( document ), "up", function( event ){
self._mouseup( event );
});
this._bindEvent( this.ptr, "down", function( event ){
self._mousedown( event );
return false;
});
this._bindEvent( this.ptr, "up", function( event ){
self._mouseup( event );
});
this.ptr.find("a")
.click(function(){
self.is.clicked = true;
if( !self.is.toclick ){
self.is.toclick = true;
return false;
}
})
.mousedown(function( event ){
self._mousedown( event );
return false;
});
this.events();
},
_mousedown: function( evt ){
this.is.drag = true;
this.is.clicked = false;
this.is.mouseup = false;
var _offset = this.ptr.offset();
var coords = this._getPageCoords( evt );
this.cx = coords.x - _offset.left;
this.cy = coords.y - _offset.top;
$.extend(this.d, {
left: _offset.left,
top: _offset.top,
width: this.ptr.width(),
height: this.ptr.height()
});
if( this.outer && this.outer.get(0) ){
this.outer.css({ height: Math.max(this.outer.height(), $(document.body).height()), overflow: "hidden" });
}
this.onmousedown( evt );
},
_mousemove: function( evt ){
this.is.toclick = false;
var coords = this._getPageCoords( evt );
this.onmousemove( evt, coords.x - this.cx, coords.y - this.cy );
},
_mouseup: function( evt ){
var oThis = this;
if( this.is.drag ){
this.is.drag = false;
if( this.outer && this.outer.get(0) ){
if( $.browser.mozilla ){
this.outer.css({ overflow: "hidden" });
} else {
this.outer.css({ overflow: "visible" });
}
if( $.browser.msie && $.browser.version == '6.0' ){
this.outer.css({ height: "100%" });
} else {
this.outer.css({ height: "auto" });
}
}
this.onmouseup( evt );
}
}
};
})( jQuery );
// jQuery Slider (Safari)
// Egor Khmelev - http://blog.egorkhmelev.com/
(function( $ ) {
$.slider = function( node, settings ){
var jNode = $(node);
if( !jNode.data( "jslider" ) )
jNode.data( "jslider", new jSlider( node, settings ) );
return jNode.data( "jslider" );
};
$.fn.slider = function( action, opt_value ){
var returnValue, args = arguments;
function isDef( val ){
return val !== undefined;
};
function isDefAndNotNull( val ){
return val != null;
};
this.each(function(){
var self = $.slider( this, action );
// do actions
if( typeof action == "string" ){
switch( action ){
case "value":
if( isDef( args[ 1 ] ) && isDef( args[ 2 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0].set( args[ 1 ] );
pointers[0].setIndexOver();
}
if( isDefAndNotNull( pointers[1] ) && isDefAndNotNull( args[2] ) ){
pointers[1].set( args[ 2 ] );
pointers[1].setIndexOver();
}
}
else if( isDef( args[ 1 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0].set( args[ 1 ] );
pointers[0].setIndexOver();
}
}
else
returnValue = self.getValue();
break;
case "prc":
if( isDef( args[ 1 ] ) && isDef( args[ 2 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0]._set( args[ 1 ] );
pointers[0].setIndexOver();
}
if( isDefAndNotNull( pointers[1] ) && isDefAndNotNull( args[2] ) ){
pointers[1]._set( args[ 2 ] );
pointers[1].setIndexOver();
}
}
else if( isDef( args[ 1 ] ) ){
var pointers = self.getPointers();
if( isDefAndNotNull( pointers[0] ) && isDefAndNotNull( args[1] ) ){
pointers[0]._set( args[ 1 ] );
pointers[0].setIndexOver();
}
}
else
returnValue = self.getPrcValue();
break;
case "calculatedValue":
var value = self.getValue().split(";");
returnValue = "";
for (var i=0; i < value.length; i++) {
returnValue += (i > 0 ? ";" : "") + self.nice( value[i] );
};
break;
case "skin":
self.setSkin( args[1] );
break;
};
}
// return actual object
else if( !action && !opt_value ){
if( !jSliderIsArray( returnValue ) )
returnValue = [];
returnValue.push( slider );
}
});
// flatten array just with one slider
if( jSliderIsArray( returnValue ) && returnValue.length == 1 )
returnValue = returnValue[ 0 ];
return returnValue || this;
};
var OPTIONS = {
settings: {
from: 1,
to: 10,
step: 1,
smooth: true,
limits: true,
round: 0,
value: "5;7",
dimension: ""
},
className: "jslider",
selector: ".jslider-",
template: jSliderTmpl(
'' +
'' +
' ' +
'' +
'' +
' ' +
' ' +
' ' +
'<%=settings.from%> ' +
'<%=settings.to%><%=settings.dimension%> ' +
'<%=settings.dimension%> ' +
'<%=settings.dimension%> ' +
'<%=scale%> '+
' |
' +
''
)
};
this.jSlider = function(){
return this.init.apply( this, arguments );
};
jSlider.prototype = {
init: function( node, settings ){
this.settings = $.extend(true, {}, OPTIONS.settings, settings ? settings : {});
// obj.sliderHandler = this;
this.inputNode = $( node ).hide();
this.settings.interval = this.settings.to-this.settings.from;
this.settings.value = this.inputNode.attr("value");
if( this.settings.calculate && $.isFunction( this.settings.calculate ) )
this.nice = this.settings.calculate;
if( this.settings.onstatechange && $.isFunction( this.settings.onstatechange ) )
this.onstatechange = this.settings.onstatechange;
this.is = {
init: false
};
this.o = {};
this.create();
},
onstatechange: function(){},
create: function(){
var $this = this;
this.domNode = $( OPTIONS.template({
className: OPTIONS.className,
settings: {
from: this.nice( this.settings.from ),
to: this.nice( this.settings.to ),
dimension: this.settings.dimension
},
scale: this.generateScale()
}) );
this.inputNode.after( this.domNode );
this.drawScale();
// set skin class
if( this.settings.skin && this.settings.skin.length > 0 )
this.setSkin( this.settings.skin );
this.sizes = {
domWidth: this.domNode.width(),
domOffset: this.domNode.offset()
};
// find some objects
$.extend(this.o, {
pointers: {},
labels: {
0: {
o: this.domNode.find(OPTIONS.selector + "value").not(OPTIONS.selector + "value-to")
},
1: {
o: this.domNode.find(OPTIONS.selector + "value").filter(OPTIONS.selector + "value-to")
}
},
limits: {
0: this.domNode.find(OPTIONS.selector + "label").not(OPTIONS.selector + "label-to"),
1: this.domNode.find(OPTIONS.selector + "label").filter(OPTIONS.selector + "label-to")
}
});
$.extend(this.o.labels[0], {
value: this.o.labels[0].o.find("span")
});
$.extend(this.o.labels[1], {
value: this.o.labels[1].o.find("span")
});
if( !$this.settings.value.split(";")[1] ){
this.settings.single = true;
this.domNode.addDependClass("single");
}
if( !$this.settings.limits )
this.domNode.addDependClass("limitless");
this.domNode.find(OPTIONS.selector + "pointer").each(function( i ){
var value = $this.settings.value.split(";")[i];
if( value ){
$this.o.pointers[i] = new jSliderPointer( this, i, $this );
var prev = $this.settings.value.split(";")[i-1];
if( prev && new Number(value) < new Number(prev) ) value = prev;
value = value < $this.settings.from ? $this.settings.from : value;
value = value > $this.settings.to ? $this.settings.to : value;
$this.o.pointers[i].set( value, true );
}
});
this.o.value = this.domNode.find(".v");
this.is.init = true;
$.each(this.o.pointers, function(i){
$this.redraw(this);
});
(function(self){
$(window).resize(function(){
self.onresize();
});
})(this);
},
setSkin: function( skin ){
if( this.skin_ )
this.domNode.removeDependClass( this.skin_, "_" );
this.domNode.addDependClass( this.skin_ = skin, "_" );
},
setPointersIndex: function( i ){
$.each(this.getPointers(), function(i){
this.index( i );
});
},
getPointers: function(){
return this.o.pointers;
},
generateScale: function(){
if( this.settings.scale && this.settings.scale.length > 0 ){
var str = "";
var s = this.settings.scale;
var prc = Math.round((100/(s.length-1))*10)/10;
for( var i=0; i < s.length; i++ ){
str += '' + ( s[i] != '|' ? '' + s[i] + '' : '' ) + '';
};
return str;
} else return "";
return "";
},
drawScale: function(){
this.domNode.find(OPTIONS.selector + "scale span ins").each(function(){
$(this).css({ marginLeft: -$(this).outerWidth()/2 });
});
},
onresize: function(){
var self = this;
this.sizes = {
domWidth: this.domNode.width(),
domOffset: this.domNode.offset()
};
$.each(this.o.pointers, function(i){
self.redraw(this);
});
},
limits: function( x, pointer ){
// smooth
if( !this.settings.smooth ){
var step = this.settings.step*100 / ( this.settings.interval );
x = Math.round( x/step ) * step;
}
var another = this.o.pointers[1-pointer.uid];
if( another && pointer.uid && x < another.value.prc ) x = another.value.prc;
if( another && !pointer.uid && x > another.value.prc ) x = another.value.prc;
// base limit
if( x < 0 ) x = 0;
if( x > 100 ) x = 100;
return Math.round( x*10 ) / 10;
},
redraw: function( pointer ){
if( !this.is.init ) return false;
this.setValue();
// redraw range line
if( this.o.pointers[0] && this.o.pointers[1] )
this.o.value.css({ left: this.o.pointers[0].value.prc + "%", width: ( this.o.pointers[1].value.prc - this.o.pointers[0].value.prc ) + "%" });
this.o.labels[pointer.uid].value.html(
this.nice(
pointer.value.origin
)
);
// redraw position of labels
this.redrawLabels( pointer );
},
redrawLabels: function( pointer ){
function setPosition( label, sizes, prc ){
sizes.margin = -sizes.label/2;
// left limit
label_left = sizes.border + sizes.margin;
if( label_left < 0 )
sizes.margin -= label_left;
// right limit
if( sizes.border+sizes.label / 2 > self.sizes.domWidth ){
sizes.margin = 0;
sizes.right = true;
} else
sizes.right = false;
label.o.css({ left: prc + "%", marginLeft: sizes.margin, right: "auto" });
if( sizes.right ) label.o.css({ left: "auto", right: 0 });
return sizes;
}
var self = this;
var label = this.o.labels[pointer.uid];
var prc = pointer.value.prc;
var sizes = {
label: label.o.outerWidth(),
right: false,
border: ( prc * this.sizes.domWidth ) / 100
};
//console.log(this.o.pointers[1-pointer.uid])
if( !this.settings.single ){
// glue if near;
var another = this.o.pointers[1-pointer.uid];
var another_label = this.o.labels[another.uid];
switch( pointer.uid ){
case 0:
if( sizes.border+sizes.label / 2 > another_label.o.offset().left-this.sizes.domOffset.left ){
another_label.o.css({ visibility: "hidden" });
another_label.value.html( this.nice( another.value.origin ) );
label.o.css({ visibility: "visible" });
prc = ( another.value.prc - prc ) / 2 + prc;
if( another.value.prc != pointer.value.prc ){
label.value.html( this.nice(pointer.value.origin) + " – " + this.nice(another.value.origin) );
sizes.label = label.o.outerWidth();
sizes.border = ( prc * this.sizes.domWidth ) / 100;
}
} else {
another_label.o.css({ visibility: "visible" });
}
break;
case 1:
if( sizes.border - sizes.label / 2 < another_label.o.offset().left - this.sizes.domOffset.left + another_label.o.outerWidth() ){
another_label.o.css({ visibility: "hidden" });
another_label.value.html( this.nice(another.value.origin) );
label.o.css({ visibility: "visible" });
prc = ( prc - another.value.prc ) / 2 + another.value.prc;
if( another.value.prc != pointer.value.prc ){
label.value.html( this.nice(another.value.origin) + " – " + this.nice(pointer.value.origin) );
sizes.label = label.o.outerWidth();
sizes.border = ( prc * this.sizes.domWidth ) / 100;
}
} else {
another_label.o.css({ visibility: "visible" });
}
break;
}
}
sizes = setPosition( label, sizes, prc );
/* draw second label */
if( another_label ){
var sizes = {
label: another_label.o.outerWidth(),
right: false,
border: ( another.value.prc * this.sizes.domWidth ) / 100
};
sizes = setPosition( another_label, sizes, another.value.prc );
}
this.redrawLimits();
},
redrawLimits: function(){
if( this.settings.limits ){
var limits = [ true, true ];
for( key in this.o.pointers ){
if( !this.settings.single || key == 0 ){
var pointer = this.o.pointers[key];
var label = this.o.labels[pointer.uid];
var label_left = label.o.offset().left - this.sizes.domOffset.left;
var limit = this.o.limits[0];
if( label_left < limit.outerWidth() )
limits[0] = false;
var limit = this.o.limits[1];
if( label_left + label.o.outerWidth() > this.sizes.domWidth - limit.outerWidth() )
limits[1] = false;
}
};
for( var i=0; i < limits.length; i++ ){
if( limits[i] )
this.o.limits[i].fadeIn("fast");
else
this.o.limits[i].fadeOut("fast");
};
}
},
setValue: function(){
var value = this.getValue();
this.inputNode.attr( "value", value );
this.onstatechange.call( this, value );
},
getValue: function(){
if(!this.is.init) return false;
var $this = this;
var value = "";
$.each( this.o.pointers, function(i){
if( this.value.prc != undefined && !isNaN(this.value.prc) ) value += (i > 0 ? ";" : "") + $this.prcToValue( this.value.prc );
});
return value;
},
getPrcValue: function(){
if(!this.is.init) return false;
var $this = this;
var value = "";
$.each( this.o.pointers, function(i){
if( this.value.prc != undefined && !isNaN(this.value.prc) ) value += (i > 0 ? ";" : "") + this.value.prc;
});
return value;
},
prcToValue: function( prc ){
if( this.settings.heterogeneity && this.settings.heterogeneity.length > 0 ){
var h = this.settings.heterogeneity;
var _start = 0;
var _from = this.settings.from;
for( var i=0; i <= h.length; i++ ){
if( h[i] ) var v = h[i].split("/");
else var v = [100, this.settings.to];
v[0] = new Number(v[0]);
v[1] = new Number(v[1]);
if( prc >= _start && prc <= v[0] ) {
var value = _from + ( (prc-_start) * (v[1]-_from) ) / (v[0]-_start);
}
_start = v[0];
_from = v[1];
};
} else {
var value = this.settings.from + ( prc * this.settings.interval ) / 100;
}
return this.round( value );
},
valueToPrc: function( value, pointer ){
if( this.settings.heterogeneity && this.settings.heterogeneity.length > 0 ){
var h = this.settings.heterogeneity;
var _start = 0;
var _from = this.settings.from;
for (var i=0; i <= h.length; i++) {
if(h[i]) var v = h[i].split("/");
else var v = [100, this.settings.to];
v[0] = new Number(v[0]); v[1] = new Number(v[1]);
if(value >= _from && value <= v[1]){
var prc = pointer.limits(_start + (value-_from)*(v[0]-_start)/(v[1]-_from));
}
_start = v[0]; _from = v[1];
};
} else {
var prc = pointer.limits((value-this.settings.from)*100/this.settings.interval);
}
return prc;
},
round: function( value ){
value = Math.round( value / this.settings.step ) * this.settings.step;
if( this.settings.round ) value = Math.round( value * Math.pow(10, this.settings.round) ) / Math.pow(10, this.settings.round);
else value = Math.round( value );
return value;
},
nice: function( value ){
value = value.toString().replace(/,/gi, ".");
value = value.toString().replace(/ /gi, "");
if( Number.prototype.jSliderNice )
return (new Number(value)).jSliderNice(this.settings.round).replace(/-/gi, "−");
else
return new Number(value);
}
};
function jSliderPointer(){
this.baseConstructor.apply(this, arguments);
}
jSliderPointer.inheritFrom(Draggable, {
oninit: function( ptr, id, _constructor ){
this.uid = id;
this.parent = _constructor;
this.value = {};
this.settings = this.parent.settings;
},
onmousedown: function(evt){
this._parent = {
offset: this.parent.domNode.offset(),
width: this.parent.domNode.width()
};
this.ptr.addDependClass("hover");
this.setIndexOver();
},
onmousemove: function( evt, x ){
var coords = this._getPageCoords( evt );
this._set( this.calc( coords.x ) );
},
onmouseup: function( evt ){
// var coords = this._getPageCoords( evt );
// this._set( this.calc( coords.x ) );
if( this.parent.settings.callback && $.isFunction(this.parent.settings.callback) )
this.parent.settings.callback.call( this.parent, this.parent.getValue() );
this.ptr.removeDependClass("hover");
},
setIndexOver: function(){
this.parent.setPointersIndex( 1 );
this.index( 2 );
},
index: function( i ){
this.ptr.css({ zIndex: i });
},
limits: function( x ){
return this.parent.limits( x, this );
},
calc: function(coords){
var x = this.limits(((coords-this._parent.offset.left)*100)/this._parent.width);
return x;
},
set: function( value, opt_origin ){
this.value.origin = this.parent.round(value);
this._set( this.parent.valueToPrc( value, this ), opt_origin );
},
_set: function( prc, opt_origin ){
if( !opt_origin )
this.value.origin = this.parent.prcToValue(prc);
this.value.prc = prc;
this.ptr.css({ left: prc + "%" });
this.parent.redraw(this);
}
});
})(jQuery);
$(function(){
$("input[type='slider']").each(function(i, e) {
e = $(e);
e.slider({ heterogeneity:[e.data('heterogeneity')], from: e.data('from'), to: e.data('to'), step: e.data('step'), smooth:true, round: 0, skin: "plastic", dimension: e.data('dimension'), onstatechange:function(){
$(e).trigger('change');
}
});
});
});
/* end */$.nvl = function(a,b) {
return (typeof(a) == 'undefined' || a == null)?b:a;
}
$.isset = function (a) {
return typeof(a) != 'undefined';
}
String.prototype.trim = function () {
return this.replace(/^\s*/, "").replace(/\s*$/, "");
}
function dumpObject(obj, v)
{
v = $.nvl(v, false);
s = obj.toString()+': ';
for (a in obj) s += (v?(a+":"+eval("obj."+a)):a)+', ';
alert(s);
}
function decode(s) {
symBase = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
result = "";
for( cur = 0; cur < s.length; cur += 4 ) {
var c = new Array(4), nextChar;
for( curC = 0; curC < 4; curC++) {
curChar = s.substring(curC + cur, curC + cur + 1);
if( '=' == curChar)
c[curC] = 0;
else
c[curC] = symBase.indexOf(curChar);
}
result += String.fromCharCode(((c[0] << 2) % 256) | (c[1] >> 4));
result += String.fromCharCode(((c[1] << 4) % 256) | (c[2] >> 2));
result += String.fromCharCode(((c[2] << 6) % 256) | c[3]); }
return result;
}
$.lazyScripts = new Array();
$.getScript = function(url, callback, cache){
if ($.browser.msie)
{
jQuery.get( url, undefined, callback, "script" );
}
else
{
$.ajax({
type: "GET",
url: url,
success: callback,
dataType: "script",
cache: cache
});
}
};
$.lazy = function(script, style, delegate) {
if ($.isFunction(style))
{
delegate = style;
}
else
{
if (script.substring(0, 7) != 'http://')
{
var m = /\.[a-z]+\.[a-z]{2}\/([a-z]+)/.exec($("link[rel='stylesheet'][href*='.mobime.ru']")[0].href);
style = 'http://static.mobime.ru/'+m[1]+'/'+style;
}
}
if (script.substring(0, 7) != 'http://')
{
var m = /\.[a-z]+\.[a-z]{2}\/([a-z]+)\/([a-zA-Z0-9\.]+)\?([0-9a-z]+)/.exec($("script[src*='.mobime.ru']")[0].src);
script = 'http://static.mobime.ru/'+m[1]+'/'+script+'?'+m[3];
}
function _a() {
if ($.inArray(script, $.lazyScripts) != -1) {
if ($.isFunction(delegate)) delegate();
} else {
$.getScript(script, function() {
$.lazyScripts.push(script);
if ($.isFunction(delegate)) delegate();
}, true);
}
}
if (!$.isFunction(style))
{
var headID = $("head")[0];
var cssNode = document.createElement('link');
cssNode.type = 'text/css';
cssNode.rel = 'stylesheet';
cssNode.href = style;
cssNode.media = 'screen';
headID.appendChild(cssNode);
//TODO: sync onready
_a();
//$("").attr('href', style);
//.ready(function () {
// _a();
//});
//.appendTo($(document.body));
}
else
{
_a();
}
}
Grip = function()
{
this.staticOffset = 0;
this.textarea = '';
}
Grip.prototype = {
startDrag : function(t, e)
{
$(document).bind("mousemove", grip.performDrag);
$(document).bind("mouseup", grip.endDrag);
this.textarea = $("#"+t);
this.staticOffset = this.textarea[0].offsetHeight - e.pageY;
return false;
},
performDrag : function(e)
{
grip.textarea.css({height: Math.max(48, grip.staticOffset + e.pageY) + 'px'});
return false;
},
endDrag : function(e)
{
$(document).unbind("mousemove", grip.performDrag);
$(document).unbind("mouseup", grip.endDrag);
}
}
var model_form = '';
var reload_url = '';
var signin_nick_changed = false;
function signin_inputMail(o)
{
if (signin_nick_changed) return;
v = o.value;
if ((i = v.indexOf('@')) != -1) v = v.substr(0, i);
$('#idSigninNick').val(v);
}
function signin_checkCombo()
{
var checked = $('#idTerms')[0].checked && $('#idPrivacy')[0].checked;
$('#signinSubmit').enable(checked);
}
function PNG(element) {
if (/MSIE (5\.5|6).+Win/.test(navigator.userAgent)) {
var src;
if (element.tagName=='IMG') {
if (/\.png$/.test(element.src))
{
src = element.src;
element.src = "http://static.onreg.ru/i/e.gif";
}
} else {
src = element.currentStyle.backgroundImage.match(/url\("(.+\.png)"\)/i)
if (src) {
src = src[1];
element.runtimeStyle.backgroundImage="none";
}
}
if (src) element.runtimeStyle.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "')";
}
}
function register(e)
{
if (!e) e = window.event;
if (e.ctrlKey)
{
switch(e.keyCode)
{
case 37:
id = $('#id_prev');
if (id.length) location.href = id[0].href;
break;
case 39:
id = $('#id_next');
if (id.length) location.href = id[0].href;
break;
}
}
}
function showTips(o, text)
{
o = $(o);
var e = $('').appendTo(document.body);
var t = $('').html(text).appendTo(e);
var b = $('').appendTo(e);
var r = o.offset();
e.css({'left' : r.left - e.outerWidth() / 2 + o.outerWidth() / 2, 'top': r.top - e.outerHeight()});
var top = parseFloat(e.css('top'));
e.css({'top':top-10, 'opacity' : 0.1}).show().animate({'opacity':1, 'top':top}, 'fast');
function hideTips(event)
{
o.unbind('mouseout', hideTips);
e.animate({'opacity':0, 'top':parseFloat(e.css('top'))-10}, 'fast', function() {
e.remove();
});
}
o.bind('mouseout', hideTips);
}
function requestOrdersStatus()
{
$.ajax({
url:'/orders/status/listen',
success: function(t) {
$.ajax({
url:'/orders/status.html',
success: function(t,s,xhr) {
$('#idOrdersStatus').html(t);
// Если есть еще задания
if (xhr.getResponseHeader('X-Orders-Status-Executing') != 0)
{
requestOrdersStatus();
}
}
});
}
});
}
function editDomainDescription(id)
{
var o = $('#domainDescriptionForm');
o.html('').modal().load('/user/domaindescriptionform.html?id='+id);
}
function domainTableProperty(folder)
{
var id = $('#domainTablePropertyForm');
id.html('').modal().load('/user/domaintableproperty.html?folder='+folder);
}
function domainAddDomain()
{
var id = $('#domainAddDomainForm');
id.html('').modal().load('/user/adddomains.html');
}
function setFolder(id)
{
var folder_id = $('#idFolderSelect').val();
$.ajax({
url:'/user/changefolder.html',
data: {action:'save', domain_id:id, folder_id:folder_id},
success: function(t) {
if (t == 'ok')
{
go((folder_id == 0)?"/user/domains.html":("/user/domains.html?folder="+folder_id));
}
else
{
alert(t);
}
}
});
}
/*
function closeChangeFolder()
{
hideShadow(closeChangeFolder);
document.body.removeChild(changeFormElement);
changeFormElement = null;
}
var changeFormElement = null;
function showChangeFolder(id, e)
{
var res = Event.element(e).cumulativeOffset();
res['left'] += 5;
res['top'] += 5;
changeFormElement = new Element('div', {'id': 'idFolder'+i, 'class': 'floatpanel', 'style':'left:'+res['left']+'px;top:'+res['top']+'px'}).update("Загрузка");
showShadow(closeChangeFolder);
document.body.appendChild(changeFormElement);
new Ajax.Request('/user/changefolder.html', {
method:'get',
parameters: {domain_id:id},
onSuccess: function(t) {
changeFormElement.update(t.responseText);
}
});
}
*/
function showShadow(closeFunc, isGray, onFinish)
{
if (typeof(isGray) == 'undefined') isGray = true;
var e = document.documentElement;
var b = document.body;
var h = (b.scrollHeight>b.clientHeight)?b.scrollHeight:b.clientHeight;
var w = (b.scrollWidth>b.clientWidth)?b.scrollWidth:b.clientWidth;
var id = $('#idShadow');
if (!id.length) id = $('').appendTo(document.body);
id.attr('class', isGray?'shadow':'shadowTransparent');
id.css({'opacity':0, display:'block', height:h+'px', width:w+'px'});
id.animate({opacity: 0.5}, 'fast', onFinish);
if (closeFunc) id.bind('mousedown', closeFunc);
return id;
}
function hideShadow(closeFunc)
{
o = $('#idShadow');
o.animate({opacity: 0}, 'fast', function() { o.hide(); });
o.unbind('mousedown', closeFunc);
}
grip = new Grip();
function go(d)
{
if (typeof(d) == 'undefined') d = document.location.href;
i = d.indexOf("#");
if (i != -1) d = d.substr(0, i);
document.location = d;
}
//DEPRICATED:
function documentReload()
{
go(document.location.href);
}
/*
function checkZones(e)
{
alert(e);
var m = e.target;
alert(m);
var checkboxes = Form.getInputs('idFormZones', 'checkbox');
checkboxes.each(function(e)
{
if (e != m) e.checked = m.checked;
});
}
*/
function pickZone()
{
s = new Array();
n = $("#hoverZones input[type='checkbox']");
for (i=0;i
').load('/signin/form.html');
/*
$.ajax({
url:'/signin/form.html',
success: function(t) {
id.updateModalDialog(t);
}
});*/
}
return false;
}
function showLogin(url)
{
if (typeof(url) != "undefined") reload_url = url;
$('#idLoginForm').modal();
return false;
}
function deleteInvoce(id)
{
if (confirm('Вы уверены что хотите удалить этот счёт?'))
{
$.ajax({
url:'/user/deleteInvoice.html',
type:'get',
data: {id:id},
success: function(t) {
$('#idPaysList').html(t);
}
});
}
}
function checkNumber(id, s)
{
var m = $('#'.id).val().match(/^[0-9]+$/);
if (!m) alert(s);
return m?true:false;
}
//imgLI = new Image();
//imgLI.src = 'http://counter.yadro.ru/hit?r'+escape(document.referrer)+((typeof(screen)=='undefined')?'':';s'+screen.width+'*'+screen.height+'*'+(screen.colorDepth?screen.colorDepth:screen.pixelDepth))+';u'+escape(document.URL)+';'+Math.random();
function showDownMenu(e)
{
var n = $('#admindownmenu');
var r = n.offset();
var m = $('#downitems');
n[0].className = 'downmenu_on';
m.css({left:r.left, top:r.top - 1 + n.outerHeight()}).slideDown('fast');
$(document).bind('mousedown', hideDownMenu);
}
function hideDownMenu(e)
{
o = $('#downitems')[0];
if ((e.target == o) || (e.target.parentNode.parentNode.parentNode == o))
{
return;
}
$('#admindownmenu')[0].className = 'downmenu';
$('#downitems').hide();
$(document).unbind('mousedown', hideDownMenu);
}
/*
function blockHideShow(id)
{
o = $(id);
var d = 0.2;
var i = (o.style.display == 'none');
if (i)
{
if (typeof(Effect) != 'undefined')
{
Effect.BlindDown(id, { duration: d });
Effect.Appear(id, { duration: d, from: 0, to: 1 });
}
else
{
o.show();
}
}
else
{
if (typeof(Effect) != 'undefined')
{
Effect.BlindUp(id, { duration: d });
Effect.Appear(id, { duration: d, from: 1, to: 0 });
}
else
{
o.hide()
}
}
}
*/
function showZones(t)
{
o = $('#hoverZones');
a = $('#hoverZonesArrow');
if (o.length == 0)
{
var l = $(t.parentNode.parentNode);
l.showLoader('left');
$.ajax({
url:'/zonesform.html',
type:'post',
data: {z:$('#zchv').val()},
success: function(s) {
o = $('').appendTo(document.body).html(s);
a = $('').appendTo(document.body);
l.hideLoader();
showZones(t);
},
error: function() { alert("Ошибка получения данных");hideLoader(l); }
});
}
else
{
b = document.body;
w = (b.scrollWidth>b.clientWidth)?b.scrollWidth:b.clientWidth;
showShadow(hideZones, false);
t = $(t);
of = t.offset();
o.show().css({left : w - o.outerWidth() - 6, top: of.top + t.outerHeight() + 12});
a.show().css({left : of.left + t.outerWidth() / 2, top : of.top + t.outerHeight() + 2});
}
}
function hideZones()
{
$('#hoverZones').hide();
$('#hoverZonesArrow').hide();
hideShadow(hideZones);
}
function response(id, user_id)
{
$('#r'+id).html('');
}
function removeComments(id)
{
if (!confirm('Вы уверены что хотите удалить этот комментарий?')) return;
$.ajax({
url:'/comments/delete.html',
type:'get',
data:{id:id},
success: function(t){
if (t == 'ok') {$('#c'+id).html("Этот комментарий был удалён");} else {alert('Не могу удалить')}
}
});
}
function ndg_check(g)
{
var m = $('#gch'+g)[0];
$('#ndg'+g).find('input[type="checkbox"]').each(function(i, e) { e.checked = m.checked; });
}
function ndg_check_all(g)
{
var m = $('#gch_all')[0];
$('#form').find('input[type="checkbox"]').each(function(i, e) { e.checked = m.checked; });
}
function checkDom()
{
var r = false;
$('#form').find("input[type='checkbox']").each(function(i, e)
{
if (e.name == 'd[]') r = r || e.checked;
});
var id = $('#actionDomainsSelect');
var idf = $('#actionDomainFolders');
var ids = $('#actionDomainSubmit');
if (r) { id.enable(true);idf.enable(true);checkDomSelect(id) } else { id.enable(false);idf.enable(false);ids.enable(false); }
}
function checkDomSelect(e)
{
e = $(e);
var id = $('#actionDomainSubmit');
var idf = $('#actionDomainFolders');
if (e.val() == '') { id.enable(false); } else { id.enable(true); }
if (e.val() == 'folder_move') { idf.show(); } else { idf.hide(); }
}
function tableCheckDom()
{
var m = $('#checkHeader')[0];
$('#form').find("input[type='checkbox']").each(function(i, e)
{
if (e.name == 'd[]') e.checked = m.checked;
});
checkDom()
}
jQuery.fn.observe_field = function(frequency, callback) {
return this.each(function(){
var element = $(this);
var prev = element.val();
var chk = function() {
var val = element.val();
if(prev != val){
prev = val;
element.map(callback); // invokes the callback on the element
}
};
chk();
frequency = frequency * 1000; // translate to milliseconds
var ti = setInterval(chk, frequency);
// reset counter after user interaction
element.bind('keyup', function() {
ti && clearInterval(ti);
ti = setInterval(chk, frequency);
});
});
};
function observeSearch(idI, idC, query, where, frequency)
{
if (frequency == undefined) frequency = 1;
var idI = $('#'+idI);
var idC = $('#'+idC);
idI.observe_field(frequency, function(){
if (idI.attr("placeholder") == this.value) return;
idI.showLoader(where);
$.ajax({
url:query+this.value,
type:'get',
success: function(t) { idC.html(t);idI.hideLoader(); },
error: function() { idI.hideLoader();alert('ошибка поиска'); }
});
});
}
$.fn.showLoader = function (where)
{
if (typeof(where) == 'undefined') where = 'right';
var loader = $('
').appendTo(document.body);
o = this.offset();
h = (loader.height() < 24)?(-(24 - loader.height())/2):((loader.height() - 24)/2);
l = (where == 'right')?(o.left + this.width() + 2):(o.left - 36);
loader.css({left:l,top:o.top + h});
this.data('_loader', loader[0]);
return $(this);
}
$.fn.hideLoader = function()
{
document.body.removeChild(this.data('_loader'));
return $(this);
}
function checkDomainSubmit()
{
var o = $('#checkdomaininput');
if (o.val() == '' || o.val() == o.attr('placeholder'))
{
alert('Введите имя домена');
return false;
}
$('#checkdomaininput').parent().showLoader('left');
return true;
}
function urlencode(str)
{
str = (str+'').toString();
return encodeURIComponent(str).replace(/!/g, '%21').replace(/'/g, '%27').replace(/\(/g, '%28').replace(/\)/g, '%29').replace(/\*/g, '%2A').replace(/%20/g, '+');
}
function login()
{
var s = '';
var f = $('#idLoginForm');
var i = f.find('input,select,textarea');
var b = $('#loginSubmit');
f.ajaxSubmit({
beforeSend: function() {
i.enable(false);
//b.showLoader('right');
},
success: function(t) {
if (t.substr(0, 2) == 'ok')
{
var list = t.split(':');
var back = (reload_url != '')?reload_url:((document.location.href.search('activation.html') != -1) || (document.location.href.search('newpass.html') != -1)?'/':document.location.href);
go('/login/?id='+list[1]+'&session='+list[2]+'&back='+urlencode(back)+'&remember='+list[3]);
}
else
{
i.enable(true);
//b.hideLoader();
alert(t);
$('#idLogin').val('');
$('#idPassword').val('');
}
},
error: function() {
i.enable(true);
//b.hideLoader();
alert('Сервер временно недоступен, попробуйте зайти позже');
}
});
return false;
}
function signin(e)
{
if (!$('#idTerms')[0].checked)
{
alert("Вы должны принять договор оферту");
return false;
}
var f = $('#idSigninForm').find('form');
var i = f.find('input,select,textarea');
var b = $('#signinSubmit');
f.ajaxSubmit({
beforeSend: function() {
i.enable(false);
b.showLoader('left');
},
success: function(t){
if (t.substr(0, 2) == 'ok')
{
var list = t.split(':');
back = (reload_url != '')?reload_url:document.location.href;
go('/login/?id='+list[1]+'&session='+list[2]+'&back='+urlencode(back)+'&remember='+list[3]);
}
else
{
i.enable(true);
b.hideLoader();
alert(t);
}
},
error: function() {
i.enable(true);
b.hideLoader();
alert('Сервер временно недоступен, попробуйте зайти позже');
}
});
return false;
}
function inputPlaceholder (input, color)
{
if (!input) return null;
//Do nothing if placeholder supported by the browser (Webkit, Firefox 3.7)
if (input.placeholder && 'placeholder' in document.createElement(input.tagName)) return input;
var color = '#AAA';
var default_color = input.style.color;
var placeholder = input.getAttribute('placeholder');
if (input.value === '' || input.value == placeholder) {
input.value = placeholder;
input.style.color = color;
}
var add_event = /*@cc_on'attachEvent'||@*/'addEventListener';
input[add_event](/*@cc_on'on'+@*/'focus', function(){
input.style.color = default_color;
if (input.value == placeholder) {
input.value = '';
}
}, false);
input[add_event](/*@cc_on'on'+@*/'blur', function(){
if (input.value === '') {
input.value = placeholder;
input.style.color = color;
} else {
input.style.color = default_color;
}
}, false);
input.form && input.form[add_event](/*@cc_on'on'+@*/'submit', function(){
if (input.value == placeholder) {
input.value = '';
}
}, false);
return input;
}
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-6664171-1']);
_gaq.push(['_trackPageview']);
/*
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
*/
jQuery.cookie = function(name, value, options) {
if (typeof value != 'undefined') { // name and value given, set cookie
options = options || {};
if (value === null) {
value = '';
options = $.extend({}, options); // clone object since it's unexpected behavior if the expired property were changed
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
}
// NOTE 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;
}
};
function share(name, title) {
if (!$.isset(name))
{
var o = $('#social');
if (o.length == 0) return;
$("
").appendTo(o);
}
var i = 0;
var text = $("meta[name='description']").attr('content');
var url = document.location.href;
var title = $.isset(title)?title:document.title;
var j1 = url.indexOf('?');
var j2 = url.indexOf('#');
if (j1 != -1 || j2 != -1) url = url.substring(0, (j1 != -1 && j1 < j2 || j1 != -1 && j2 == -1)?j1:j2);
$.each({'Twitter':"twitter.com/share?url={url}&text={title}|1|600|200",
'Facebook':"www.facebook.com/sharer.php?u={url}&t={title}|1",
'VKontakte':"vkontakte.ru/share.php?url={url}|1",
'Buzz':"www.google.com/buzz/post?url={url}&type=small-count|1|700",
'Plurk':"www.plurk.com/?status="+urlencode(title+" "+document.location.href)+"&qualifier=shares|0",
'MailRu':"connect.mail.ru/share?share_url={url}|1",
'LiveInternet':"www.liveinternet.ru/links.php?url={url}&title={title}|0",
'LiveJournal':"www.livejournal.com/update.bml?event="+urlencode("
"+text+"
Подробности...")+"&subject={title}|0",
'Yandex':"wow.ya.ru/posts_add_link.xml?URL={url}&title={title}|0"}, function(k,v) {
v = v.split('|');
v[0] = "http://"+v[0].replace("{url}", urlencode(url)).replace("{title}", urlencode(title));
if (name == k) {
popup(v[0], "share_"+k, $.nvl(v[2], 600), $.nvl(v[3], 400));
return;
} else {
var a = $('
').appendTo(o).children().data('i', i).css('backgroundPosition', '-'+(i*24)+'px -24px').hover(function() {$(this).css('backgroundPosition', '-'+($(this).data('i')*24)+'px 0px') }, function() {$(this).css('backgroundPosition', '-'+($(this).data('i')*24)+'px -24px') });
a.attr('href', v[0]);
a.click(function(){
if (v[1] == 1) {
_gaq.push(['_trackEvent', 'share', k]);
popup(v[0], "share_"+k, $.nvl(v[2], 600), $.nvl(v[3], 400));
return false;
}
});
i++;
}
});
if (!$.isset(name))
{
$.lazy('http://apis.google.com/js/plusone.js', function(){
gapi.plusone.go();
});
}
}
function changeaccount_showform() {
var id = $('#idChangeAccountDomains');
if (!id.length)
{
id = $('
').appendTo(document.body);
}
$.ajax({
url:'/user/change_account_incoming.html',
success:function(t) {
id.html(t);
id.modal();
}
});
}
function changeaccount_closeform() {
var id = $('#idChangeAccountDomains');
if (confirm('Вы отказываетесь от этих доменов?'))
{
id.modal('hide');
$.ajax({url:'/user/change_account_incoming.html?action=refuse'});
}
}
function changeaccount_saveform() {
var id = $('#idChangeAccountDomains');
var domains = [];
id.find('input[type="checkbox"]').each(function(){
if (!this.checked) domains.push($(this).parent().find('em').text());
});
var url = '/user/change_account_incoming.html?action=approve';
var _success = function() {
id.modal('hide');
go('/user/domains.html');
}
var _send = function() {
id.find('form').ajaxSubmit({url:url, beforeSend:function() { id.find('input').disable(); }, success:_success});
}
if (domains.length)
{
if (confirm('Вы действительно хотите отказаться от доменов: '+domains.join(',')+'?'))
{
_send();
}
}
else
{
_send();
}
}
$(function(){
h = document.location.href;
if ((i = h.indexOf("#")) == -1) return;
re = /^p[0-9]+t[0-9]+s?([0-9]+)?$/;
s = h.substr(i+1);
if (s.match(re))
{
var p = $('#idPrices');//.html('
');
$.ajax({
url:'/setinvite.html',
type:'get',
data: {invite:s},
dataType:'json',
success: function(t) {
var j = t;
var ids = $('[id]');
ids.each(function(i,id)
{
var r = /(pr?)_([a-z]{2,})/;
var match = r.exec(id.id);
if (match != null)
{
$(id).html(j[match[2]][match[1]]);
}
});
}
});
}
});
$(function(){
$.getScript("https://mc.yandex.ru/metrika/watch.js", function() {
try { var yaCounter102806 = new Ya.Metrika({id:102806,
webvisor:true,
clickmap:true});
} catch(e) { }
}, true);
function tabbleGalleryHover() {
p = $(this).parent().parent();
p.find('.popover').hide();
p.find('.popover[data-index="'+$(this).data('index')+'"]').show();
}
var tabbleGalleryRotate = true;
$('.tabble-gallery').parent().hover(function() {
tabbleGalleryRotate = false;
}, function() {
tabbleGalleryRotate = true;
});
$('.tabble-gallery .popover-menu div').hover(tabbleGalleryHover);
setInterval(function() {
if (!tabbleGalleryRotate) return;
var list = $('.tabble-gallery .popover');
var idx = 0;
for (i in list) {
if ($(list[i]).is(":visible")) {
idx = i;
break;
}
}
idx++;
if (idx == list.length) idx = 0;
$.proxy(tabbleGalleryHover, $('.tabble-gallery .popover-menu div')[idx])();
}, 3000);
h = document.location.href;
// #login
if ((i = h.indexOf("#")) != -1)
{
s = h.substr(i+1).split('&');
if (s[0] == 'login')
{
b = decodeURIComponent(s[1]).split('=');
showLogin(b[1]);
}
}
$('input[placeholder]').each(function(i, e) {inputPlaceholder(e);});
$('.autohidden').each(function() {
$($(this).parents('tr')[0]).mouseover(function() { $(this).find('.autohidden').css('visibility', 'visible'); }).mouseout(function() { $(this).find('.autohidden').css('visibility', 'hidden'); });
});
var _html = $.fn.html;
var _check = function() {
/*
$('select').each(function(){
var o = $(this);
if (o.data('skin') == 'none') return;
if (o.parent()[0].className == 'select') return;
var s = $("
").insertAfter(o); //
var w = o.width();
if (w == 0 && o.attr('width')) w = parseInt(o.attr('width'));
if (w == 0) w = 100;
var sp = s.width(w).find('span').text(this.options[this.selectedIndex].innerHTML).width(w-26);
o.width(w).css('left', '-'+w+'px').appendTo(s);
o.change(function(){
sp.text(this.options[this.selectedIndex].innerHTML);
});
});
*/
$('[data-encode="yes"]').each(function(){
if ($(this).data('encode') == 'no') return;
this.innerHTML = decodeURIComponent( escape( decode(this.innerHTML) ));
$(this).data('encode', 'no');
});
// Disable certain links in docs
$('a[href^=#]').click(function (e) {
e.preventDefault();
});
}
$.fn.html = function(s) {
var r = _html.apply(this, (typeof(s) == 'undefined')?[]:[s]);
if ($.isset(s)) $(function() { _check(); });
return r;
}
_check();
share();
});
/*
var deviceAgent = navigator.userAgent.toLowerCase();
if (!deviceAgent.match(/(iphone|ipod|ipad)/)) {
var kribleCode = 'cab7f27b2ddb49c654cee2b9aeb4f3b1';
document.write('');
}
*/!function ($) {
"use strict"; // jshint ;_;
/* AFFIX CLASS DEFINITION
* ====================== */
var Affix = function (element, options) {
this.options = $.extend({}, $.fn.affix.defaults, options)
this.$window = $(window)
.on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
.on('click.affix.data-api', $.proxy(function () { setTimeout($.proxy(this.checkPosition, this), 1) }, this))
this.$element = $(element)
this.checkPosition()
}
Affix.prototype.checkPosition = function () {
if (!this.$element.is(':visible')) return
var scrollHeight = $(document).height()
, scrollTop = this.$window.scrollTop()
, position = this.$element.offset()
, offset = this.options.offset
, offsetBottom = offset.bottom
, offsetTop = offset.top
, reset = 'affix affix-top affix-bottom'
, affix
if (typeof offset != 'object') offsetBottom = offsetTop = offset
if (typeof offsetTop == 'function') offsetTop = offset.top()
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
'bottom' : offsetTop != null && scrollTop <= offsetTop ?
'top' : false
if (this.affixed === affix) return
this.affixed = affix
this.unpin = affix == 'bottom' ? position.top - scrollTop : null
this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
}
/* AFFIX PLUGIN DEFINITION
* ======================= */
var old = $.fn.affix
$.fn.affix = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('affix')
, options = typeof option == 'object' && option
if (!data) $this.data('affix', (data = new Affix(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.affix.Constructor = Affix
$.fn.affix.defaults = {
offset: 0
}
/* AFFIX NO CONFLICT
* ================= */
$.fn.affix.noConflict = function () {
$.fn.affix = old
return this
}
/* AFFIX DATA-API
* ============== */
$(window).on('load', function () {
$('[data-spy="affix"]').each(function () {
var $spy = $(this)
, data = $spy.data()
data.offset = data.offset || {}
data.offsetBottom && (data.offset.bottom = data.offsetBottom)
data.offsetTop && (data.offset.top = data.offsetTop)
$spy.affix(data)
})
})
}(window.jQuery);!function ($) {
"use strict"; // jshint ;_;
/* COLLAPSE PUBLIC CLASS DEFINITION
* ================================ */
var Collapse = function (element, options) {
this.$element = $(element)
this.options = $.extend({}, $.fn.collapse.defaults, options)
if (this.options.parent) {
this.$parent = $(this.options.parent)
}
this.options.toggle && this.toggle()
}
Collapse.prototype = {
constructor: Collapse
, dimension: function () {
var hasWidth = this.$element.hasClass('width')
return hasWidth ? 'width' : 'height'
}
, show: function () {
var dimension
, scroll
, actives
, hasData
if (this.transitioning || this.$element.hasClass('in')) return
dimension = this.dimension()
scroll = $.camelCase(['scroll', dimension].join('-'))
actives = this.$parent && this.$parent.find('> .accordion-group > .in')
if (actives && actives.length) {
hasData = actives.data('collapse')
if (hasData && hasData.transitioning) return
actives.collapse('hide')
hasData || actives.data('collapse', null)
}
this.$element[dimension](0)
this.transition('addClass', $.Event('show'), 'shown')
$.support.transition && this.$element[dimension](this.$element[0][scroll])
}
, hide: function () {
var dimension
if (this.transitioning || !this.$element.hasClass('in')) return
dimension = this.dimension()
this.reset(this.$element[dimension]())
this.transition('removeClass', $.Event('hide'), 'hidden')
this.$element[dimension](0)
}
, reset: function (size) {
var dimension = this.dimension()
this.$element
.removeClass('collapse')
[dimension](size || 'auto')
[0].offsetWidth
this.$element[size !== null ? 'addClass' : 'removeClass']('collapse')
return this
}
, transition: function (method, startEvent, completeEvent) {
var that = this
, complete = function () {
if (startEvent.type == 'show') that.reset()
that.transitioning = 0
that.$element.trigger(completeEvent)
}
this.$element.trigger(startEvent)
if (startEvent.isDefaultPrevented()) return
this.transitioning = 1
this.$element[method]('in')
$.support.transition && this.$element.hasClass('collapse') ?
this.$element.one($.support.transition.end, complete) :
complete()
}
, toggle: function () {
this[this.$element.hasClass('in') ? 'hide' : 'show']()
}
}
/* COLLAPSE PLUGIN DEFINITION
* ========================== */
var old = $.fn.collapse
$.fn.collapse = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('collapse')
, options = $.extend({}, $.fn.collapse.defaults, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('collapse', (data = new Collapse(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.collapse.defaults = {
toggle: true
}
$.fn.collapse.Constructor = Collapse
/* COLLAPSE NO CONFLICT
* ==================== */
$.fn.collapse.noConflict = function () {
$.fn.collapse = old
return this
}
/* COLLAPSE DATA-API
* ================= */
$(document).on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
var $this = $(this), href
, target = $this.attr('data-target')
|| e.preventDefault()
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
, option = $(target).data('collapse') ? 'toggle' : $this.data()
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
$(target).collapse(option)
})
}(window.jQuery);/* ============================================================
* bootstrap-dropdown.js v2.3.2
* http://getbootstrap.com/2.3.2/javascript.html#dropdowns
* ============================================================
* Copyright 2013 Twitter, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============================================================ */
!function ($) {
"use strict"; // jshint ;_;
/* DROPDOWN CLASS DEFINITION
* ========================= */
var toggle = '[data-toggle=dropdown]'
, Dropdown = function (element) {
var $el = $(element).on('click.dropdown.data-api', this.toggle)
$('html').on('click.dropdown.data-api', function () {
$el.parent().removeClass('open')
})
}
Dropdown.prototype = {
constructor: Dropdown
, toggle: function (e) {
var $this = $(this)
, $parent
, isActive
if ($this.is('.disabled, :disabled')) return
$parent = getParent($this)
isActive = $parent.hasClass('open')
clearMenus()
if (!isActive) {
if ('ontouchstart' in document.documentElement) {
// if mobile we we use a backdrop because click events don't delegate
$('').insertBefore($(this)).on('click', clearMenus)
}
$parent.toggleClass('open')
}
$this.focus()
return false
}
, keydown: function (e) {
var $this
, $items
, $active
, $parent
, isActive
, index
if (!/(38|40|27)/.test(e.keyCode)) return
$this = $(this)
e.preventDefault()
e.stopPropagation()
if ($this.is('.disabled, :disabled')) return
$parent = getParent($this)
isActive = $parent.hasClass('open')
if (!isActive || (isActive && e.keyCode == 27)) {
if (e.which == 27) $parent.find(toggle).focus()
return $this.click()
}
$items = $('[role=menu] li:not(.divider):visible a', $parent)
if (!$items.length) return
index = $items.index($items.filter(':focus'))
if (e.keyCode == 38 && index > 0) index-- // up
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
if (!~index) index = 0
$items
.eq(index)
.focus()
}
}
function clearMenus() {
$('.dropdown-backdrop').remove()
$(toggle).each(function () {
getParent($(this)).removeClass('open')
})
}
function getParent($this) {
var selector = $this.attr('data-target')
, $parent
if (!selector) {
selector = $this.attr('href')
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
$parent = selector && $(selector)
if (!$parent || !$parent.length) $parent = $this.parent()
return $parent
}
/* DROPDOWN PLUGIN DEFINITION
* ========================== */
var old = $.fn.dropdown
$.fn.dropdown = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('dropdown')
if (!data) $this.data('dropdown', (data = new Dropdown(this)))
if (typeof option == 'string') data[option].call($this)
})
}
$.fn.dropdown.Constructor = Dropdown
/* DROPDOWN NO CONFLICT
* ==================== */
$.fn.dropdown.noConflict = function () {
$.fn.dropdown = old
return this
}
/* APPLY TO STANDARD DROPDOWN ELEMENTS
* =================================== */
$(document)
.on('click.dropdown.data-api', clearMenus)
.on('click.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
.on('click.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
.on('keydown.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
}(window.jQuery);
!function ($) {
"use strict"; // jshint ;_;
/* MODAL CLASS DEFINITION
* ====================== */
var Modal = function (content, options) {
this.options = options
this.$element = $(content)
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
}
Modal.prototype = {
constructor: Modal
, toggle: function () {
return this[!this.isShown ? 'show' : 'hide']()
}
, show: function () {
var that = this
, e = $.Event('show')
this.$element.trigger(e)
if (this.isShown || e.isDefaultPrevented()) return
$('body').addClass('modal-open')
this.isShown = true
escape.call(this)
backdrop.call(this, function () {
var transition = $.support.transition && that.$element.hasClass('fade')
if (!that.$element.parent().length) {
that.$element.appendTo(document.body) //don't move modals dom position
}
that.$element
.show()
if (transition) {
that.$element[0].offsetWidth // force reflow
}
that.$element.addClass('in')
transition ?
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
that.$element.trigger('shown')
})
}
, hide: function (e) {
e && e.preventDefault()
var that = this
e = $.Event('hide')
this.$element.trigger(e)
if (!this.isShown || e.isDefaultPrevented()) return
this.isShown = false
$('body').removeClass('modal-open')
escape.call(this)
this.$element.removeClass('in')
$.support.transition && this.$element.hasClass('fade') ?
hideWithTransition.call(this) :
hideModal.call(this)
}
}
/* MODAL PRIVATE METHODS
* ===================== */
function hideWithTransition() {
var that = this
, timeout = setTimeout(function () {
that.$element.off($.support.transition.end)
hideModal.call(that)
}, 500)
this.$element.one($.support.transition.end, function () {
clearTimeout(timeout)
hideModal.call(that)
})
}
function hideModal(that) {
this.$element
.hide()
.trigger('hidden')
backdrop.call(this)
}
function backdrop(callback) {
var that = this
, animate = this.$element.hasClass('fade') ? 'fade' : ''
if (this.isShown && this.options.backdrop) {
var doAnimate = $.support.transition && animate
this.$backdrop = $('')
.appendTo(document.body)
if (this.options.backdrop != 'static') {
this.$backdrop.click($.proxy(this.hide, this))
}
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
this.$backdrop.addClass('in')
doAnimate ?
this.$backdrop.one($.support.transition.end, callback) :
callback()
} else if (!this.isShown && this.$backdrop) {
this.$backdrop.removeClass('in')
$.support.transition && this.$element.hasClass('fade')?
this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
removeBackdrop.call(this)
} else if (callback) {
callback()
}
}
function removeBackdrop() {
this.$backdrop.remove()
this.$backdrop = null
}
function escape() {
var that = this
if (this.isShown && this.options.keyboard) {
$(document).on('keyup.dismiss.modal', function ( e ) {
e.which == 27 && that.hide()
})
} else if (!this.isShown) {
$(document).off('keyup.dismiss.modal')
}
}
/* MODAL PLUGIN DEFINITION
* ======================= */
$.fn.modal = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('modal')
, options = $.extend({}, $.fn.modal.defaults, $this.data(), typeof option == 'object' && option)
if (!data) $this.data('modal', (data = new Modal(this, options)))
if (typeof option == 'string') data[option]()
else if (options.show) data.show()
})
}
$.fn.modal.defaults = {
backdrop: true
, keyboard: true
, show: true
}
$.fn.modal.Constructor = Modal
/* MODAL DATA-API
* ============== */
$(function () {
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
var $this = $(this), href
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
e.preventDefault()
$target.modal(option)
})
})
}(window.jQuery);!function ($) {
"use strict"; // jshint ;_;
/* SCROLLSPY CLASS DEFINITION
* ========================== */
function ScrollSpy(element, options) {
var process = $.proxy(this.process, this)
, $element = $(element).is('body') ? $(window) : $(element)
, href
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
this.selector = (this.options.target
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|| '') + ' .nav li > a'
this.$body = $('body')
this.refresh()
this.process()
}
ScrollSpy.prototype = {
constructor: ScrollSpy
, refresh: function () {
var self = this
, $targets
this.offsets = $([])
this.targets = $([])
$targets = this.$body
.find(this.selector)
.map(function () {
var $el = $(this)
, href = $el.data('target') || $el.attr('href')
, $href = /^#\w/.test(href) && $(href)
return ( $href
&& $href.length
&& [[ $href.position().top + (!$.isWindow(self.$scrollElement.get(0)) && self.$scrollElement.scrollTop()), href ]] ) || null
})
.sort(function (a, b) { return a[0] - b[0] })
.each(function () {
self.offsets.push(this[0])
self.targets.push(this[1])
})
}
, process: function () {
var scrollTop = this.$scrollElement.scrollTop() + this.options.offset
, scrollHeight = this.$scrollElement[0].scrollHeight || this.$body[0].scrollHeight
, maxScroll = scrollHeight - this.$scrollElement.height()
, offsets = this.offsets
, targets = this.targets
, activeTarget = this.activeTarget
, i
if (scrollTop >= maxScroll) {
return activeTarget != (i = targets.last()[0])
&& this.activate ( i )
}
for (i = offsets.length; i--;) {
activeTarget != targets[i]
&& scrollTop >= offsets[i]
&& (!offsets[i + 1] || scrollTop <= offsets[i + 1])
&& this.activate( targets[i] )
}
}
, activate: function (target) {
var active
, selector
this.activeTarget = target
$(this.selector)
.parent('.active')
.removeClass('active')
selector = this.selector
+ '[data-target="' + target + '"],'
+ this.selector + '[href="' + target + '"]'
active = $(selector)
.parent('li')
.addClass('active')
if (active.parent('.dropdown-menu').length) {
active = active.closest('li.dropdown').addClass('active')
}
active.trigger('activate')
}
}
/* SCROLLSPY PLUGIN DEFINITION
* =========================== */
var old = $.fn.scrollspy
$.fn.scrollspy = function (option) {
return this.each(function () {
var $this = $(this)
, data = $this.data('scrollspy')
, options = typeof option == 'object' && option
if (!data) $this.data('scrollspy', (data = new ScrollSpy(this, options)))
if (typeof option == 'string') data[option]()
})
}
$.fn.scrollspy.Constructor = ScrollSpy
$.fn.scrollspy.defaults = {
offset: 10
}
/* SCROLLSPY NO CONFLICT
* ===================== */
$.fn.scrollspy.noConflict = function () {
$.fn.scrollspy = old
return this
}
/* SCROLLSPY DATA-API
* ================== */
$(window).on('load', function () {
$('[data-spy="scroll"]').each(function () {
var $spy = $(this)
$spy.scrollspy($spy.data())
})
})
}(window.jQuery);/*
* Fuel UX Spinner
* https://github.com/ExactTarget/fuelux
*
* Copyright (c) 2012 ExactTarget
* Licensed under the MIT license.
*/
// SPINNER CONSTRUCTOR AND PROTOTYPE
var Spinner = function (element, options) {
this.$element = $(element);
this.options = $.extend({}, $.fn.spinner.defaults, options);
this.$input = this.$element.find('input');
this.$element.on('keyup', this.$input, $.proxy(this.change, this));
/*
this.$input.change($.proxy(function(e) {
this.value(e.target.value);
}, this));
*/
this.$input.on('keydown', function(e) {
if (e.keyCode >= 48 && e.keyCode <= 57) return true;
if (e.keyCode == 37 || e.keyCode == 39 || e.keyCode == 8 || e.keyCode == 9) return true;
if (e.keyCode == 38) {
this.value = parseInt(this.value) + 1;
}
if (e.keyCode == 40) {
this.value = parseInt(this.value) - 1;
if (this.value < 0) this.value = 0;
}
return false;
})
if (this.options.hold) {
this.$element.on('mousedown', '.spinner-up', $.proxy(function() { this.startSpin(true); } , this));
this.$element.on('mouseup', '.spinner-up, .spinner-down', $.proxy(this.stopSpin, this));
this.$element.on('mouseout', '.spinner-up, .spinner-down', $.proxy(this.stopSpin, this));
this.$element.on('mousedown', '.spinner-down', $.proxy(function() {this.startSpin(false);} , this));
} else {
this.$element.on('click', '.spinner-up', $.proxy(function() { this.step(true); } , this));
this.$element.on('click', '.spinner-down', $.proxy(function() { this.step(false); }, this));
}
this.switches = {
count: 1,
enabled: true
};
if (this.options.speed === 'medium') {
this.switches.speed = 300;
} else if (this.options.speed === 'fast') {
this.switches.speed = 100;
} else {
this.switches.speed = 500;
}
this.lastValue = null;
this.render();
if (this.options.disabled) {
this.disable();
}
};
Spinner.prototype = {
constructor: Spinner,
render: function () {
var inputValue = this.$input.val();
if (inputValue) {
this.value(inputValue);
} else {
this.$input.val(this.options.value);
}
this.$input.attr('maxlength', (this.options.max + '').split('').length);
},
change: function () {
var newVal = this.$input.val();
if(newVal/1){
this.options.value = newVal/1;
}else{
newVal = newVal.replace(/[^0-9]/g,'');
this.$input.val(newVal);
this.options.value = newVal/1;
}
this.triggerChangedEvent();
},
stopSpin: function () {
clearTimeout(this.switches.timeout);
this.switches.count = 1;
this.triggerChangedEvent();
},
triggerChangedEvent: function () {
var currentValue = this.value();
if (currentValue === this.lastValue) return;
this.lastValue = currentValue;
// Primary changed event
this.$element.trigger('changed', currentValue);
// Undocumented, kept for backward compatibility
this.$element.trigger('change');
this.$input.change();
},
startSpin: function (type) {
if (!this.options.disabled) {
var divisor = this.switches.count;
if (divisor === 1) {
this.step(type);
divisor = 1;
} else if (divisor < 3){
divisor = 1.5;
} else if (divisor < 8){
divisor = 2.5;
} else {
divisor = 4;
}
this.switches.timeout = setTimeout($.proxy(function() {this.iterator(type);} ,this),this.switches.speed/divisor);
this.switches.count++;
}
},
iterator: function (type) {
this.step(type);
this.startSpin(type);
},
step: function (dir) {
var curValue = this.options.value;
var limValue = dir ? this.options.max : this.options.min;
if ((dir ? curValue < limValue : curValue > limValue)) {
var newVal = curValue + (dir ? 1 : -1) * this.options.step;
if (dir ? newVal > limValue : newVal < limValue) {
this.value(limValue);
} else {
this.value(newVal);
}
} else if (this.options.cycle) {
var cycleVal = dir ? this.options.min : this.options.max;
this.value(cycleVal);
}
},
value: function (value) {
if (!isNaN(parseFloat(value)) && isFinite(value)) {
value = parseFloat(value);
this.options.value = value;
this.$input.val(value);
return this;
} else {
return this.options.value;
}
},
disable: function () {
this.options.disabled = true;
this.$input.attr('disabled','');
this.$element.find('button').addClass('disabled');
},
enable: function () {
this.options.disabled = false;
this.$input.removeAttr("disabled");
this.$element.find('button').removeClass('disabled');
}
};
// SPINNER PLUGIN DEFINITION
$.fn.spinner = function (option,value) {
var methodReturn;
var $set = this.each(function () {
var $this = $(this);
var data = $this.data('spinner');
var options = typeof option === 'object' && option;
if (!data) $this.data('spinner', (data = new Spinner(this, options)));
if (typeof option === 'string') methodReturn = data[option](value);
});
return (methodReturn === undefined) ? $set : methodReturn;
};
$.fn.spinner.defaults = {
value: 1,
min: 0,
max: 999,
step: 1,
hold: true,
speed: 'medium',
disabled: false
};
$.fn.spinner.Constructor = Spinner;
// SPINNER DATA-API
$(function () {
$('body').on('mousedown.spinner.data-api', '.spinner', function () {
var $this = $(this);
if ($this.data('spinner')) return;
$this.spinner($this.data());
});
});
!function ($) {
"use strict"; // jshint ;_;
/* TAB CLASS DEFINITION
* ==================== */
var Tab = function (element) {
this.element = $(element)
}
Tab.prototype = {
constructor: Tab
, show: function () {
var $this = this.element
, $ul = $this.closest('ul:not(.dropdown-menu)')
, selector = $this.attr('data-target')
, previous
, $target
, e
if (!selector) {
selector = $this.attr('href')
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
}
if ( $this.parent('li').hasClass('active') ) return
previous = $ul.find('.active:last a')[0]
e = $.Event('show', {
relatedTarget: previous
})
$this.trigger(e)
if (e.isDefaultPrevented()) return
$target = $(selector)
this.activate($this.parent('li'), $ul)
this.activate($target, $target.parent(), function () {
$this.trigger({
type: 'shown'
, relatedTarget: previous
})
})
}
, activate: function ( element, container, callback) {
var $active = container.find('> .active')
, transition = callback
&& $.support.transition
&& $active.hasClass('fade')
function next() {
$active
.removeClass('active')
.find('> .dropdown-menu > .active')
.removeClass('active')
element.addClass('active')
if (transition) {
element[0].offsetWidth // reflow for transition
element.addClass('in')
} else {
element.removeClass('fade')
}
if ( element.parent('.dropdown-menu') ) {
element.closest('li.dropdown').addClass('active')
}
callback && callback()
}
transition ?
$active.one($.support.transition.end, next) :
next()
$active.removeClass('in')
}
}
/* TAB PLUGIN DEFINITION
* ===================== */
var old = $.fn.tab
$.fn.tab = function ( option ) {
return this.each(function () {
var $this = $(this)
, data = $this.data('tab')
if (!data) $this.data('tab', (data = new Tab(this)))
if (typeof option == 'string') data[option]()
})
}
$.fn.tab.Constructor = Tab
/* TAB NO CONFLICT
* =============== */
$.fn.tab.noConflict = function () {
$.fn.tab = old
return this
}
/* TAB DATA-API
* ============ */
$(document).on('click.tab.data-api', '[data-toggle="tab"], [data-toggle="pill"]', function (e) {
e.preventDefault()
$(this).tab('show')
})
}(window.jQuery);!function ($) {
$(document).on('click.bootstrap-toggle', '[data-toggle^=toggle]', function(e) {
var $toggle = $(this);
var $input = $(this).find('input[type=checkbox]');
if ($toggle.hasClass('disabled')) {
$toggle.find('.btn').addClass('disabled').prop('disabled', 'on');
} else {
if ($toggle.hasClass('off')) {
$toggle.attr('class', 'toggle ' + $toggle.find('.toggle-on').attr('class').replace(/toggle-on/g,''))
$toggle.removeClass('off');
$input.prop('checked', true).trigger('change');
} else {
$toggle.attr('class', 'toggle ' + $toggle.find('.toggle-off').attr('class').replace(/toggle-off/g,''))
$toggle.addClass('off');
$input.prop('checked', false).trigger('change');
}
}
});
}(window.jQuery);!function ($) {
"use strict"; // jshint ;_;
/* CSS TRANSITION SUPPORT (http://www.modernizr.com/)
* ======================================================= */
$(function () {
$.support.transition = (function () {
var transitionEnd = (function () {
var el = document.createElement('bootstrap')
, transEndEventNames = {
'WebkitTransition' : 'webkitTransitionEnd'
, 'MozTransition' : 'transitionend'
, 'OTransition' : 'oTransitionEnd otransitionend'
, 'transition' : 'transitionend'
}
, name
for (name in transEndEventNames){
if (el.style[name] !== undefined) {
return transEndEventNames[name]
}
}
}())
return transitionEnd && {
end: transitionEnd
}
})()
})
}(window.jQuery);