working on it ...

Filters

Explore Public Snippets

Sort by

Found 8,195 snippets matching: jquery

    public by micurs modified Dec 23, 2013  747805  18  7  1

    JQuery typescript interface for $.ajax() callbacks

    To use JQuery $.ajax() you must define your callback functions with the following interfaces
    interface OnSuccessAjaxCallback {
      (data: any, textStatus?: string, jqXHR?: JQueryXHR): any;
    }
    interface OnErrorAjaxCallback {
      (jqXHR?: JQueryXHR, textStatus?: string, errorThrow?: string) : any;
    }
    

    public by pan modified Jan 17, 2015  312604  0  7  4

    CSS Regex Selector Extension For jQuery

    Using this extension enables regular expresions css selectors in jQuery
    /**
     * CSS Regex Selector Extension For jQuery
     * 
     */
    jQuery.expr[':'].regex = function(elem, index, match) {
       var matchParams = match[3].split(','),
           validLabels = /^(data|css):/,
           attr = {
               method: matchParams[0].match(validLabels) ?
                   matchParams[0].split(':')[0] : 'attr',
               property: matchParams.shift().replace(validLabels,'')
           },
           regexFlags = 'ig',
           regex = new RegExp(matchParams.join('').replace(/^\s+|\s+$/g,''), regexFlags);
       return regex.test(jQuery(elem)[attr.method](attr.property));
    }

    public by manolenso modified Oct 17, 2014  191631  0  4  0

    verification loading jquery

    verification loading jquery: app.coffee
    $ -> alert "jQuery est chargée!"
    
    
    

    public by HeathDernovich modified Aug 19, 2014  166435  0  4  0

    addClass function similar to Jquery

    addClass function similar to Jquery: addClass.js
    function addClass(node, class) {
    	if (!node.length) node = [node];
    	for (var n = 0, m = node.length; n < m; n++) {
    		if ((" " + node[n].className + " ").indexOf(" "+class+" ") >= 0) {
    			node.className += " " + class;
    		}
    	}
    }
    // apply myclass to all nodes
    addClass(document.getElementById("myelement"), "myclass");
    
    
    

    public by manolenso modified Oct 17, 2014  214720  0  4  0

    jquery1.7.2 cnd & fallback

    jquery1.7.2 cnd & fallback: untitled
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.
    js"></script>
    <script>window.jQuery || document.write('<script src="js/lib/
    jquery.js"><\/script>')
    </script>
    
    
    

    public by johansonkatherine modified May 8, 2014  219604  1  6  2

    C# Code Sample to Replace Multiple Texts inside PDF File Using Cloud API

    The following code sample shows how developers can replace multiple texts in a single API call in a PDF file using Aspose.Pdf for Cloud API in their applications. Developers can use Aspose REST API with any language: .NET, Java, PHP, Ruby, Rails, Python, jQuery and many more.
    AsposeApp.AppSID  = "77***********************************";
    AsposeApp.AppKey = "9a*******************************";
    
    //build URI
    stringstrURI = "http://api.aspose.com/v1.1/pdf/test.pdf/replaceTextList";
    
    //sign URI
    stringsignedURI = Utils.Sign(strURI);
    
    //build JSON to post
    TextReplace textReplace1 = new TextReplace();
    textReplace1.OldValue = "[!firm!]";
    textReplace1.NewValue = "Aspose";
    textReplace1.Regex = "false";
    
    //build JSON to post
    TextReplace textReplace2 = new TextReplace();
    textReplace2.OldValue = "[!client!]";
    textReplace2.NewValue = "Mark";
    textReplace2.Regex = "false";
    
    MultipleTextReplacestextReplaces = new MultipleTextReplaces();
    textReplaces.TextReplaces = new TextReplace[] { textReplace1, textReplace2 };
    stringstrJSON = JsonConvert.SerializeObject(textReplaces);
    Console.Write(strJSON);
    Utils.ProcessCommand(signedURI, "POST", strJSON);
    
    //build URI
    strURI = "http://api.aspose.com/v1.1/storage/file/test.pdf";
    
    //sign URI
    signedURI = Utils.Sign(strURI);
    
    Stream responseStream = Utils.ProcessCommand(signedURI, "GET");
    using (Stream fileStream = System.IO.File.OpenWrite(@"test.pdf"))
    {
    Utils.CopyStream(responseStream, fileStream);
    }
    responseStream.Close();
    
    //Following are required classes
    public class MultipleTextReplaces
        {
    publicTextReplace[] TextReplaces { get; set; }
        }
    public class TextReplace
        {
    publicTextReplace() { }
    
    public string OldValue { get; set; }
    public string NewValue { get; set; }
    public string Regex { get; set; }
    
        }
    

    public by micurs modified Oct 20, 2014  267752  11  7  1

    Check if Event was Triggered or Native

    You can easily add extra argument when triggering an event function programmatically in jquery. This way you can recognize if the event was triggered by a real mouse click rather than a direct call to the .click() function. As seen on http://css-tricks.com/snippets/jquery/check-if-event-was-triggered-or-native/
    $('button').click(function(event, wasTriggered) {
        if (wasTriggered) {
            alert('triggered in code');
        } else {
            alert('triggered by mouse');
        }
    });
    
    $('button').trigger('click', true);

    public by micurs modified Nov 2, 2014  6046  16  8  6

    Using promise() with JQuery animate

    With jQuery 1.5 the $.ajax implements the Promise interface. So you can use done() fail() and always() on the returned promise object returned from the ajax call. You can do the same when invoking the animate() function. The animate function returns the collection of elements the animate() is acting on, so you can create the promise explicitly
    // Shows an alert at the end of an animation.
    $('#myElement').animate( {  height: 200 + 'px'}, 500)
      .promise()
      .done( function () {
        alert('Animation complete!');
      });
    
    

    public by micurs modified Aug 10, 2014  2702  2  9  7

    Execute javascript code at the end of a CSS transition

    Using JQuery you can easily bind a function to any event. CSS transitions on a given element trigger different event depending on the browser. You can capture all or write a small function that select the one working on the current browser. Here is how (using typescript and underscore):
    function getBrowserTransitionEvent( el : JQuery ) : string {
      var transitions = [ 
        { name: 'transition', value: 'transitionend' },
        { name: 'OTransition', value: 'oTransitionEnd' },
        { name: 'MozTransition', value: 'transitionend' },
        { name: 'WebkitTransition', value: 'webkitTransitionEnd' } ];
      var HTMLElement e = el.get();
      var t = _.find< { name: string; value: string }>( transitions , 
          (t) => e.style[t.name] !== undefined);
      return t !== undefined ? t.value : '';
    }
    
    
    // Here is how to use this:
    $('#myElement').bind( getBrowserTransitionEvent($('#myElement')),
      function() {
        alert('CSS transision is complete');
      });

    public by sTiLL-iLL @ SniPitz-KND modified Dec 1, 2015  3427  0  7  19

    KachingFetch.js get it boy! woof! good dog....

    I modeled it after jquery's "getScript" only better.... cause it caches!!!
    
    // caching script fetcher  //
     
    var futrs = {};
     
     var ajaxFetch = function( url, cBak ) {
         if ( !futrs[ url ] ) {
             futrs[ url ] = $.Deferred(function( defer ) {
                 $.getScript( url )
                     .then( defer.resolve, defer.reject );
                 }).promise();
           }
         return futrs[ url ].done( cBak );
     };
     
    /*-----------------------------------------------------------------------*/
     
        // <<  use it! >>
      ajaxFetch('//totalPorn247.com/freeVideos/Tits+Ass?=199BOOBzInVIEW.js', cBak);
     
      function cBak(resp) {
          if(resp.length > 0) {
              var dd = document.querySelector('#resultDiv');
              dd.innerHTML = renderDirtyWords(a, z, 125);                        
          }  
      }
            
                
    • Public Snippets
    • Channels Snippets