Domanda

Voglio modificare il file supersized.3.1.3.core.min.js.

Ecco il codice (posizionato qui temporaneamente):

(function(a){a(document).ready(function(){a("body").prepend('<div id="supersized-loader"></div>').append('<div id="supersized"></div>')});a.supersized=function(b){var d={start_slide:1,vertical_center:0,horizontal_center:0,min_width:0,min_height:0,fit_portrait:0,fit_landscape:0,image_protect:1};var c=a("#supersized");if(b){var b=a.extend(d,b)}else{var b=a.extend(d)}if(b.start_slide){var f=b.start_slide-1}else{var f=Math.floor(Math.random()*b.slides.length)}a("<img/>").attr("src",b.slides[f].image).appendTo(c);c.hide();a(document).ready(function(){e()});a(window).load(function(){a("#supersized-loader").hide();c.fadeIn("fast");e()});a(window).resize(function(){e()});function e(){return c.each(function(){var g=a("img",c);a(g).each(function(){var i=(a(this).height()/a(this).width()).toFixed(2);thisSlide=a(this);var h=a(window).width();var k=a(window).height();var l;if((k<=b.min_height)&&(h<=b.min_width)){if((k/h)>i){b.fit_landscape&&i<=1?j(true):m(true)}else{b.fit_portrait&&i>1?m(true):j(true)}}else{if(h<=b.min_width){if((k/h)>i){b.fit_landscape&&i<=1?j(true):m()}else{b.fit_portrait&&i>1?m():j(true)}}else{if(k<=b.min_height){if((k/h)>i){b.fit_landscape&&i<=1?j():m(true)}else{b.fit_portrait&&i>1?m(true):j()}}else{if((k/h)>i){b.fit_landscape&&i<=1?j():m()}else{b.fit_portrait&&i>1?m():j()}}}}function j(n){if(n){if(thisSlide.width()<h||thisSlide.width()<b.min_width){if(thisSlide.width()*i>=b.min_height){thisSlide.width(b.min_width);thisSlide.height(thisSlide.width()*i)}else{m()}}}else{if(b.min_height>=k&&!b.fit_landscape){if(h*i>=b.min_height||(h*i>=b.min_height&&i<=1)){thisSlide.width(h);thisSlide.height(h*i)}else{if(i>1){thisSlide.height(b.min_height);thisSlide.width(thisSlide.height()/i)}else{if(thisSlide.width()<h){thisSlide.width(h);thisSlide.height(thisSlide.width()*i)}}}}else{thisSlide.width(h);thisSlide.height(h*i)}}}function m(n){if(n){if(thisSlide.height()<k){if(thisSlide.height()/i>=b.min_width){thisSlide.height(b.min_height);thisSlide.width(thisSlide.height()/i)}else{j(true)}}}else{if(b.min_width>=h){if(k/i>=b.min_width||i>1){thisSlide.height(k);thisSlide.width(k/i)}else{if(i<=1){thisSlide.width(b.min_width);thisSlide.height(thisSlide.width()*i)}}}else{thisSlide.height(k);thisSlide.width(k/i)}}}if(b.horizontal_center){a(this).css("left",(h-a(this).width())/2)}if(b.vertical_center){a(this).css("top",(k-a(this).height())/2)}});if(b.image_protect){a("img",c).bind("contextmenu",function(){return false});a("img",c).bind("mousedown",function(){return false})}return false})}}})(jQuery);

Voglio aggiungere la mia riga di codice personalizzata:

$('#content').delay('fast').fadeIn('slow');

All'interno di questo pezzo:

a(window).load(function(){a("#supersized-loader").hide();c.fadeIn("fast");e()});

Per far svanire il Div #Content in lentamente dopo che l'immagine di sfondo è sbiadita.

L'ho fatto nella versione non minimizzata, in questo modo:

    $(window).load(function(){

            $('#supersized-loader').hide();     //Hide loading animation
            element.fadeIn('fast');             //Fade in background

            resizenow();

$('#content').delay('fast').fadeIn('slow'); //my bit of code

        });

- ma mi piacerebbe molto sapere come fare lo stesso nel codice ridotto.

Apprezzerei un consiglio sapientemente!

È stato utile?

Soluzione

Puoi semplicemente apportare le modifiche alla versione not-min del file .js e quindi riputrirlo utilizzando uno dei numerosi strumenti Web. Poiché la versione .min è solo un file .js completo, dovresti essere a posto.

Eccone uno che è utile: http://dean.edwards.name/packer/

Altri suggerimenti

Perché non lavorare con il codice non minimizzato, aggiungere il tuo, testare tutto in modo soddisfacente e poi minimizzare di nuovo?

Naturalmente, puoi semplicemente spogliare lo spazio bianco fuori dal tuo fragionamento per inserire e collegarlo, cedendo

a(window).load(function(){a("#supersized-loader").hide();c.fadeIn("fast");e();a('#content').delay('fast').fadeIn('slow')});

Supponendo che e() è resizenow(), che è una supposizione ragionevole.

Hai provato

a(window).load(function(){a("#supersized-loader").hide();c.fadeIn("fast");$('#content').delay('fast').fadeIn('slow');e()});

Perché non limitarti a minimizzare la versione non compressa modificata?

vedere http://developer.yahoo.com/yui/compresor/ Per i dettagli su come.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top