/*-----------H-ui前端框架-------------
* H-ui.js v3.0.2
* http://www.h-ui.net/
* Created & Modified by guojunhui
* Date modified 2017-01.19
*
* 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.Spinner.js
jQuery.emailsuggest.js v1.0
jQuery.format.js
jQuery.togglePassword.js
jQuery.iCheck.js
jQuery.onePageNav.js
jQuery.stickUp.js
jQuery.HuiaddFavorite.js
jQuery.Huisethome.js
jQuery.Huisidenav.js
jQuery.Huihover.js
jQuery.Huifocusblur.js
jQuery.Huiselect.js
jQuery.Huitab.js
jQuery.Huifold.js
jQuery.Huitags.js
jQuery.Huitagsmixed.js
jQuery.Huitextarealength.js
jQuery.Huipreview.js
jQuery.Huimodalalert.js
jQuery.Huialert.js
jQuery.Huitotop.js
jQuery.Huimarquee.js
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.Spinner.js 微调器
* ========================================================================*/
!function($) {
$.fn.Spinner = function(opts) {
var defaults = {
value: 1,
min: 1,
len: 3,
max: 99
}
var options = $.extend(defaults, opts);
var keyCodes = {
up: 38,
down: 40
}
return this.each(function() {
var a = $('');
f(a, 0, "decrease", "-"); //加
var c = $('');
f(c, 0, "increase", "+"); //减
var b = $('');
f(b, 1, "amount input-text");
cv(0); //值
$(this).append(a).append(b).append(c);
a.click(function() {
cv( - 1)
});
b.keyup(function() {
cv(0)
});
c.click(function() {
cv( + 1)
});
b.on('keyup paste change',
function(e) {
e.keyCode == keyCodes.up && cv( + 1);
e.keyCode == keyCodes.down && cv( - 1);
});
function cv(n) {
b.val(b.val().replace(/[^\d]/g, ''));
bv = parseInt(b.val() || options.min) + n;
bv >= options.min && bv <= options.max && b.val(bv);
if (bv <= options.min) {
b.val(options.min);
f(a, 2, "disDe", "decrease");
} else {
f(a, 2, "decrease", "disDe");
}
if (bv >= options.max) {
b.val(options.max);
f(c, 2, "disIn", "Increase");
} else {
f(c, 2, "increase", "disIn");
}
}
});
function f(o, t, c, s) {
t == 0 && o.addClass(c).attr("href", "javascript:void(0)").append("").find("i").append(s);
t == 1 && o.addClass(c).attr({
"value": options.value,
"autocomplete": "off",
"maxlength": options.len
});
t == 2 && o.addClass(c).removeClass(s);
}
}
} (window.jQuery);
/* =======================================================================
* jQuery.format.js 金额格式化
* ========================================================================*/
!function($) {
$.extend({
format: function(str, step, splitor) {
str = str.toString();
var len = str.length;
if (len > step) {
var l1 = len % step,
l2 = parseInt(len / step),
arr = [],
first = str.substr(0, l1);
if (first != '') {
arr.push(first);
};
for (var i = 0; i < l2; i++) {
arr.push(str.substr(l1 + i * step, step));
};
str = arr.join(splitor);
};
return str;
}
});
} (window.jQuery);
/* =======================================================================
* jquery.togglePassword.js 隐藏显示密码
* type="password"
* ========================================================================*/
!function($) {
$.fn.togglePassword = function(options) {
var s = $.extend($.fn.togglePassword.defaults, options),
input = $(this);
$(s.el).on(s.ev,
function() {
"password" == $(input).attr("type") ? $(input).attr("type", "text") : $(input).attr("type", "password");
});
};
$.fn.togglePassword.defaults = {
ev: "click"
};
} (window.jQuery);
/* =======================================================================
* jQuery.iCheck.js v1.0.2, http://git.io/arlzeA
* Powerful jQuery and Zepto plugin for checkboxes and radio buttons customization
*
* (c) 2013 Damir Sultanov, http://fronteed.com
* MIT Licensed
* ======================================================================== */
!(function($) {
// Cached vars
var _iCheck = 'iCheck',
_iCheckHelper = _iCheck + '-helper',
_checkbox = 'checkbox',
_radio = 'radio',
_checked = 'checked',
_unchecked = 'un' + _checked,
_disabled = 'disabled',
_determinate = 'determinate',
_indeterminate = 'in' + _determinate,
_update = 'update',
_type = 'type',
_click = 'click',
_touch = 'touchbegin.i touchend.i',
_add = 'addClass',
_remove = 'removeClass',
_callback = 'trigger',
_label = 'label',
_cursor = 'cursor',
_mobile = /ipad|iphone|ipod|android|blackberry|windows phone|opera mini|silk/i.test(navigator.userAgent);
// Plugin init
$.fn[_iCheck] = function(options, fire) {
// Walker
var handle = 'input[type="' + _checkbox + '"], input[type="' + _radio + '"]',
stack = $(),
walker = function(object) {
object.each(function() {
var self = $(this);
if (self.is(handle)) {
stack = stack.add(self);
} else {
stack = stack.add(self.find(handle));
}
});
};
// Check if we should operate with some method
if (/^(check|uncheck|toggle|indeterminate|determinate|disable|enable|update|destroy)$/i.test(options)) {
// Normalize method's name
options = options.toLowerCase();
// Find checkboxes and radio buttons
walker(this);
return stack.each(function() {
var self = $(this);
if (options == 'destroy') {
tidy(self, 'ifDestroyed');
} else {
operate(self, true, options);
}
// Fire method's callback
if ($.isFunction(fire)) {
fire();
}
});
// Customization
} else if (typeof options == 'object' || !options) {
// Check if any options were passed
var settings = $.extend({
checkedClass: _checked,
disabledClass: _disabled,
indeterminateClass: _indeterminate,
labelHover: true
},
options),
selector = settings.handle,
hoverClass = settings.hoverClass || 'hover',
focusClass = settings.focusClass || 'focus',
activeClass = settings.activeClass || 'active',
labelHover = !!settings.labelHover,
labelHoverClass = settings.labelHoverClass || 'hover',
// Setup clickable area
area = ('' + settings.increaseArea).replace('%', '') | 0;
// Selector limit
if (selector == _checkbox || selector == _radio) {
handle = 'input[type="' + selector + '"]';
}
// Clickable area limit
if (area < -50) {
area = -50;
}
// Walk around the selector
walker(this);
return stack.each(function() {
var self = $(this);
// If already customized
tidy(self);
var node = this,
id = node.id,
// Layer styles
offset = -area + '%',
size = 100 + (area * 2) + '%',
layer = {
position: 'absolute',
top: offset,
left: offset,
display: 'block',
width: size,
height: size,
margin: 0,
padding: 0,
background: '#fff',
border: 0,
opacity: 0
},
// Choose how to hide input
hide = _mobile ? {
position: 'absolute',
visibility: 'hidden'
}: area ? layer: {
position: 'absolute',
opacity: 0
},
// Get proper class
className = node[_type] == _checkbox ? settings.checkboxClass || 'i' + _checkbox: settings.radioClass || 'i' + _radio,
// Find assigned labels
label = $(_label + '[for="' + id + '"]').add(self.closest(_label)),
// Check ARIA option
aria = !!settings.aria,
// Set ARIA placeholder
ariaID = _iCheck + '-' + Math.random().toString(36).substr(2, 6),
// Parent & helper
parent = '')[_callback]('ifCreated').parent().append(settings.insert);
// Layer addition
helper = $('').css(layer).appendTo(parent);
// Finalize customization
self.data(_iCheck, {
o: settings,
s: self.attr('style')
}).css(hide); !! settings.inheritClass && parent[_add](node.className || ''); !! settings.inheritID && id && parent.attr('id', _iCheck + '-' + id);
parent.css('position') == 'static' && parent.css('position', 'relative');
operate(self, true, _update);
// Label events
if (label.length) {
label.on(_click + '.i mouseover.i mouseout.i ' + _touch,
function(event) {
var type = event[_type],
item = $(this);
// Do nothing if input is disabled
if (!node[_disabled]) {
// Click
if (type == _click) {
if ($(event.target).is('a')) {
return;
}
operate(self, false, true);
// Hover state
} else if (labelHover) {
// mouseout|touchend
if (/ut|nd/.test(type)) {
parent[_remove](hoverClass);
item[_remove](labelHoverClass);
} else {
parent[_add](hoverClass);
item[_add](labelHoverClass);
}
}
if (_mobile) {
event.stopPropagation();
} else {
return false;
}
}
});
}
// Input events
self.on(_click + '.i focus.i blur.i keyup.i keydown.i keypress.i',
function(event) {
var type = event[_type],
key = event.keyCode;
// Click
if (type == _click) {
return false;
// Keydown
} else if (type == 'keydown' && key == 32) {
if (! (node[_type] == _radio && node[_checked])) {
if (node[_checked]) {
off(self, _checked);
} else {
on(self, _checked);
}
}
return false;
// Keyup
} else if (type == 'keyup' && node[_type] == _radio) { ! node[_checked] && on(self, _checked);
// Focus/blur
} else if (/us|ur/.test(type)) {
parent[type == 'blur' ? _remove: _add](focusClass);
}
});
// Helper events
helper.on(_click + ' mousedown mouseup mouseover mouseout ' + _touch,
function(event) {
var type = event[_type],
// mousedown|mouseup
toggle = /wn|up/.test(type) ? activeClass: hoverClass;
// Do nothing if input is disabled
if (!node[_disabled]) {
// Click
if (type == _click) {
operate(self, false, true);
// Active and hover states
} else {
// State is on
if (/wn|er|in/.test(type)) {
// mousedown|mouseover|touchbegin
parent[_add](toggle);
// State is off
} else {
parent[_remove](toggle + ' ' + activeClass);
}
// Label hover
if (label.length && labelHover && toggle == hoverClass) {
// mouseout|touchend
label[/ut|nd/.test(type) ? _remove: _add](labelHoverClass);
}
}
if (_mobile) {
event.stopPropagation();
} else {
return false;
}
}
});
});
} else {
return this;
}
};
// Do something with inputs
function operate(input, direct, method) {
var node = input[0],
state = /er/.test(method) ? _indeterminate: /bl/.test(method) ? _disabled: _checked,
active = method == _update ? {
checked: node[_checked],
disabled: node[_disabled],
indeterminate: input.attr(_indeterminate) == 'true' || input.attr(_determinate) == 'false'
}: node[state];
// Check, disable or indeterminate
if (/^(ch|di|in)/.test(method) && !active) {
on(input, state);
// Uncheck, enable or determinate
} else if (/^(un|en|de)/.test(method) && active) {
off(input, state);
// Update
} else if (method == _update) {
// Handle states
for (var each in active) {
if (active[each]) {
on(input, each, true);
} else {
off(input, each, true);
}
}
} else if (!direct || method == 'toggle') {
// Helper or label was clicked
if (!direct) {
input[_callback]('ifClicked');
}
// Toggle checked state
if (active) {
if (node[_type] !== _radio) {
off(input, state);
}
} else {
on(input, state);
}
}
}
// Add checked, disabled or indeterminate state
function on(input, state, keep) {
var node = input[0],
parent = input.parent(),
checked = state == _checked,
indeterminate = state == _indeterminate,
disabled = state == _disabled,
callback = indeterminate ? _determinate: checked ? _unchecked: 'enabled',
regular = option(input, callback + capitalize(node[_type])),
specific = option(input, state + capitalize(node[_type]));
// Prevent unnecessary actions
if (node[state] !== true) {
// Toggle assigned radio buttons
if (!keep && state == _checked && node[_type] == _radio && node.name) {
var form = input.closest('form'),
inputs = 'input[name="' + node.name + '"]';
inputs = form.length ? form.find(inputs) : $(inputs);
inputs.each(function() {
if (this !== node && $(this).data(_iCheck)) {
off($(this), state);
}
});
}
// Indeterminate state
if (indeterminate) {
// Add indeterminate state
node[state] = true;
// Remove checked state
if (node[_checked]) {
off(input, _checked, 'force');
}
// Checked or disabled state
} else {
// Add checked or disabled state
if (!keep) {
node[state] = true;
}
// Remove indeterminate state
if (checked && node[_indeterminate]) {
off(input, _indeterminate, false);
}
}
// Trigger callbacks
callbacks(input, checked, state, keep);
}
// Add proper cursor
if (node[_disabled] && !!option(input, _cursor, true)) {
parent.find('.' + _iCheckHelper).css(_cursor, 'default');
}
// Add state class
parent[_add](specific || option(input, state) || '');
// Set ARIA attribute
if ( !! parent.attr('role') && !indeterminate) {
parent.attr('aria-' + (disabled ? _disabled: _checked), 'true');
}
// Remove regular state class
parent[_remove](regular || option(input, callback) || '');
}
// Remove checked, disabled or indeterminate state
function off(input, state, keep) {
var node = input[0],
parent = input.parent(),
checked = state == _checked,
indeterminate = state == _indeterminate,
disabled = state == _disabled,
callback = indeterminate ? _determinate: checked ? _unchecked: 'enabled',
regular = option(input, callback + capitalize(node[_type])),
specific = option(input, state + capitalize(node[_type]));
// Prevent unnecessary actions
if (node[state] !== false) {
// Toggle state
if (indeterminate || !keep || keep == 'force') {
node[state] = false;
}
// Trigger callbacks
callbacks(input, checked, callback, keep);
}
// Add proper cursor
if (!node[_disabled] && !!option(input, _cursor, true)) {
parent.find('.' + _iCheckHelper).css(_cursor, 'pointer');
}
// Remove state class
parent[_remove](specific || option(input, state) || '');
// Set ARIA attribute
if ( !! parent.attr('role') && !indeterminate) {
parent.attr('aria-' + (disabled ? _disabled: _checked), 'false');
}
// Add regular state class
parent[_add](regular || option(input, callback) || '');
}
// Remove all traces
function tidy(input, callback) {
if (input.data(_iCheck)) {
// Remove everything except input
input.parent().html(input.attr('style', input.data(_iCheck).s || ''));
// Callback
if (callback) {
input[_callback](callback);
}
// Unbind events
input.off('.i').unwrap();
$(_label + '[for="' + input[0].id + '"]').add(input.closest(_label)).off('.i');
}
}
// Get some option
function option(input, state, regular) {
if (input.data(_iCheck)) {
return input.data(_iCheck).o[state + (regular ? '': 'Class')];
}
}
// Capitalize some string
function capitalize(string) {
return string.charAt(0).toUpperCase() + string.slice(1);
}
// Executable handlers
function callbacks(input, checked, callback, keep) {
if (!keep) {
if (checked) {
input[_callback]('ifToggled');
}
input[_callback]('ifChanged')[_callback]('if' + capitalize(callback));
}
}
})(window.jQuery || window.Zepto);
/* =======================================================================
* jQuery.raty.js v2.4.5- A Star Rating Plugin
* -------------------------------------------------------------------
* jQuery Raty is a plugin that generates a customizable star rating.
* Licensed under The MIT License
*
* @version 2.4.5
* @since 2010.06.11
* @author Washington Botelho
* @documentation wbotelhos.com/raty
* @twitter twitter.com/wbotelhos
*
* Usage:
* -------------------------------------------------------------------
* $('#star').raty();
*
* ======================================================================== */
!(function($) {
var methods = {
init: function(settings) {
return this.each(function() {
var self = this,
$this = $(self).empty();
self.opt = $.extend(true, {},
$.fn.raty.defaults, settings);
$this.data('settings', self.opt);
self.opt.number = methods.between(self.opt.number, 0, 20);
if (self.opt.path.substring(self.opt.path.length - 1, self.opt.path.length) != '/') {
self.opt.path += '/';
}
if (typeof self.opt.score == 'function') {
self.opt.score = self.opt.score.call(self);
}
if (self.opt.score) {
self.opt.score = methods.between(self.opt.score, 0, self.opt.number);
}
for (var i = 1; i <= self.opt.number; i++) {
$('', {
src: self.opt.path + ((!self.opt.score || self.opt.score < i) ? self.opt.starOff: self.opt.starOn),
alt: i,
title: (i <= self.opt.hints.length && self.opt.hints[i - 1] !== null) ? self.opt.hints[i - 1] : i
}).appendTo(self);
if (self.opt.space) {
$this.append((i < self.opt.number) ? '': '');
}
}
self.stars = $this.children('img:not(".raty-cancel")');
self.score = $('', {
type: 'hidden',
name: self.opt.scoreName
}).appendTo(self);
if (self.opt.score && self.opt.score > 0) {
self.score.val(self.opt.score);
methods.roundStar.call(self, self.opt.score);
}
if (self.opt.iconRange) {
methods.fill.call(self, self.opt.score); }
methods.setTarget.call(self, self.opt.score, self.opt.targetKeep);
var space = self.opt.space ? 4 : 0,
width = self.opt.width || (self.opt.number * self.opt.size + self.opt.number * space);
if (self.opt.cancel) {
self.cancel = $('', {
src: self.opt.path + self.opt.cancelOff,
alt: 'x',
title: self.opt.cancelHint,
'class': 'raty-cancel'
});
if (self.opt.cancelPlace == 'left') {
//$this.prepend(' ').prepend(self.cancel);
} else {
//$this.append(' ').append(self.cancel);
}
width += (self.opt.size + space);
}
if (self.opt.readOnly) {
methods.fixHint.call(self);
if (self.cancel) {
self.cancel.hide();
}
} else {
$this.css('cursor', 'pointer');
methods.bindAction.call(self);
}
//$this.css('width', width);
});
},
between: function(value, min, max) {
return Math.min(Math.max(parseFloat(value), min), max);
},
bindAction: function() {
var self = this,
$this = $(self);
$this.mouseleave(function() {
var score = self.score.val() || undefined;
methods.initialize.call(self, score);
methods.setTarget.call(self, score, self.opt.targetKeep);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, score);
}
});
var action = self.opt.half ? 'mousemove': 'mouseover';
if (self.opt.cancel) {
self.cancel.mouseenter(function() {
$(this).attr('src', self.opt.path + self.opt.cancelOn);
self.stars.attr('src', self.opt.path + self.opt.starOff);
methods.setTarget.call(self, null, true);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, null);
}
}).mouseleave(function() {
$(this).attr('src', self.opt.path + self.opt.cancelOff);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, self.score.val() || null);
}
}).click(function(evt) {
self.score.removeAttr('value');
if (self.opt.click) {
self.opt.click.call(self, null, evt);
}
});
}
self.stars.bind(action,
function(evt) {
var value = parseInt(this.alt, 10);
if (self.opt.half) {
var position = parseFloat((evt.pageX - $(this).offset().left) / self.opt.size),
diff = (position > .5) ? 1 : .5;
value = parseFloat(this.alt) - 1 + diff;
methods.fill.call(self, value);
if (self.opt.precision) {
value = value - diff + position;
}
methods.showHalf.call(self, value);
} else {
methods.fill.call(self, value);
}
$this.data('score', value);
methods.setTarget.call(self, value, true);
if (self.opt.mouseover) {
self.opt.mouseover.call(self, value, evt);
}
}).click(function(evt) {
self.score.val((self.opt.half || self.opt.precision) ? $this.data('score') : this.alt);
if (self.opt.click) {
self.opt.click.call(self, self.score.val(), evt);
}
});
},
cancel: function(isClick) {
return $(this).each(function() {
var self = this,
$this = $(self);
if ($this.data('readonly') === true) {
return this;
}
if (isClick) {
methods.click.call(self, null);
} else {
methods.score.call(self, null);
}
self.score.removeAttr('value');
});
},
click: function(score) {
return $(this).each(function() {
if ($(this).data('readonly') === true) {
return this;
}
methods.initialize.call(this, score);
if (this.opt.click) {
this.opt.click.call(this, score);
} else {
methods.error.call(this, 'you must add the "click: function(score, evt) { }" callback.');
}
methods.setTarget.call(this, score, true);
});
},
error: function(message) {
$(this).html(message);
$.error(message);
},
fill: function(score) {
var self = this,
number = self.stars.length,
count = 0,
$star, star, icon;
for (var i = 1; i <= number; i++) {
$star = self.stars.eq(i - 1);
if (self.opt.iconRange && self.opt.iconRange.length > count) {
star = self.opt.iconRange[count];
if (self.opt.single) {
icon = (i == score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
} else {
icon = (i <= score) ? (star.on || self.opt.starOn) : (star.off || self.opt.starOff);
}
if (i <= star.range) {
$star.attr('src', self.opt.path + icon);
}
if (i == star.range) {
count++;
}
} else {
if (self.opt.single) {
icon = (i == score) ? self.opt.starOn: self.opt.starOff;
} else {
icon = (i <= score) ? self.opt.starOn: self.opt.starOff;
}
$star.attr('src', self.opt.path + icon);
}
}
},
fixHint: function() {
var $this = $(this),
score = parseInt(this.score.val(), 10),
hint = this.opt.noRatedMsg;
if (!isNaN(score) && score > 0) {
hint = (score <= this.opt.hints.length && this.opt.hints[score - 1] !== null) ? this.opt.hints[score - 1] : score;
}
$this.data('readonly', true).css('cursor', 'default').attr('title', hint);
this.score.attr('readonly', 'readonly');
this.stars.attr('title', hint);
},
getScore: function() {
var score = [],
value;
$(this).each(function() {
value = this.score.val();
score.push(value ? parseFloat(value) : undefined);
});
return (score.length > 1) ? score: score[0];
},
readOnly: function(isReadOnly) {
return this.each(function() {
var $this = $(this);
if ($this.data('readonly') === isReadOnly) {
return this;
}
if (this.cancel) {
if (isReadOnly) {
this.cancel.hide();
} else {
this.cancel.show();
}
}
if (isReadOnly) {
$this.unbind();
$this.children('img').unbind();
methods.fixHint.call(this);
} else {
methods.bindAction.call(this);
methods.unfixHint.call(this);
}
$this.data('readonly', isReadOnly);
});
},
reload: function() {
return methods.set.call(this, {});
},
roundStar: function(score) {
var diff = (score - Math.floor(score)).toFixed(2);
if (diff > this.opt.round.down) {
var icon = this.opt.starOn; // Full up: [x.76 .. x.99]
if (diff < this.opt.round.up && this.opt.halfShow) { // Half: [x.26 .. x.75]
icon = this.opt.starHalf;
} else if (diff < this.opt.round.full) { // Full down: [x.00 .. x.5]
icon = this.opt.starOff;
}
this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + icon);
} // Full down: [x.00 .. x.25]
},
score: function() {
return arguments.length ? methods.setScore.apply(this, arguments) : methods.getScore.call(this);
},
set: function(settings) {
this.each(function() {
var $this = $(this),
actual = $this.data('settings'),
clone = $this.clone().removeAttr('style').insertBefore($this);
$this.remove();
clone.raty($.extend(actual, settings));
});
return $(this.selector);
},
setScore: function(score) {
return $(this).each(function() {
if ($(this).data('readonly') === true) {
return this;
}
methods.initialize.call(this, score);
methods.setTarget.call(this, score, true);
});
},
setTarget: function(value, isKeep) {
if (this.opt.target) {
var $target = $(this.opt.target);
if ($target.length == 0) {
methods.error.call(this, '目标选择器无效或丢失!');
}
var score = value;
if (!isKeep || score === undefined) {
score = this.opt.targetText;
} else {
if (this.opt.targetType == 'hint') {
score = (score === null && this.opt.cancel) ? this.opt.cancelHint: this.opt.hints[Math.ceil(score - 1)];
} else {
score = this.opt.precision ? parseFloat(score).toFixed(1) : parseInt(score, 10);
}
}
if (this.opt.targetFormat.indexOf('{score}') < 0) {
methods.error.call(this, '模版 "{score}" 找不到!');
}
if (value !== null) {
score = this.opt.targetFormat.toString().replace('{score}', score);
}
if ($target.is(':input')) {
$target.val(score);
} else {
$target.html(score);
}
}
},
showHalf: function(score) {
var diff = (score - Math.floor(score)).toFixed(1);
if (diff > 0 && diff < .6) {
this.stars.eq(Math.ceil(score) - 1).attr('src', this.opt.path + this.opt.starHalf);
}
},
initialize: function(score) {
score = !score ? 0 : methods.between(score, 0, this.opt.number);
methods.fill.call(this, score);
if (score > 0) {
if (this.opt.halfShow) {
methods.roundStar.call(this, score);
}
this.score.val(score);
}
},
unfixHint: function() {
for (var i = 0; i < this.opt.number; i++) {
this.stars.eq(i).attr('title', (i < this.opt.hints.length && this.opt.hints[i] !== null) ? this.opt.hints[i] : i);
}
$(this).data('readonly', false).css('cursor', 'pointer').removeAttr('title');
this.score.attr('readonly', 'readonly');
}
};
$.fn.raty = function(method) {
if (methods[method]) {
return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
} else if (typeof method === 'object' || !method) {
return methods.init.apply(this, arguments);
} else {
$.error('方法 ' + method + ' 不存在!');
}
};
$.fn.raty.defaults = {
cancel: false,
cancelHint: '取消评级!',
cancelOff: 'cancel-off.png',
cancelOn: 'cancel-on.png',
cancelPlace: 'left',
click: undefined,
half: false,
halfShow: true,
hints: ['10', '20', '30', '40', '50', '60', '70', '80', '90', '100'],
iconRange: undefined,
mouseover: undefined,
noRatedMsg: '没有额定',
number: 10,
path: 'images/',
precision: false,
round: {
down: .25,
full: .6,
up: .76
},
readOnly: false,
score: undefined,
scoreName: 'score',
single: false,
size: 16,
space: true,
starHalf: 'star-half.png',
starOff: 'star-off.png',
starOn: 'star-on.png',
target: undefined,
targetFormat: '{score}',
targetKeep: false,
targetText: '',
targetType: 'hint',
width: undefined
};
})(jQuery);
/* =======================================================================
* jQuery.onePageNav.js v0.9One Page Nav Plugin
* http://github.com/davist11/jQuery-One-Page-Nav
* Copyright (c) 2010 Trevor Davis (http://trevordavis.net)
* Dual licensed under the MIT and GPL licenses.
* Uses the same license as jQuery, see:
* http://jquery.org/license
* Example usage:
* $('#nav').onePageNav({
* currentClass: 'current',
* changeHash: false,
* scrollSpeed: 750
* });
* ========================================================================*/
!(function($) {
$.fn.onePageNav = function(options) {
var opts = $.extend({},
$.fn.onePageNav.defaults, options),
onePageNav = {};
onePageNav.sections = {};
onePageNav.bindNav = function($el, $this, o) {
var $par = $el.parent(),
newLoc = $el.attr('href'),
$win = $(window);
if (!$par.hasClass(o.currentClass)) {
if (o.begin) {
o.begin();
}
onePageNav.adjustNav($this, $par, o.currentClass);
$win.unbind('.onePageNav');
$.scrollTo(newLoc, o.scrollSpeed, {
easing: o.easing,
offset: {
top: -o.scrollOffset
},
onAfter: function() {
if (o.changeHash) {
window.location.hash = newLoc;
}
$win.bind('scroll.onePageNav',
function() {
onePageNav.scrollChange($this, o);
});
if (o.end) {
o.end();
}
}
});
}
};
onePageNav.adjustNav = function($this, $el, curClass) {
$this.find('.' + curClass).removeClass(curClass);
$el.addClass(curClass);
};
onePageNav.getPositions = function($this, o) {
var $nav = $this.find('a');
if (o.filter !== '') {
$nav = $nav.filter(o.filter);
}
$nav.each(function() {
var linkHref = $(this).attr('href'),
divPos = $(linkHref).offset(),
topPos = divPos.top;
onePageNav.sections[linkHref.substr(1)] = Math.round(topPos) - o.scrollOffset;
});
};
onePageNav.getSection = function(windowPos, o) {
var returnValue = '',
windowHeight = Math.round($(window).height() * o.scrollThreshold);
for (var section in onePageNav.sections) {
if ((onePageNav.sections[section] - windowHeight) < windowPos) {
returnValue = section;
}
}
return returnValue;
};
onePageNav.scrollChange = function($this, o) {
onePageNav.getPositions($this, o);
var windowTop = $(window).scrollTop(),
position = onePageNav.getSection(windowTop, o);
if (position !== '') {
onePageNav.adjustNav($this, $this.find('a[href=#' + position + ']').parent(), o.currentClass);
}
};
onePageNav.init = function($this, o) {
var didScroll = false,
$nav = $this.find('a');
if (o.filter !== '') {
$nav = $nav.filter(o.filter);
}
$nav.bind('click',
function(e) {
onePageNav.bindNav($(this), $this, o);
e.preventDefault();
});
onePageNav.getPositions($this, o);
$(window).bind('scroll.onePageNav',
function() {
didScroll = true;
});
setInterval(function() {
if (didScroll) {
didScroll = false;
onePageNav.scrollChange($this, o);
}
},
250);
};
return this.each(function() {
var $this = $(this),
o = $.meta ? $.extend({},
opts, $this.data()) : opts;
onePageNav.init($this, o);
});
};
// default options
$.fn.onePageNav.defaults = {
currentClass: 'current',
changeHash: false,
easing: 'swing',
filter: '',
scrollSpeed: 750,
scrollOffset: 0,
scrollThreshold: 0.5,
begin: false,
end: false
};
})(jQuery);
/* =======================================================================
* jquery.HuiaddFavorite.js 添加收藏
* 收藏本站
* function shoucang(name,site){
$.addFavorite({
name:name,
site:site,
});
* ========================================================================*/
function HuiaddFavorite(obj) {
obj.site = obj.site || window.location.href;
obj.name = obj.name || document.title;
try {
window.external.addFavorite(obj.site, obj.name);
} catch(e) {
try {
window.sidebar.addPanel(name, site, "");
} catch(e) {
$.Huimodalalert("加入收藏失败,请使用Ctrl+D进行添加", 2000);
}
}
}
/* ========================================================================
* jQuery.Huisethome.js 设为首页
* ======================================================================== */
function Huisethome(obj){
try{
obj.style.behavior="url(#default#homepage)";
obj.setHomePage(webSite);
}
catch(e){
if(window.netscape){
try {
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
}
catch(e){
$.Huimodalalert("此操作被浏览器拒绝!\n请在浏览器地址栏输入\"about:config\"并回车\n然后将 [signed.applets.codebase_principal_support]的值设置为'true',双击即可。",2000);
}
var prefs = Components.classes['@mozilla.org/preferences-service;1'].getService(Components.interfaces.nsIPrefBranch);
prefs.setCharPref('browser.startup.homepage',url);
}
}
}
/* =======================================================================
* jQuery.Huisidenav.js 左侧菜单-隐藏显示
* ======================================================================== */
function displaynavbar(obj){
if($(obj).hasClass("open")){
$(obj).removeClass("open");
$("body").removeClass("big-page");
} else {
$(obj).addClass("open");
$("body").addClass("big-page");
}
}
/* =======================================================================
* jQuery.Huihover.js 得到失去焦点
* ========================================================================*/
!function($) {
$.Huihover = function(obj) {
$(obj).hover(function() {
$(this).addClass("hover");
},
function() {
$(this).removeClass("hover");
});
}
} (window.jQuery);
/* =======================================================================
* jQuery.Huifocusblur.js 得到失去焦点
* ========================================================================*/
!function($) {
$.Huifocusblur = function(obj) {
$(obj).focus(function() {
$(this).addClass("focus").removeClass("inputError");
});
$(obj).blur(function() {
$(this).removeClass("focus");
});
}
} (window.jQuery);
$(function() {
/*****表单*****/
$.Huifocusblur(".input-text,.textarea");
});
/* =======================================================================
* jQuery.Huiselect.js 选择
* ========================================================================*/
!function($) {
$.Huiselect = function(divselectid, inputselectid) {
var inputselect = $(inputselectid);
$(divselectid + " cite").click(function() {
var ul = $(divselectid + " ul");
ul.slideToggle();
});
$(divselectid + " ul li a").click(function() {
var txt = $(this).text();
$(divselectid + " cite").html(txt);
var value = $(this).attr("selectid");
inputselect.val(value);
$(divselectid + " ul").hide();
});
$(document).click(function() {
$(divselectid + " ul").hide();
});
};
} (window.jQuery);
/* =======================================================================
* jQuery.Huitab.js 选项卡
* ========================================================================*/
!function($) {
$.Huitab = function(tabBar, tabCon, class_name, tabEvent, i) {
var $tab_menu = $(tabBar);
// 初始化操作
$tab_menu.removeClass(class_name);
$(tabBar).eq(i).addClass(class_name);
$(tabCon).hide();
$(tabCon).eq(i).show();
$tab_menu.on(tabEvent,
function() {
$tab_menu.removeClass(class_name);
$(this).addClass(class_name);
var index = $tab_menu.index(this);
$(tabCon).hide();
$(tabCon).eq(index).show();
});
}
} (window.jQuery);
/* =======================================================================
* jQuery.Huifold.js 折叠
* ========================================================================*/
!function($) {
$.Huifold = function(obj, obj_c, speed, obj_type, Event) {
if (obj_type == 2) {
$(obj + ":first").find("b").html("-");
$(obj_c + ":first").show();
}
$(obj).on(Event,
function() {
if ($(this).next().is(":visible")) {
if (obj_type == 2) {
return false;
} else {
$(this).next().slideUp(speed).end().removeClass("selected");
if ($(this).find("b")) {
$(this).find("b").html("+");
}
}
} else {
if (obj_type == 3) {
$(this).next().slideDown(speed).end().addClass("selected");
if ($(this).find("b")) {
$(this).find("b").html("-");
}
} else {
$(obj_c).slideUp(speed);
$(obj).removeClass("selected");
if ($(this).find("b")) {
$(obj).find("b").html("+");
}
$(this).next().slideDown(speed).end().addClass("selected");
if ($(this).find("b")) {
$(this).find("b").html("-");
}
}
}
});
}
} (window.jQuery);
/* =======================================================================
* jQuery.Huitags.js 标签
* ========================================================================*/
!function($) {
/*tag标签*/
var time1;
$(".Hui-tags-lable").show();
$(".Hui-tags-input").val("");
$(document).on("blur", ".Hui-tags-input",
function() {
time1 = setTimeout(function() {
$(this).parents(".Hui-tags").find(".Hui-tags-list").slideUp();
},
400);
});
$(document).on("focus", ".Hui-tags-input",
function() {
clearTimeout(time1);
});
$(document).on("click", ".Hui-tags-input",
function() {
$(this).find(".Hui-tags-input").focus();
$(this).find(".Hui-tags-list").slideDown();
});
function gettagval(obj) {
var str = "";
var token = $(obj).parents(".Hui-tags").find(".Hui-tags-token");
if (token.length < 1) {
$(obj).parents(".Hui-tags").find(".Hui-tags-val").val("");
return false;
}
for (var i = 0; i < token.length; i++) {
str += token.eq(i).text() + ",";
$(obj).parents(".Hui-tags").find(".Hui-tags-val").val(str);
}
}
$(document).on("keydown", ".Hui-tags-input",
function(event) {
$(this).next().hide();
var v = $(this).val().replace(/\s+/g, "");
var reg = /^,|,$/gi;
v = v.replace(reg, "");
v = $.trim(v);
var token = $(this).parents(".Hui-tags").find(".Hui-tags-token");
if (v != '') {
if (event.keyCode == 13 || event.keyCode == 108 || event.keyCode == 32) {
$('' + v + '').insertBefore($(this).parents(".Hui-tags").find(".Hui-tags-iptwrap"));
$(this).val("");
gettagval(this);
}
} else {
if (event.keyCode == 8) {
if (token.length >= 1) {
$(this).parents(".Hui-tags").find(".Hui-tags-token:last").remove();
gettagval(this);
} else {
$(this).parents(".Hui-tags").find(".Hui-tags-lable").show();
return false;
}
}
}
});
$(document).on("click", ".Hui-tags-has span",
function() {
var taghasV = $(this).text();
taghasV = taghasV.replace(/(^\s*)|(\s*$)/g, "");
$('' + taghasV + '').insertBefore($(this).parents(".Hui-tags").find(".Hui-tags-iptwrap"));
gettagval(this);
$(this).parents(".Hui-tags").find(".Hui-tags-input").focus();
});
$(document).on("click", ".Hui-tags-token",
function() {
var token = $(this).parents(".Hui-tags").find(".Hui-tags-token");
var it = $(this).parents(".Hui-tags");
$(this).remove();
switch (token.length) {
case 1:
it.find(".Hui-tags-lable").show();
break;
}
var str = "";
var token = it.find(".Hui-tags-token");
if (token.length < 1) {
it.find(".Hui-tags-val").val("");
return false;
}
for (var i = 0; i < token.length; i++) {
str += token.eq(i).text() + ",";
it.find(".Hui-tags-val").val(str);
}
});
} (window.jQuery);
/* =======================================================================
* jQuery.Huitagsmixed.js 标签混排效果
* ========================================================================*/
!function($) {
$.Huitagsmixed = function(obj) {
$(obj).each(function() {
var x = 9;
var y = 0;
var rand = parseInt(Math.random() * (x - y + 1) + y);
$(this).addClass("tags" + rand);
});
}
} (window.jQuery);
/* =======================================================================
* jQuery.Huitextarealength.js 字数限制
* ========================================================================*/
!function($) {
$.Huitextarealength = function(obj, maxlength) {
var v = $(obj).val();
var l = v.length;
if (l > maxlength) {
v = v.substring(0, maxlength);
$(obj).val(v);
}
$(obj).parent().find(".textarea-length").text(v.length);
}
} (window.jQuery);
/* =======================================================================
* jQuery.Huipreview.js 图片预览
* ========================================================================*/
!function($) {
$.Huipreview = function(obj) {
/*图片预览*/
$(obj).hover(function() {
$(this).addClass("active");
$("#tooltip-preview").remove();
var winW = $(window).width();
var winW5 = winW / 2;
this.myTitle = this.title;
this.title = "";
var midimg = $(this).attr('data-preview');
if (midimg == '') {
return false;
} else {
var imgT = $(this).parents(".imgItem").offset().top;
var imgL = $(this).parents(".imgItem").offset().left;
var imgW = $(this).parents(".imgItem").width();
var imgH = $(this).parents(".imgItem").height();
var ww = (imgL + imgW / 2);
if (ww < winW5) {
var tooltipLeft = (imgW + imgL) + "px";
} else {
var tooltipRight = (winW - imgL) + "px";
}
var tooltip_keleyi_com = "