/*-----------H-ui前端框架-------------
* H-ui.js v3.1.3
* http://www.h-ui.net/
* Created & Modified by guojunhui
* Date modified 2017.05.26
*
* Copyright 2013-2017 北京颖杰联创科技有限公司 All rights reserved.
* Licensed under MIT license.
* http://opensource.org/licenses/MIT
*/
/*
Includes:
jQuery.IEMobileHack.js
jQuery.cookie.js v1.4.1
jQuery.form.js v3.51.0
jQuery.lazyload.js v1.9.3
jQuery.responsive-nav.js v1.0.39
jQuery.placeholder.js
jQuery.emailsuggest.js v1.0
jQuery.format.js
jQuery.togglePassword.js
jQuery.iCheck.js
jQuery.raty.js v2.4.5
jQuery.onePageNav.js
jQuery.stickUp.js
jQuery.ColorPicker.js
jQuery.HuiaddFavorite.js
jQuery.Huisethome.js
jQuery.Huisidenav.js
jQuery.Huihover.js v2.0
jQuery.Huifocusblur.js V2.0
jQuery.Huiselect.js
jQuery.Huitab.js v2.0
jQuery.Huifold.js v2.0
jQuery.Huitags.js v2.0
jQuery.Huitagsmixed.js
jQuery.Huitextarealength.js v2.0
jQuery.Huipreview.js v2.0
jQuery.Huimodalalert.js
jQuery.Huialert.js
jQuery.Huitotop.js v2.0
jQuery.Huimarquee.js
jQuery.Huispinner.js v2.0
Bootstrap.modal.js v3.3.0
Bootstrap.dropdown.js v3.3.0
Bootstrap.transition.js v3.3.0
Bootstrap.tooltip.js v3.3.0
Bootstrap.popover.js v3.3.0
Bootstrap.alert.js v3.3.0
Bootstrap.slider.js v1.0.1
Bootstrap.datetimepicker.js
Bootstrap.Switch v1.3
*/
/* =======================================================================
* jQuery.IEMobileHack.js判断浏览器
* ======================================================================== */
!function(){
if (navigator.userAgent.match(/IEMobile\/10\.0/)) {
var msViewportStyle = document.createElement("style");
msViewportStyle.appendChild(
document.createTextNode(
"@-ms-viewport{width:auto!important}"
)
);
document.getElementsByTagName("head")[0].appendChild(msViewportStyle);
}
} ();
/* =======================================================================
* jQuery.stopDefault.js 阻止默认浏览器动作
* ======================================================================== */
function stopDefault(e) {
if (e && e.preventDefault) e.preventDefault();
//IE中阻止函数器默认动作的方式
else window.event.returnValue = false;
return false;
}
/* =======================================================================
* jQuery.cookie.js v1.4.1
* https://github.com/carhartl/jQuery-cookie
*
* Copyright 2006, 2014 Klaus Hartl
* Released under the MIT license
* ======================================================================== */
!(function(factory) {
if (typeof define === 'function' && define.amd) {
// AMD (Register as an anonymous module)
define(['jquery'], factory);
} else if (typeof exports === 'object') {
// Node/CommonJS
module.exports = factory(require('jquery'));
} else {
// Browser globals
factory(jQuery);
}
}
(function($){
var pluses = /\+/g;
function encode(s) {
return config.raw ? s : encodeURIComponent(s);
}
function decode(s) {
return config.raw ? s : decodeURIComponent(s);
}
function stringifyCookieValue(value) {
return encode(config.json ? JSON.stringify(value) : String(value));
}
function parseCookieValue(s) {
if (s.indexOf('"') === 0) {
// This is a quoted cookie as according to RFC2068, unescape...
s = s.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\');
}
try {
// Replace server-side written pluses with spaces.
// If we can't decode the cookie, ignore it, it's unusable.
// If we can't parse the cookie, ignore it, it's unusable.
s = decodeURIComponent(s.replace(pluses, ' '));
return config.json ? JSON.parse(s) : s;
} catch(e) {}
}
function read(s, converter) {
var value = config.raw ? s: parseCookieValue(s);
return $.isFunction(converter) ? converter(value) : value;
}
var config = $.cookie = function(key, value, options) {
// Write
if (arguments.length > 1 && !$.isFunction(value)) {
options = $.extend({},
config.defaults, options);
if (typeof options.expires === 'number') {
var days = options.expires,
t = options.expires = new Date();
t.setMilliseconds(t.getMilliseconds() + days * 864e+5);
}
return (document.cookie = [encode(key), '=', stringifyCookieValue(value), options.expires ? '; expires=' + options.expires.toUTCString() : '', // use expires attribute, max-age is not supported by IE
options.path ? '; path=' + options.path: '', options.domain ? '; domain=' + options.domain: '', options.secure ? '; secure': ''].join(''));
}
// Read
var result = key ? undefined: {},
// To prevent the for loop in the first place assign an empty array
// in case there are no cookies at all. Also prevents odd result when
// calling $.cookie().
cookies = document.cookie ? document.cookie.split('; ') : [],
i = 0,
l = cookies.length;
for (; i < l; i++) {
var parts = cookies[i].split('='),
name = decode(parts.shift()),
cookie = parts.join('=');
if (key === name) {
// If second argument (value) is a function it's a converter...
result = read(cookie, value);
break;
}
// Prevent storing a cookie that we couldn't decode.
if (!key && (cookie = read(cookie)) !== undefined) {
result[name] = cookie;
}
}
return result;
};
config.defaults = {};
$.removeCookie = function(key, options) {
// Must not alter options, thus extending a fresh object...
$.cookie(key, '', $.extend({},
options, {
expires: -1
}));
return ! $.cookie(key);
};
}));
/* =======================================================================
* jQuery.form.js Plugin v3.51.0 2014.06.20
* Requires jQuery v1.5 or later
* Copyright (c) 2014 M. Alsup
* Examples and documentation at: http://malsup.com/jquery/form/
* Project repository: https://github.com/malsup/form
* Dual licensed under the MIT and GPL licenses.
* https://github.com/malsup/form#copyright-and-license
* ======================================================================== */
// AMD support
(function(factory) {
"use strict";
if (typeof define === 'function' && define.amd) {
// using AMD; register as anon module
define(['jquery'], factory);
} else {
// no AMD; invoke directly
factory((typeof(jQuery) != 'undefined') ? jQuery: window.Zepto);
}
} (function($) {
"use strict";
/*
Usage Note:
-----------
Do not use both ajaxSubmit and ajaxForm on the same form. These
functions are mutually exclusive. Use ajaxSubmit if you want
to bind your own submit handler to the form. For example,
$(document).ready(function() {
$('#myForm').on('submit', function(e) {
e.preventDefault(); // <-- important
$(this).ajaxSubmit({
target: '#output'
});
});
});
Use ajaxForm when you want the plugin to manage all the event binding
for you. For example,
$(document).ready(function() {
$('#myForm').ajaxForm({
target: '#output'
});
});
You can also use ajaxForm with delegation (requires jQuery v1.7+), so the
form does not have to exist when you invoke ajaxForm:
$('#myForm').ajaxForm({
delegation: true,
target: '#output'
});
When using ajaxForm, the ajaxSubmit function will be invoked for you
at the appropriate time.
*/
/**
* Feature detection
*/
var feature = {};
feature.fileapi = $("").get(0).files !== undefined;
feature.formdata = window.FormData !== undefined;
var hasProp = !!$.fn.prop;
// attr2 uses prop when it can but checks the return type for
// an expected string. this accounts for the case where a form
// contains inputs with names like "action" or "method"; in those
// cases "prop" returns the element
$.fn.attr2 = function() {
if (!hasProp) {
return this.attr.apply(this, arguments);
}
var val = this.prop.apply(this, arguments);
if ((val && val.jquery) || typeof val === 'string') {
return val;
}
return this.attr.apply(this, arguments);
};
/**
* ajaxSubmit() provides a mechanism for immediately submitting
* an HTML form using AJAX.
*/
$.fn.ajaxSubmit = function(options) {
/*jshint scripturl:true */
// fast fail if nothing selected (http://dev.jquery.com/ticket/2752)
if (!this.length) {
log('ajaxSubmit: skipping submit process - no element selected');
return this;
}
var method, action, url, $form = this;
if (typeof options == 'function') {
options = {
success: options
};
} else if (options === undefined) {
options = {};
}
method = options.type || this.attr2('method');
action = options.url || this.attr2('action');
url = (typeof action === 'string') ? $.trim(action) : '';
url = url || window.location.href || '';
if (url) {
// clean url (don't include hash vaue)
url = (url.match(/^([^#]+)/) || [])[1];
}
options = $.extend(true, {
url: url,
success: $.ajaxSettings.success,
type: method || $.ajaxSettings.type,
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 traditional = options.traditional;
if (traditional === undefined) {
traditional = $.ajaxSettings.traditional;
}
var elements = [];
var qx, a = this.formToArray(options.semantic, elements);
if (options.data) {
options.extraData = options.data;
qx = $.param(options.data, traditional);
}
// 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, traditional);
if (qx) {
q = (q ? (q + '&' + qx) : qx);
}
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 callbacks = [];
if (options.resetForm) {
callbacks.push(function() {
$form.resetForm();
});
}
if (options.clearForm) {
callbacks.push(function() {
$form.clearForm(options.includeHidden);
});
}
// 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 || this; // 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]);
}
};
if (options.error) {
var oldError = options.error;
options.error = function(xhr, status, error) {
var context = options.context || this;
oldError.apply(context, [xhr, status, error, $form]);
};
}
if (options.complete) {
var oldComplete = options.complete;
options.complete = function(xhr, status) {
var context = options.context || this;
oldComplete.apply(context, [xhr, status, $form]);
};
}
// are there files to upload?
// [value] (issue #113), also see comment:
// https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219
var fileInputs = $('input[type=file]:enabled', this).filter(function() {
return $(this).val() !== '';
});
var hasFileInputs = fileInputs.length > 0;
var mp = 'multipart/form-data';
var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp);
var fileAPI = feature.fileapi && feature.formdata;
log("fileAPI :" + fileAPI);
var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI;
var jqxhr;
// 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 && (options.iframe || shouldUseFrame)) {
// 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,
function() {
jqxhr = fileUploadIframe(a);
});
} else {
jqxhr = fileUploadIframe(a);
}
} else if ((hasFileInputs || multipart) && fileAPI) {
jqxhr = fileUploadXhr(a);
} else {
jqxhr = $.ajax(options);
}
$form.removeData('jqxhr').data('jqxhr', jqxhr);
// clear element array
for (var k = 0; k < elements.length; k++) {
elements[k] = null;
}
// fire 'notify' event
this.trigger('form-submit-notify', [this, options]);
return this;
// utility fn for deep serialization
function deepSerialize(extraData) {
var serialized = $.param(extraData, options.traditional).split('&');
var len = serialized.length;
var result = [];
var i, part;
for (i = 0; i < len; i++) {
// #252; undo param space replacement
serialized[i] = serialized[i].replace(/\+/g, ' ');
part = serialized[i].split('=');
// #278; use array instead of object storage, favoring array serializations
result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]);
}
return result;
}
// XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz)
function fileUploadXhr(a) {
var formdata = new FormData();
for (var i = 0; i < a.length; i++) {
formdata.append(a[i].name, a[i].value);
}
if (options.extraData) {
var serializedData = deepSerialize(options.extraData);
for (i = 0; i < serializedData.length; i++) {
if (serializedData[i]) {
formdata.append(serializedData[i][0], serializedData[i][1]);
}
}
}
options.data = null;
var s = $.extend(true, {},
$.ajaxSettings, options, {
contentType: false,
processData: false,
cache: false,
type: method || 'POST'
});
if (options.uploadProgress) {
// workaround because jqXHR does not expose upload property
s.xhr = function() {
var xhr = $.ajaxSettings.xhr();
if (xhr.upload) {
xhr.upload.addEventListener('progress',
function(event) {
var percent = 0;
var position = event.loaded || event.position;
/*event.position is deprecated*/
var total = event.total;
if (event.lengthComputable) {
percent = Math.ceil(position / total * 100);
}
options.uploadProgress(event, position, total, percent);
},
false);
}
return xhr;
};
}
s.data = null;
var beforeSend = s.beforeSend;
s.beforeSend = function(xhr, o) {
//Send FormData() provided by user
if (options.formData) {
o.data = options.formData;
} else {
o.data = formdata;
}
if (beforeSend) {
beforeSend.call(this, xhr, o);
}
};
return $.ajax(s);
}
// private function for handling file uploads (hat tip to YAHOO!)
function fileUploadIframe(a) {
var form = $form[0],
el,
i,
s,
g,
id,
$io,
io,
xhr,
sub,
n,
timedOut,
timeoutHandle;
var deferred = $.Deferred();
// #341
deferred.abort = function(status) {
xhr.abort(status);
};
if (a) {
// ensure that every serialized input is still enabled
for (i = 0; i < elements.length; i++) {
el = $(elements[i]);
if (hasProp) {
el.prop('disabled', false);
} else {
el.removeAttr('disabled');
}
}
}
s = $.extend(true, {},
$.ajaxSettings, options);
s.context = s.context || s;
id = 'jqFormIO' + (new Date().getTime());
if (s.iframeTarget) {
$io = $(s.iframeTarget);
n = $io.attr2('name');
if (!n) {
$io.attr2('name', id);
} else {
id = n;
}
} else {
$io = $('');
$io.css({
position: 'absolute',
top: '-1000px',
left: '-1000px'
});
}
io = $io[0];
xhr = { // mock object
aborted: 0,
responseText: null,
responseXML: null,
status: 0,
statusText: 'n/a',
getAllResponseHeaders: function() {},
getResponseHeader: function() {},
setRequestHeader: function() {},
abort: function(status) {
var e = (status === 'timeout' ? 'timeout': 'aborted');
log('aborting upload... ' + e);
this.aborted = 1;
try { // #214, #257
if (io.contentWindow.document.execCommand) {
io.contentWindow.document.execCommand('Stop');
}
} catch(ignore) {}
$io.attr('src', s.iframeSrc); // abort op in progress
xhr.error = e;
if (s.error) {
s.error.call(s.context, xhr, e, status);
}
if (g) {
$.event.trigger("ajaxError", [xhr, s, e]);
}
if (s.complete) {
s.complete.call(s.context, xhr, e);
}
}
};
g = s.global;
// trigger ajax global events so that activity/block indicators work like normal
if (g && 0 === $.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--;
}
deferred.reject();
return deferred;
}
if (xhr.aborted) {
deferred.reject();
return deferred;
}
// add submitting element to data if we know it
sub = form.clk;
if (sub) {
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;
}
}
}
var CLIENT_TIMEOUT_ABORT = 1;
var SERVER_ABORT = 2;
function getDoc(frame) {
/* it looks like contentWindow or contentDocument do not
* carry the protocol property in ie8, when running under ssl
* frame.document is the only valid response document, since
* the protocol is know but not on the other two objects. strange?
* "Same origin policy" http://en.wikipedia.org/wiki/Same_origin_policy
*/
var doc = null;
// IE8 cascading access check
try {
if (frame.contentWindow) {
doc = frame.contentWindow.document;
}
} catch(err) {
// IE8 access denied under ssl & missing protocol
log('cannot get iframe.contentWindow document: ' + err);
}
if (doc) { // successful getting content
return doc;
}
try { // simply checking may throw in ie8 under ssl or mismatched protocol
doc = frame.contentDocument ? frame.contentDocument: frame.document;
} catch(err) {
// last attempt
log('cannot get iframe.contentDocument: ' + err);
doc = frame.document;
}
return doc;
}
// Rails CSRF hack (thanks to Yvan Barthelemy)
var csrf_token = $('meta[name=csrf-token]').attr('content');
var csrf_param = $('meta[name=csrf-param]').attr('content');
if (csrf_param && csrf_token) {
s.extraData = s.extraData || {};
s.extraData[csrf_param] = csrf_token;
}
// 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.attr2('target'),
a = $form.attr2('action'),
mp = 'multipart/form-data',
et = $form.attr('enctype') || $form.attr('encoding') || mp;
// update form attrs in IE friendly way
form.setAttribute('target', id);
if (!method || /post/i.test(method)) {
form.setAttribute('method', 'POST');
}
if (a != s.url) {
form.setAttribute('action', s.url);
}
// ie borks in some cases when setting encoding
if (!s.skipEncodingOverride && (!method || /post/i.test(method))) {
$form.attr({
encoding: 'multipart/form-data',
enctype: 'multipart/form-data'
});
}
// support timout
if (s.timeout) {
timeoutHandle = setTimeout(function() {
timedOut = true;
cb(CLIENT_TIMEOUT_ABORT);
},
s.timeout);
}
// look for server aborts
function checkState() {
try {
var state = getDoc(io).readyState;
log('state = ' + state);
if (state && state.toLowerCase() == 'uninitialized') {
setTimeout(checkState, 50);
}
} catch(e) {
log('Server abort: ', e, ' (', e.name, ')');
cb(SERVER_ABORT);
if (timeoutHandle) {
clearTimeout(timeoutHandle);
}
timeoutHandle = undefined;
}
}
// add "extra" data to form if provided in options
var extraInputs = [];
try {
if (s.extraData) {
for (var n in s.extraData) {
if (s.extraData.hasOwnProperty(n)) {
// if using the $.param format that allows for multiple values with the same name
if ($.isPlainObject(s.extraData[n]) && s.extraData[n].hasOwnProperty('name') && s.extraData[n].hasOwnProperty('value')) {
extraInputs.push($('').val(s.extraData[n].value).appendTo(form)[0]);
} else {
extraInputs.push($('').val(s.extraData[n]).appendTo(form)[0]);
}
}
}
}
if (!s.iframeTarget) {
// add iframe to doc and submit the form
$io.appendTo('body');
}
if (io.attachEvent) {
io.attachEvent('onload', cb);
} else {
io.addEventListener('load', cb, false);
}
setTimeout(checkState, 15);
try {
form.submit();
} catch(err) {
// just in case form has element with name/id of 'submit'
var submitFn = document.createElement('form').submit;
submitFn.apply(form);
}
} finally {
// reset attrs and remove "extra" input elements
form.setAttribute('action', a);
form.setAttribute('enctype', et); // #380
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,
callbackProcessed;
function cb(e) {
if (xhr.aborted || callbackProcessed) {
return;
}
doc = getDoc(io);
if (!doc) {
log('cannot access response document');
e = SERVER_ABORT;
}
if (e === CLIENT_TIMEOUT_ABORT && xhr) {
xhr.abort('timeout');
deferred.reject(xhr, 'timeout');
return;
} else if (e == SERVER_ABORT && xhr) {
xhr.abort('server abort');
deferred.reject(xhr, 'error', 'server abort');
return;
}
if (!doc || doc.location.href == s.iframeSrc) {
// response not received yet
if (!timedOut) {
return;
}
}
if (io.detachEvent) {
io.detachEvent('onload', cb);
} else {
io.removeEventListener('load', cb, false);
}
var status = 'success',
errMsg;
try {
if (timedOut) {
throw 'timeout';
}
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');
var docRoot = doc.body ? doc.body: doc.documentElement;
xhr.responseText = docRoot ? docRoot.innerHTML: null;
xhr.responseXML = doc.XMLDocument ? doc.XMLDocument: doc;
if (isXml) {
s.dataType = 'xml';
}
xhr.getResponseHeader = function(header) {
var headers = {
'content-type': s.dataType
};
return headers[header.toLowerCase()];
};
// support for XHR 'status' & 'statusText' emulation :
if (docRoot) {
xhr.status = Number(docRoot.getAttribute('status')) || xhr.status;
xhr.statusText = docRoot.getAttribute('statusText') || xhr.statusText;
}
var dt = (s.dataType || '').toLowerCase();
var scr = /(json|script|text)/.test(dt);
if (scr || s.textarea) {
// see if user embedded response in textarea
var ta = doc.getElementsByTagName('textarea')[0];
if (ta) {
xhr.responseText = ta.value;
// support for XHR 'status' & 'statusText' emulation :
xhr.status = Number(ta.getAttribute('status')) || xhr.status;
xhr.statusText = ta.getAttribute('statusText') || xhr.statusText;
} else if (scr) {
// account for browsers injecting pre around json response
var pre = doc.getElementsByTagName('pre')[0];
var b = doc.getElementsByTagName('body')[0];
if (pre) {
xhr.responseText = pre.textContent ? pre.textContent: pre.innerText;
} else if (b) {
xhr.responseText = b.textContent ? b.textContent: b.innerText;
}
}
} else if (dt == 'xml' && !xhr.responseXML && xhr.responseText) {
xhr.responseXML = toXml(xhr.responseText);
}
try {
data = httpData(xhr, dt, s);
} catch(err) {
status = 'parsererror';
xhr.error = errMsg = (err || status);
}
} catch(err) {
log('error caught: ', err);
status = 'error';
xhr.error = errMsg = (err || status);
}
if (xhr.aborted) {
log('upload aborted');
status = null;
}
if (xhr.status) { // we've set xhr.status
status = (xhr.status >= 200 && xhr.status < 300 || xhr.status === 304) ? 'success': 'error';
}
// ordering of these callbacks/triggers is odd, but that's how $.ajax does it
if (status === 'success') {
if (s.success) {
s.success.call(s.context, data, 'success', xhr);
}
deferred.resolve(xhr.responseText, 'success', xhr);
if (g) {
$.event.trigger("ajaxSuccess", [xhr, s]);
}
} else if (status) {
if (errMsg === undefined) {
errMsg = xhr.statusText;
}
if (s.error) {
s.error.call(s.context, xhr, status, errMsg);
}
deferred.reject(xhr, 'error', errMsg);
if (g) {
$.event.trigger("ajaxError", [xhr, s, errMsg]);
}
}
if (g) {
$.event.trigger("ajaxComplete", [xhr, s]);
}
if (g && !--$.active) {
$.event.trigger("ajaxStop");
}
if (s.complete) {
s.complete.call(s.context, xhr, status);
}
callbackProcessed = true;
if (s.timeout) {
clearTimeout(timeoutHandle);
}
// clean up
setTimeout(function() {
if (!s.iframeTarget) {
$io.remove();
} else { //adding else to clean up existing iframe response.
$io.attr('src', s.iframeSrc);
}
xhr.responseXML = null;
},
100);
}
var toXml = $.parseXML ||
function(s, doc) { // use parseXML if available (jQuery 1.5+)
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.nodeName != 'parsererror') ? doc: null;
};
var parseJSON = $.parseJSON ||
function(s) {
/*jslint evil:true */
return window['eval']('(' + s + ')');
};
var httpData = function(xhr, type, s) { // mostly lifted from jq1.4.4
var ct = xhr.getResponseHeader('content-type') || '',
xml = type === 'xml' || !type && ct.indexOf('xml') >= 0,
data = xml ? xhr.responseXML: xhr.responseText;
if (xml && data.documentElement.nodeName === 'parsererror') {
if ($.error) {
$.error('parsererror');
}
}
if (s && s.dataFilter) {
data = s.dataFilter(data, type);
}
if (typeof data === 'string') {
if (type === 'json' || !type && ct.indexOf('json') >= 0) {
data = parseJSON(data);
} else if (type === "script" || !type && ct.indexOf("javascript") >= 0) {
$.globalEval(data);
}
}
return data;
};
return deferred;
}
};
/**
* 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) {
options = options || {};
options.delegation = options.delegation && $.isFunction($.fn.on);
// in jQuery 1.3+ we can fix mistakes with the ready state
if (!options.delegation && 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;
}
if (options.delegation) {
$(document).off('submit.form-plugin', this.selector, doAjaxSubmit).off('click.form-plugin', this.selector, captureSubmittingElement).on('submit.form-plugin', this.selector, options, doAjaxSubmit).on('click.form-plugin', this.selector, options, captureSubmittingElement);
return this;
}
return this.ajaxFormUnbind().on('submit.form-plugin', options, doAjaxSubmit).on('click.form-plugin', options, captureSubmittingElement);
};
// private event handlers
function doAjaxSubmit(e) {
/*jshint validthis:true */
var options = e.data;
if (!e.isDefaultPrevented()) { // if event has been canceled, don't proceed
e.preventDefault();
$(e.target).ajaxSubmit(options); // #365
}
}
function captureSubmittingElement(e) {
/*jshint validthis:true */
var target = e.target;
var $el = $(target);
if (! ($el.is("[type=submit],[type=image]"))) {
// is this a child element of the submit el? (ex: a span within a button)
var t = $el.closest('[type=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') {
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, elements) {
var a = [];
if (this.length === 0) {
return a;
}
var form = this[0];
var formId = this.attr('id');
var els = semantic ? form.getElementsByTagName('*') : form.elements;
var els2;
if (els && !/MSIE [678]/.test(navigator.userAgent)) { // #390
els = $(els).get(); // convert to standard array
}
// #386; account for inputs outside the form which use the 'form' attribute
if (formId) {
els2 = $(':input[form="' + formId + '"]').get(); // hat tip @thet
if (els2.length) {
els = (els || []).concat(els2);
}
}
if (!els || !els.length) {
return a;
}
var i, j, n, v, el, max, jmax;
for (i = 0, max = els.length; i < max; i++) {
el = els[i];
n = el.name;
if (!n || el.disabled) {
continue;
}
if (semantic && form.clk && el.type == "image") {
// handle image inputs on the fly when semantic == true
if (form.clk == el) {
a.push({
name: n,
value: $(el).val(),
type: el.type
});
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) {
if (elements) {
elements.push(el);
}
for (j = 0, jmax = v.length; j < jmax; j++) {
a.push({
name: n,
value: v[j]
});
}
} else if (feature.fileapi && el.type == 'file') {
if (elements) {
elements.push(el);
}
var files = el.files;
if (files.length) {
for (j = 0; j < files.length; j++) {
a.push({
name: n,
value: files[j],
type: el.type
});
}
} else {
// #180
a.push({
name: n,
value: '',
type: el.type
});
}
} else if (v !== null && typeof v != 'undefined') {
if (elements) {
elements.push(el);
}
a.push({
name: n,
value: v,
type: el.type,
required: el.required
});
}
}
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 = $('input[type=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 = $('input[type=checkbox]').fieldValue();
* // if neither checkbox is checked
* v === undefined
* // if both checkboxes are checked
* v == ['B1', 'B2']
*
* var v = $('input[type=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;
}
if (v.constructor == Array) {
$.merge(val, v);
} else {
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(includeHidden) {
return this.each(function() {
$('input,select,textarea', this).clearFields(includeHidden);
});
};
/**
* Clears the selected form elements.
*/
$.fn.clearFields = $.fn.clearInputs = function(includeHidden) {
var re = /^(?:color|date|datetime|email|month|number|password|range|search|tel|text|time|url|week)$/i; // 'hidden' is not in this list
return this.each(function() {
var t = this.type,
tag = this.tagName.toLowerCase();
if (re.test(t) || tag == 'textarea') {
this.value = '';
} else if (t == 'checkbox' || t == 'radio') {
this.checked = false;
} else if (tag == 'select') {
this.selectedIndex = -1;
} else if (t == "file") {
if (/MSIE/.test(navigator.userAgent)) {
$(this).replaceWith($(this).clone(true));
} else {
$(this).val('');
}
} else if (includeHidden) {
// includeHidden can be the value true, or it can be a selector string
// indicating a special test; for example:
// $('#myForm').clearForm('.special:hidden')
// the above would clean hidden inputs that have the class of 'special'
if ((includeHidden === true && /hidden/.test(t)) || (typeof includeHidden == 'string' && $(this).is(includeHidden))) {
this.value = '';
}
}
});
};
/**
* 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;
});
};
/**
* 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;
}
});
};
// expose debug var
$.fn.ajaxSubmit.debug = false;
function log() {
if (!$.fn.ajaxSubmit.debug) {
return;
}
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.lazyload v1.9.3
* Lazy Load - jQuery plugin for lazy loading images
* Copyright (c) 2007-2013 Mika Tuupola
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
* Project home: http://www.appelsiini.net/projects/lazyload
* ======================================================================== */
! (function($, window, document, undefined) {
var $window = $(window);
$.fn.lazyload = function(options) {
var elements = this;
var $container;
var settings = {
threshold: 0,
failure_limit: 0,
event: "scroll",
effect: "show",
container: window,
data_attribute: "original",
skip_invisible: true,
appear: null,
load: null,
placeholder: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC"
};
function update() {
var counter = 0;
elements.each(function() {
var $this = $(this);
if (settings.skip_invisible && !$this.is(":visible")) {
return;
}
if ($.abovethetop(this, settings) || $.leftofbegin(this, settings)) {
/* Nothing. */
} else if (!$.belowthefold(this, settings) && !$.rightoffold(this, settings)) {
$this.trigger("appear");
/* if we found an image we'll load, reset the counter */
counter = 0;
} else {
if (++counter > settings.failure_limit) {
return false;
}
}
});
}
if (options) {
/* Maintain BC for a couple of versions. */
if (undefined !== options.failurelimit) {
options.failure_limit = options.failurelimit;
delete options.failurelimit;
}
if (undefined !== options.effectspeed) {
options.effect_speed = options.effectspeed;
delete options.effectspeed;
}
$.extend(settings, options);
}
/* Cache container as jQuery as object. */
$container = (settings.container === undefined || settings.container === window) ? $window: $(settings.container);
/* Fire one scroll event per scroll. Not one scroll event per image. */
if (0 === settings.event.indexOf("scroll")) {
$container.on(settings.event,
function() {
return update();
});
}
this.each(function() {
var self = this;
var $self = $(self);
self.loaded = false;
/* If no src attribute given use data:uri. */
if ($self.attr("src") === undefined || $self.attr("src") === false) {
if ($self.is("img")) {
$self.attr("src", settings.placeholder);
}
}
/* When appear is triggered load original image. */
$self.one("appear",
function() {
if (!this.loaded) {
if (settings.appear) {
var elements_left = elements.length;
settings.appear.call(self, elements_left, settings);
}
$("").on("load",
function() {
var original = $self.attr("data-" + settings.data_attribute);
$self.hide();
if ($self.is("img")) {
$self.attr("src", original);
} else {
$self.css("background-image", "url('" + original + "')");
}
$self[settings.effect](settings.effect_speed);
self.loaded = true;
/* Remove image from array so it is not looped next time. */
var temp = $.grep(elements,
function(element) {
return ! element.loaded;
});
elements = $(temp);
if (settings.load) {
var elements_left = elements.length;
settings.load.call(self, elements_left, settings);
}
}).attr("src", $self.attr("data-" + settings.data_attribute));
}
});
/* When wanted event is triggered load original image */
/* by triggering appear. */
if (0 !== settings.event.indexOf("scroll")) {
$self.on(settings.event,
function() {
if (!self.loaded) {
$self.trigger("appear");
}
});
}
});
/* Check if something appears when window is resized. */
$window.on("resize",
function() {
update();
});
/* With IOS5 force loading images when navigating with back button. */
/* Non optimal workaround. */
if ((/(?:iphone|ipod|ipad).*os 5/gi).test(navigator.appVersion)) {
$window.on("pageshow",
function(event) {
if (event.originalEvent && event.originalEvent.persisted) {
elements.each(function() {
$(this).trigger("appear");
});
}
});
}
/* Force initial check if images should appear. */
$(document).ready(function() {
update();
});
return this;
};
/* Convenience methods in jQuery namespace. */
/* Use as $.belowthefold(element, {threshold : 100, container : window}) */
$.belowthefold = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = (window.innerHeight ? window.innerHeight: $window.height()) + $window.scrollTop();
} else {
fold = $(settings.container).offset().top + $(settings.container).height();
}
return fold <= $(element).offset().top - settings.threshold;
};
$.rightoffold = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = $window.width() + $window.scrollLeft();
} else {
fold = $(settings.container).offset().left + $(settings.container).width();
}
return fold <= $(element).offset().left - settings.threshold;
};
$.abovethetop = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = $window.scrollTop();
} else {
fold = $(settings.container).offset().top;
}
return fold >= $(element).offset().top + settings.threshold + $(element).height();
};
$.leftofbegin = function(element, settings) {
var fold;
if (settings.container === undefined || settings.container === window) {
fold = $window.scrollLeft();
} else {
fold = $(settings.container).offset().left;
}
return fold >= $(element).offset().left + settings.threshold + $(element).width();
};
$.inviewport = function(element, settings) {
return ! $.rightoffold(element, settings) && !$.leftofbegin(element, settings) && !$.belowthefold(element, settings) && !$.abovethetop(element, settings);
};
/* Custom selectors for your convenience. */
/* Use as $("img:below-the-fold").something() or */
/* $("img").filter(":below-the-fold").something() which is faster */
$.extend($.expr[":"], {
"below-the-fold": function(a) {
return $.belowthefold(a, {
threshold: 0
});
},
"above-the-top": function(a) {
return ! $.belowthefold(a, {
threshold: 0
});
},
"right-of-screen": function(a) {
return $.rightoffold(a, {
threshold: 0
});
},
"left-of-screen": function(a) {
return ! $.rightoffold(a, {
threshold: 0
});
},
"in-viewport": function(a) {
return $.inviewport(a, {
threshold: 0
});
},
/* Maintain BC for couple of versions. */
"above-the-fold": function(a) {
return ! $.belowthefold(a, {
threshold: 0
});
},
"right-of-fold": function(a) {
return $.rightoffold(a, {
threshold: 0
});
},
"left-of-fold": function(a) {
return ! $.rightoffold(a, {
threshold: 0
});
}
});
})(jQuery, window, document);
/* =======================================================================
* jQuery.responsive-nav.js v1.0.39
* https://github.com/viljamis/responsive-nav.js
* http://responsive-nav.com
*
* Copyright (c) 2015 @viljamis
* Available under the MIT license
* ======================================================================== */
/* global Event */
(function(document, window, index) {
// Index is used to keep multiple navs on the same page namespaced
"use strict";
var responsiveNav = function(el, options) {
var computed = !!window.getComputedStyle;
/**
* getComputedStyle polyfill for old browsers
*/
if (!computed) {
window.getComputedStyle = function(el) {
this.el = el;
this.getPropertyValue = function(prop) {
var re = /(\-([a-z]){1})/g;
if (prop === "float") {
prop = "styleFloat";
}
if (re.test(prop)) {
prop = prop.replace(re,
function() {
return arguments[2].toUpperCase();
});
}
return el.currentStyle[prop] ? el.currentStyle[prop] : null;
};
return this;
};
}
/* exported addEvent, removeEvent, getChildren, setAttributes, addClass, removeClass, forEach */
/**
* Add Event
* fn arg can be an object or a function, thanks to handleEvent
* read more at: http://www.thecssninja.com/javascript/handleevent
*
* @param {element} element
* @param {event} event
* @param {Function} fn
* @param {boolean} bubbling
*/
var addEvent = function(el, evt, fn, bubble) {
if ("addEventListener" in el) {
// BBOS6 doesn't support handleEvent, catch and polyfill
try {
el.addEventListener(evt, fn, bubble);
} catch(e) {
if (typeof fn === "object" && fn.handleEvent) {
el.addEventListener(evt,
function(e) {
// Bind fn as this and set first arg as event object
fn.handleEvent.call(fn, e);
},
bubble);
} else {
throw e;
}
}
} else if ("attachEvent" in el) {
// check if the callback is an object and contains handleEvent
if (typeof fn === "object" && fn.handleEvent) {
el.attachEvent("on" + evt,
function() {
// Bind fn as this
fn.handleEvent.call(fn);
});
} else {
el.attachEvent("on" + evt, fn);
}
}
},
/**
* Remove Event
*
* @param {element} element
* @param {event} event
* @param {Function} fn
* @param {boolean} bubbling
*/
removeEvent = function(el, evt, fn, bubble) {
if ("removeEventListener" in el) {
try {
el.removeEventListener(evt, fn, bubble);
} catch(e) {
if (typeof fn === "object" && fn.handleEvent) {
el.removeEventListener(evt,
function(e) {
fn.handleEvent.call(fn, e);
},
bubble);
} else {
throw e;
}
}
} else if ("detachEvent" in el) {
if (typeof fn === "object" && fn.handleEvent) {
el.detachEvent("on" + evt,
function() {
fn.handleEvent.call(fn);
});
} else {
el.detachEvent("on" + evt, fn);
}
}
},
/**
* Get the children of any element
*
* @param {element}
* @return {array} Returns matching elements in an array
*/
getChildren = function(e) {
if (e.children.length < 1) {
throw new Error("The Nav container has no containing elements");
}
// Store all children in array
var children = [];
// Loop through children and store in array if child != TextNode
for (var i = 0; i < e.children.length; i++) {
if (e.children[i].nodeType === 1) {
children.push(e.children[i]);
}
}
return children;
},
/**
* Sets multiple attributes at once
*
* @param {element} element
* @param {attrs} attrs
*/
setAttributes = function(el, attrs) {
for (var key in attrs) {
el.setAttribute(key, attrs[key]);
}
},
/**
* Adds a class to any element
*
* @param {element} element
* @param {string} class
*/
addClass = function(el, cls) {
if (el.className.indexOf(cls) !== 0) {
el.className += " " + cls;
el.className = el.className.replace(/(^\s*)|(\s*$)/g, "");
}
},
/**
* Remove a class from any element
*
* @param {element} element
* @param {string} class
*/
removeClass = function(el, cls) {
var reg = new RegExp("(\\s|^)" + cls + "(\\s|$)");
el.className = el.className.replace(reg, " ").replace(/(^\s*)|(\s*$)/g, "");
},
/**
* forEach method that passes back the stuff we need
*
* @param {array} array
* @param {Function} callback
* @param {scope} scope
*/
forEach = function(array, callback, scope) {
for (var i = 0; i < array.length; i++) {
callback.call(scope, i, array[i]);
}
};
var nav, opts, navToggle, styleElement = document.createElement("style"),
htmlEl = document.documentElement,
hasAnimFinished,
isMobile,
navOpen;
var ResponsiveNav = function(el, options) {
var i;
/**
* Default options
* @type {Object}
*/
this.options = {
animate: true,
// Boolean: Use CSS3 transitions, true or false
transition: 284,
// Integer: Speed of the transition, in milliseconds
label: "Menu",
// String: Label for the navigation toggle
insert: "before",
// String: Insert the toggle before or after the navigation
customToggle: "",
// Selector: Specify the ID of a custom toggle
closeOnNavClick: false,
// Boolean: Close the navigation when one of the links are clicked
openPos: "relative",
// String: Position of the opened nav, relative or static
navClass: "nav-collapse",
// String: Default CSS class. If changed, you need to edit the CSS too!
navActiveClass: "js-nav-active",
// String: Class that is added to element when nav is active
jsClass: "js",
// String: 'JS enabled' class which is added to element
init: function() {},
// Function: Init callback
open: function() {},
// Function: Open callback
close: function() {} // Function: Close callback
};
// User defined options
for (i in options) {
this.options[i] = options[i];
}
// Adds "js" class for
addClass(htmlEl, this.options.jsClass);
// Wrapper
this.wrapperEl = el.replace("#", "");
// Try selecting ID first
if (document.getElementById(this.wrapperEl)) {
this.wrapper = document.getElementById(this.wrapperEl);
// If element with an ID doesn't exist, use querySelector
} else if (document.querySelector(this.wrapperEl)) {
this.wrapper = document.querySelector(this.wrapperEl);
// If element doesn't exists, stop here.
} else {
throw new Error("The nav element you are trying to select doesn't exist");
}
// Inner wrapper
this.wrapper.inner = getChildren(this.wrapper);
// For minification
opts = this.options;
nav = this.wrapper;
// Init
this._init(this);
};
ResponsiveNav.prototype = {
/**
* Unattaches events and removes any classes that were added
*/
destroy: function() {
this._removeStyles();
removeClass(nav, "closed");
removeClass(nav, "opened");
removeClass(nav, opts.navClass);
removeClass(nav, opts.navClass + "-" + this.index);
removeClass(htmlEl, opts.navActiveClass);
nav.removeAttribute("style");
nav.removeAttribute("aria-hidden");
removeEvent(window, "resize", this, false);
removeEvent(window, "focus", this, false);
removeEvent(document.body, "touchmove", this, false);
removeEvent(navToggle, "touchstart", this, false);
removeEvent(navToggle, "touchend", this, false);
removeEvent(navToggle, "mouseup", this, false);
removeEvent(navToggle, "keyup", this, false);
removeEvent(navToggle, "click", this, false);
if (!opts.customToggle) {
navToggle.parentNode.removeChild(navToggle);
} else {
navToggle.removeAttribute("aria-hidden");
}
},
/**
* Toggles the navigation open/close
*/
toggle: function() {
if (hasAnimFinished === true) {
if (!navOpen) {
this.open();
} else {
this.close();
}
}
},
/**
* Opens the navigation
*/
open: function() {
if (!navOpen) {
removeClass(nav, "closed");
addClass(nav, "opened");
addClass(htmlEl, opts.navActiveClass);
addClass(navToggle, "active");
nav.style.position = opts.openPos;
setAttributes(nav, {
"aria-hidden": "false"
});
navOpen = true;
opts.open();
}
},
/**
* Closes the navigation
*/
close: function() {
if (navOpen) {
addClass(nav, "closed");
removeClass(nav, "opened");
removeClass(htmlEl, opts.navActiveClass);
removeClass(navToggle, "active");
setAttributes(nav, {
"aria-hidden": "true"
});
// If animations are enabled, wait until they finish
if (opts.animate) {
hasAnimFinished = false;
setTimeout(function() {
nav.style.position = "absolute";
hasAnimFinished = true;
},
opts.transition + 10);
// Animations aren't enabled, we can do these immediately
} else {
nav.style.position = "absolute";
}
navOpen = false;
opts.close();
}
},
/**
* Resize is called on window resize and orientation change.
* It initializes the CSS styles and height calculations.
*/
resize: function() {
// Resize watches navigation toggle's display state
if (window.getComputedStyle(navToggle, null).getPropertyValue("display") !== "none") {
isMobile = true;
setAttributes(navToggle, {
"aria-hidden": "false"
});
// If the navigation is hidden
if (nav.className.match(/(^|\s)closed(\s|$)/)) {
setAttributes(nav, {
"aria-hidden": "true"
});
nav.style.position = "absolute";
}
this._createStyles();
this._calcHeight();
} else {
isMobile = false;
setAttributes(navToggle, {
"aria-hidden": "true"
});
setAttributes(nav, {
"aria-hidden": "false"
});
nav.style.position = opts.openPos;
this._removeStyles();
}
},
/**
* Takes care of all even handling
*
* @param {event} event
* @return {type} returns the type of event that should be used
*/
handleEvent: function(e) {
var evt = e || window.event;
switch (evt.type) {
case "touchstart":
this._onTouchStart(evt);
break;
case "touchmove":
this._onTouchMove(evt);
break;
case "touchend":
case "mouseup":
this._onTouchEnd(evt);
break;
case "click":
this._preventDefault(evt);
break;
case "keyup":
this._onKeyUp(evt);
break;
case "focus":
case "resize":
this.resize(evt);
break;
}
},
/**
* Initializes the widget
*/
_init: function() {
this.index = index++;
addClass(nav, opts.navClass);
addClass(nav, opts.navClass + "-" + this.index);
addClass(nav, "closed");
hasAnimFinished = true;
navOpen = false;
this._closeOnNavClick();
this._createToggle();
this._transitions();
this.resize();
/**
* On IE8 the resize event triggers too early for some reason
* so it's called here again on init to make sure all the
* calculated styles are correct.
*/
var self = this;
setTimeout(function() {
self.resize();
},
20);
addEvent(window, "resize", this, false);
addEvent(window, "focus", this, false);
addEvent(document.body, "touchmove", this, false);
addEvent(navToggle, "touchstart", this, false);
addEvent(navToggle, "touchend", this, false);
addEvent(navToggle, "mouseup", this, false);
addEvent(navToggle, "keyup", this, false);
addEvent(navToggle, "click", this, false);
/**
* Init callback here
*/
opts.init();
},
/**
* Creates Styles to the
*/
_createStyles: function() {
if (!styleElement.parentNode) {
styleElement.type = "text/css";
document.getElementsByTagName("head")[0].appendChild(styleElement);
}
},
/**
* Removes styles from the
*/
_removeStyles: function() {
if (styleElement.parentNode) {
styleElement.parentNode.removeChild(styleElement);
}
},
/**
* Creates Navigation Toggle
*/
_createToggle: function() {
// If there's no toggle, let's create one
if (!opts.customToggle) {
var toggle = document.createElement("a");
toggle.innerHTML = opts.label;
setAttributes(toggle, {
"href": "#",
"class": "nav-toggle"
});
// Determine where to insert the toggle
if (opts.insert === "after") {
nav.parentNode.insertBefore(toggle, nav.nextSibling);
} else {
nav.parentNode.insertBefore(toggle, nav);
}
navToggle = toggle;
// There is a toggle already, let's use that one
} else {
var toggleEl = opts.customToggle.replace("#", "");
if (document.getElementById(toggleEl)) {
navToggle = document.getElementById(toggleEl);
} else if (document.querySelector(toggleEl)) {
navToggle = document.querySelector(toggleEl);
} else {
throw new Error("The custom nav toggle you are trying to select doesn't exist");
}
}
},
/**
* Closes the navigation when a link inside is clicked.
*/
_closeOnNavClick: function() {
if (opts.closeOnNavClick) {
var links = nav.getElementsByTagName("a"),
self = this;
forEach(links,
function(i, el) {
addEvent(links[i], "click",
function() {
if (isMobile) {
self.toggle();
}
},
false);
});
}
},
/**
* Prevents the default functionality.
*
* @param {event} event
*/
_preventDefault: function(e) {
if (e.preventDefault) {
if (e.stopImmediatePropagation) {
e.stopImmediatePropagation();
}
e.preventDefault();
e.stopPropagation();
return false;
// This is strictly for old IE
} else {
e.returnValue = false;
}
},
/**
* On touch start we get the location of the touch.
*
* @param {event} event
*/
_onTouchStart: function(e) {
if (!Event.prototype.stopImmediatePropagation) {
this._preventDefault(e);
}
this.startX = e.touches[0].clientX;
this.startY = e.touches[0].clientY;
this.touchHasMoved = false;
/**
* Remove mouseup event completely here to avoid
* double triggering the event.
*/
removeEvent(navToggle, "mouseup", this, false);
},
/**
* Check if the user is scrolling instead of tapping.
*
* @param {event} event
*/
_onTouchMove: function(e) {
if (Math.abs(e.touches[0].clientX - this.startX) > 10 || Math.abs(e.touches[0].clientY - this.startY) > 10) {
this.touchHasMoved = true;
}
},
/**
* On touch end toggle the navigation.
*
* @param {event} event
*/
_onTouchEnd: function(e) {
this._preventDefault(e);
if (!isMobile) {
return;
}
// If the user isn't scrolling
if (!this.touchHasMoved) {
// If the event type is touch
if (e.type === "touchend") {
this.toggle();
return;
// Event type was click, not touch
} else {
var evt = e || window.event;
// If it isn't a right click, do toggling
if (! (evt.which === 3 || evt.button === 2)) {
this.toggle();
}
}
}
},
/**
* For keyboard accessibility, toggle the navigation on Enter
* keypress too.
*
* @param {event} event
*/
_onKeyUp: function(e) {
var evt = e || window.event;
if (evt.keyCode === 13) {
this.toggle();
}
},
/**
* Adds the needed CSS transitions if animations are enabled
*/
_transitions: function() {
if (opts.animate) {
var objStyle = nav.style,
transition = "max-height " + opts.transition + "ms";
objStyle.WebkitTransition = objStyle.MozTransition = objStyle.OTransition = objStyle.transition = transition;
}
},
/**
* Calculates the height of the navigation and then creates
* styles which are later added to the page
*/
_calcHeight: function() {
var savedHeight = 0;
for (var i = 0; i < nav.inner.length; i++) {
savedHeight += nav.inner[i].offsetHeight;
}
var innerStyles = "." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened{max-height:" + savedHeight + "px !important} ." + opts.jsClass + " ." + opts.navClass + "-" + this.index + ".opened.dropdown-active {max-height:9999px !important}";
if (styleElement.styleSheet) {
styleElement.styleSheet.cssText = innerStyles;
} else {
styleElement.innerHTML = innerStyles;
}
innerStyles = "";
}
};
/**
* Return new Responsive Nav
*/
return new ResponsiveNav(el, options);
};
if (typeof module !== "undefined" && module.exports) {
module.exports = responsiveNav;
} else {
window.responsiveNav = responsiveNav;
}
} (document, window, 0));
/* =======================================================================
* jQuery.placeholder.js 兼容性处理
* ======================================================================== */
!function(window, document, $) {
var isInputSupported = 'placeholder' in document.createElement('input');
var isTextareaSupported = 'placeholder' in document.createElement('textarea');
var prototype = $.fn;
var valHooks = $.valHooks;
var propHooks = $.propHooks;
var hooks;
var placeholder;
if (isInputSupported && isTextareaSupported) {
placeholder = prototype.placeholder = function() {
return this;
};
placeholder.input = placeholder.textarea = true;
} else {
placeholder = prototype.placeholder = function() {
var $this = this;
$this.filter((isInputSupported ? 'textarea': ':input') + '[placeholder]').not('.placeholder').on({
'focus.placeholder': clearPlaceholder,
'blur.placeholder': setPlaceholder
}).data('placeholder-enabled', true).trigger('blur.placeholder');
return $this;
};
placeholder.input = isInputSupported;
placeholder.textarea = isTextareaSupported;
hooks = {
'get': function(element) {
var $element = $(element);
var $passwordInput = $element.data('placeholder-password');
if ($passwordInput) {
return $passwordInput[0].value;
}
return $element.data('placeholder-enabled') && $element.hasClass('placeholder') ? '': element.value;
},
'set': function(element, value) {
var $element = $(element);
var $passwordInput = $element.data('placeholder-password');
if ($passwordInput) {
return $passwordInput[0].value = value;
}
if (!$element.data('placeholder-enabled')) {
return element.value = value;
}
if (value == '') {
element.value = value;
if (element != safeActiveElement()) {
setPlaceholder.call(element);
}
} else if ($element.hasClass('placeholder')) {
clearPlaceholder.call(element, true, value) || (element.value = value);
} else {
element.value = value;
}
return $element;
}
};
if (!isInputSupported) {
valHooks.input = hooks;
propHooks.value = hooks;
}
if (!isTextareaSupported) {
valHooks.textarea = hooks;
propHooks.value = hooks;
}
$(function() {
$(document).delegate('form', 'submit.placeholder',
function() {
var $inputs = $('.placeholder', this).each(clearPlaceholder);
setTimeout(function() {
$inputs.each(setPlaceholder);
},
10);
});
});
$(window).on('beforeunload.placeholder',
function() {
$('.placeholder').each(function() {
this.value = '';
});
});
}
function args(elem) {
var newAttrs = {};
var rinlinejQuery = /^jQuery\d+$/;
$.each(elem.attributes,
function(i, attr) {
if (attr.specified && !rinlinejQuery.test(attr.name)) {
newAttrs[attr.name] = attr.value;
}
});
return newAttrs;
}
function clearPlaceholder(event, value) {
var input = this;
var $input = $(input);
if (input.value == $input.attr('placeholder') && $input.hasClass('placeholder')) {
if ($input.data('placeholder-password')) {
$input = $input.hide().next().show().attr('id', $input.removeAttr('id').data('placeholder-id'));
if (event === true) {
return $input[0].value = value;
}
$input.focus();
} else {
input.value = '';
$input.removeClass('placeholder');
input == safeActiveElement() && input.select();
}
}
}
function setPlaceholder() {
var $replacement;
var input = this;
var $input = $(input);
var id = this.id;
if (input.value == '') {
if (input.type == 'password') {
if (!$input.data('placeholder-textinput')) {
try {
$replacement = $input.clone().prop('type', 'text');
} catch(e) {
$replacement = $('').prop($.extend(args(this), {
'type': 'text'
}));
}
$replacement.removeAttr('name').data({
'placeholder-password': $input,
'placeholder-id': id
}).on('focus.placeholder', clearPlaceholder);
$input.data({
'placeholder-textinput': $replacement,
'placeholder-id': id
}).before($replacement);
}
$input = $input.removeAttr('id').hide().prev().attr('id', id).show();
}
$input.addClass('placeholder');
$input[0].value = $input.attr('placeholder');
} else {
$input.removeClass('placeholder');
}
}
function safeActiveElement() {
try {
return document.activeElement;
} catch(exception) {}
}
} (this, document, jQuery);
/* =======================================================================
* jquery.emailsuggest.js v1.0 邮箱自动提示
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* ======================================================================== */
!function($) {
var
// 插件名
plugin = 'emailsuggest',
// 默认参数配置
defaults = {
sugClass: 'emailSug',
domains: ['163.com', '126.com', 'sohu.com', '139.com', 'sina.com', 'qq.com', 'gmail.com']
};
function EmailSug(elem, options) {
this.$field = $(elem);
this.options = $.extend(true, {},
defaults, options);
this._defaults = defaults;
this._domains = this.options.domains;
// 当前选中元素下标
this.selectedIndex = 0;
this.init();
}
EmailSug.prototype = {
init: function() {
this.addEvent();
},
addEvent: function() {
var that = this,
value;
this.$field.on('keyup.ema',
function(e) {
value = $.trim(this.value);
if (value) {
that.create(this, value);
that.doSelect(e.keyCode);
} else {
that.hide();
}
}).on('blur.ema',
function() {
setTimeout(function() {
that.hide();
},
200);
});
},
create: function(elem, value) {
var that = this,
arr, len, fragment, ul = [],
offset,
left,
top,
width,
height,
style,
// 左右边框
borderWidth = 2;
elem = $(elem);
offset = elem.offset();
width = elem.outerWidth(true) - borderWidth;
height = elem.outerHeight(true);
left = offset.left;
top = offset.top + height;
style = 'left: ' + left + 'px; top: ' + top + 'px; width: ' + width + 'px; border: 1px solid #e2e2e2; border-top: 0; display: none';
fragment = $('');
ul.push('
');
arr = this.filter(value, this._domains);
len = arr.length;
$.each(arr,
function(i, domain) {
var _class = that.options.sugClass + '-item';
if (that.selectedIndex > len - 1) {
if (i === 0) {
_class += ' active';
that.selectedIndex = 0;
}
} else {
if (i === that.selectedIndex) {
_class += ' active';
}
}
ul.push('
' + value.replace(/@.*/, '') + '@' + domain + '
');
});
ul.push('
');
ul = ul.join('');
if (this.$suggest) {
this.$suggest.empty();
this.$suggest.append(ul);
} else {
fragment.append(ul);
// 显示到页面
$('body').append(fragment);
this.$suggest = fragment;
this.$suggest.on('mouseenter click', '.' + this.options.sugClass + '-item',
function(e) {
var lis, li;
li = $(this);
lis = li.parent().children();
if (e.type === 'mouseenter') {
li.addClass('active').siblings().removeClass('active');
that.selectedIndex = $.inArray(this, lis);
} else {
// 当前选中
that.$field.val(lis.eq(that.selectedIndex).text());
// 隐藏email sug
that.hide();
}
});
}
this.show();
},
doSelect: function(keyCode) {
var elems = $('.' + this.options.sugClass + '-item', this.$suggest),
min = 0,
max = elems.length - 1;
switch (keyCode) {
case 13:
// 回车选中当前已选项
$('li.active', this.$suggest).trigger('click');
// 下标重置
this.selectedIndex = 0;
break;
// 向上
case 38:
this.selectedIndex--;
if (this.selectedIndex < min) {
this.selectedIndex = max;
}
elems.removeClass('active').eq(this.selectedIndex).addClass('active');
break;
// 向下
case 40:
this.selectedIndex++;
if (this.selectedIndex > max) {
this.selectedIndex = min;
}
elems.removeClass('active').eq(this.selectedIndex).addClass('active');
break;
default:
break;
}
},
filter: function(value, arr) {
var start, suffix, r = [];
start = value.indexOf('@');
if (start > -1) {
suffix = value.substring(start + 1);
$.each(arr,
function(i, str) {
if (str.indexOf(suffix) > -1) {
r.push(str);
}
});
} else {
r = arr;
}
return r;
},
show: function() {
if (this.$suggest) {
this.$suggest.show();
}
},
hide: function() {
if (this.$suggest) {
this.$suggest.hide();
}
}
}
$.fn[plugin] = function(options) {
return this.each(function() {
if (!$.data(this, plugin)) {
$.data(this, plugin, new EmailSug(this, options));
}
});
}
} (window.jQuery);
/* =======================================================================
* jQuery.Huispinner.js v2.1.2 微调器
* http://www.h-ui.net/
* Created & Modified by guojunhui
* Date modified 2017.06.26
*
* Copyright 2017 北京颖杰联创科技有限公司 All rights reserved.
* Licensed under MIT license.
* http://opensource.org/licenses/MIT
* ========================================================================*/
!function($) {
$.fn.Huispinner = function(options, callback) {
var defaults = {
value : 1,
minValue : 1,
maxValue : 999,
dis : 1,
}
var options = $.extend(defaults, options);
var keyCodes = {
up : 38,
down : 40
}
this.each(function() {
var that = $(this);
var str = '