Updated.
This commit is contained in:
1 parent
913e895de9
commit
e541d53b3b
6 files changed
+480
-136
No files matched your search
+111
-1
@@ -1,3 +1,106 @@
|
||||
/* dataset polyfill for IE < 11 */
|
||||
(function datasetModule(global, definition) { // non-exporting module magic dance
|
||||
'use strict';
|
||||
|
||||
var
|
||||
amd = 'amd',
|
||||
exports = 'exports'; // keeps the method names for CommonJS / AMD from being compiled to single character variable
|
||||
|
||||
if (typeof define === 'function' && define[amd]) {
|
||||
define(function definer() {
|
||||
return definition(global);
|
||||
});
|
||||
} else if (typeof module === 'function' && module[exports]) {
|
||||
module[exports] = definition(global);
|
||||
} else {
|
||||
definition(global);
|
||||
}
|
||||
}(this, function datasetPolyfill(global) {
|
||||
'use strict';
|
||||
|
||||
var
|
||||
attribute,
|
||||
attributes,
|
||||
counter,
|
||||
dash,
|
||||
dataRegEx,
|
||||
document = global.document,
|
||||
hasEventListener,
|
||||
length,
|
||||
match,
|
||||
mutationSupport,
|
||||
test = document.createElement('_'),
|
||||
DOMAttrModified = 'DOMAttrModified';
|
||||
|
||||
function clearDataset(event) {
|
||||
delete event.target._datasetCache;
|
||||
}
|
||||
|
||||
function toCamelCase(string) {
|
||||
return string.replace(dash, function (m, letter) {
|
||||
return letter.toUpperCase();
|
||||
});
|
||||
}
|
||||
|
||||
function getDataset() {
|
||||
var
|
||||
dataset = {};
|
||||
|
||||
attributes = this.attributes;
|
||||
for (counter = 0, length = attributes.length; counter < length; counter += 1) {
|
||||
attribute = attributes[counter];
|
||||
match = attribute.name.match(dataRegEx);
|
||||
if (match) {
|
||||
dataset[toCamelCase(match[1])] = attribute.value;
|
||||
}
|
||||
}
|
||||
|
||||
return dataset;
|
||||
}
|
||||
|
||||
function mutation() {
|
||||
if (hasEventListener) {
|
||||
test.removeEventListener(DOMAttrModified, mutation, false);
|
||||
} else {
|
||||
test.detachEvent('on' + DOMAttrModified, mutation);
|
||||
}
|
||||
|
||||
mutationSupport = true;
|
||||
}
|
||||
|
||||
if (test.dataset !== undefined) {
|
||||
return;
|
||||
}
|
||||
|
||||
dash = /\-([a-z])/ig;
|
||||
dataRegEx = /^data\-(.+)/;
|
||||
hasEventListener = !!document.addEventListener;
|
||||
mutationSupport = false;
|
||||
|
||||
if (hasEventListener) {
|
||||
test.addEventListener(DOMAttrModified, mutation, false);
|
||||
} else {
|
||||
test.attachEvent('on' + DOMAttrModified, mutation);
|
||||
}
|
||||
|
||||
// trigger event (if supported)
|
||||
test.setAttribute('foo', 'bar');
|
||||
|
||||
Object.defineProperty(global.Element.prototype, 'dataset', {
|
||||
get: mutationSupport
|
||||
? function get() {
|
||||
if (!this._datasetCache) {
|
||||
this._datasetCache = getDataset.call(this);
|
||||
}
|
||||
|
||||
return this._datasetCache;
|
||||
} : getDataset
|
||||
});
|
||||
|
||||
if (mutationSupport && hasEventListener) { // < IE9 supports neither
|
||||
document.addEventListener(DOMAttrModified, clearDataset, false);
|
||||
}
|
||||
}));
|
||||
$.fn.size= function(){
|
||||
return this.length;
|
||||
}
|
||||
@@ -8,6 +111,7 @@ $.fn.find= function( selector ) {
|
||||
var i, ret,
|
||||
len = this.length,
|
||||
self = this;
|
||||
|
||||
if ( typeof selector !== "string" ) {
|
||||
return this.pushStack( jQuery( selector ).filter( function() {
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
@@ -17,6 +121,7 @@ $.fn.find= function( selector ) {
|
||||
}
|
||||
} ) );
|
||||
}
|
||||
|
||||
ret = this.pushStack( [] );
|
||||
if (selector != '\#'){
|
||||
for ( i = 0; i < len; i++ ) {
|
||||
@@ -26,8 +131,10 @@ $.fn.find= function( selector ) {
|
||||
else{
|
||||
jQuery.find( document, self[ i ], ret );
|
||||
}
|
||||
|
||||
return len > 1 ? jQuery.uniqueSort( ret ) : ret;
|
||||
}
|
||||
|
||||
$.event.props = ( "altKey bubbles cancelable ctrlKey currentTarget detail eventPhase " +
|
||||
"metaKey relatedTarget shiftKey target timeStamp view which" ).split( " " )
|
||||
$.fn.load= function( url, params, callback ){
|
||||
@@ -70,9 +177,11 @@ function migrateWarnFunc( obj, prop, newFunc, msg ) {
|
||||
};
|
||||
}
|
||||
if ( jQuery.ajax ) {
|
||||
|
||||
var oldAjax = jQuery.ajax;
|
||||
jQuery.ajax = function( ) {
|
||||
var jQXHR = oldAjax.apply( this, arguments );
|
||||
|
||||
// Be sure we got a jQXHR (e.g., not sync)
|
||||
if ( jQXHR.promise ) {
|
||||
migrateWarnFunc( jQXHR, "success", jQXHR.done,
|
||||
@@ -82,13 +191,14 @@ if ( jQuery.ajax ) {
|
||||
migrateWarnFunc( jQXHR, "complete", jQXHR.always,
|
||||
"jQXHR.complete is deprecated and removed" );
|
||||
}
|
||||
|
||||
return jQXHR;
|
||||
};
|
||||
}
|
||||
$(function(){
|
||||
$('input[type!="checkbox"],textarea').not('[type="submit"],[type=radio]').on('focus', function() {
|
||||
$([document.documentElement, document.body]).animate({
|
||||
scrollTop: $(this).offset().top -200
|
||||
scrollTop: $(this).offset().top -$(window).outerHeight()/2
|
||||
}, 100);
|
||||
});
|
||||
$.each($('input[type="text"][placeholder]'),function(i,v){
|
||||
|
||||
Reference in new issue
Block a user