javascript - Extends zepto with jQuery.cssHooks() method -
i want use zepto instead jquery... replace in web jquery zepto including script
script window.jquery = zepto
inn peace of code
color.hook = function( hook ) { var hooks = hook.split( " " ); each( hooks, function( i, hook ) { console.dir(jquery.csshooks) // gives me undefined jquery.csshooks[ hook ] = { set: function( elem, value ) { console.log('es') var parsed, curelem, backgroundcolor = ""; if ( value !== "transparent" && ( jquery.type( value ) !== "string" || ( parsed = stringparse( value ) ) ) ) { value = color( parsed || value ); if ( !support.rgba && value._rgba[ 3 ] !== 1 ) { curelem = hook === "backgroundcolor" ? elem.parentnode : elem; while ( (backgroundcolor === "" || backgroundcolor === "transparent") && curelem && curelem.style ) { try { backgroundcolor = jquery.css( curelem, "backgroundcolor" ); curelem = curelem.parentnode; } catch ( e ) { } } value = value.blend( backgroundcolor && backgroundcolor !== "transparent" ? backgroundcolor : "_default" ); } value = value.torgbastring(); } try { elem.style[ hook ] = value; } catch( e ) { // wrapped prevent ie throwing errors on "invalid" values 'auto' or 'inherit' } } }; jquery.fx.step[ hook ] = function( fx ) { if ( !fx.colorinit ) { fx.start = color( fx.elem, hook ); fx.end = color( fx.end ); fx.colorinit = true; } jquery.csshooks[ hook ].set( fx.elem, fx.start.transition( fx.end, fx.pos ) ); }; }); };
i have error
uncaught typeerror: cannot set property 'backgroundcolor' of undefined
this
$.csshooks // gives me undefined
in jquery found extend
jquery.extend({ // add in style property hooks overriding default // behavior of getting , setting style property csshooks: { opacity: { get: function( elem, computed ) { if ( computed ) { // should number opacity var ret = curcss( elem, "opacity" ); return ret === "" ? "1" : ret; } } } },
how can implement csshooks jquery in zepto???
tnx
edit 2
i found posible solution problem implement ccshooks myself
jquery.csshooks= { opacity: { get: function( elem, computed ) { if ( computed ) { var ret = curcss( elem, "opacity" ); return ret === "" ? "1" : ret; } } } }; jquery.fx.step = {}; jquery.easing = { linear: function( p ) { return p; }, swing: function( p ) { return 0.5 - math.cos( p*math.pi ) / 2; } }; var originalqsa = jquery.zepto.qsa; $.zepto.qsa = function(el, sel) { try { return originalqsa.apply(this, arguments) } catch(e) { console.error("invalid css selector: ", sel) return [] } }
this extends zepto csshooks. event handler cause problem
$('#menu a').click(function() { var name=$(this).attr('id'); var div=$('div#'+name); var visible=$('#container').find(':visible').attr('id'); $('div#'+visible).css({position:'absolute'}).hide('slide',{direction:'left'},1000,function() { $(div).css({position:'relative'}).show('slide',{direction:'right'},1000,function(){resetsizegmaps()}); }); });
but trace error try/catch ive been created
invalid css selector: :visible
can fix csshooks??
Comments
Post a Comment