jquery_drapper 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
| @@ -1,70 +1,72 @@ | |
| 1 | 
            -
            (function($) {
         | 
| 1 | 
            +
            (function ($) {
         | 
| 2 2 | 
             
              $.drappers = $.extend($.drappers, {
         | 
| 3 | 
            -
                autocomplete: function() {
         | 
| 4 | 
            -
                  if(!$.isFunction($.fn.sortable)) {
         | 
| 5 | 
            -
                    throw "Jquery plugin '$.fn.tokenInput' hasn't been required. "
         | 
| 6 | 
            -
             | 
| 3 | 
            +
                autocomplete: function () {
         | 
| 4 | 
            +
                  if (!$.isFunction($.fn.sortable)) {
         | 
| 5 | 
            +
                    throw "Jquery plugin '$.fn.tokenInput' hasn't been required. " +
         | 
| 6 | 
            +
                          "Check http://loopj.com/jquery-tokeninput/ ";
         | 
| 7 7 | 
             
                  }
         | 
| 8 8 |  | 
| 9 | 
            -
                  if(!this.isDecoree) {
         | 
| 10 | 
            -
                    throw "The object is not decoree!"
         | 
| 11 | 
            -
             | 
| 9 | 
            +
                  if (!this.isDecoree) {
         | 
| 10 | 
            +
                    throw "The object is not decoree!" +
         | 
| 11 | 
            +
                          "See https://github.com/aratak/jquery.drapper/ for details.";
         | 
| 12 12 | 
             
                  }
         | 
| 13 13 |  | 
| 14 14 | 
             
                  var decoree = this;
         | 
| 15 15 |  | 
| 16 | 
            -
                  var getData = function(selectSelected) {
         | 
| 17 | 
            -
                    return $(decoree).find('option' + (selectSelected ? '[selected]' : '')).map(function() {
         | 
| 16 | 
            +
                  var getData = function (selectSelected) {
         | 
| 17 | 
            +
                    return $(decoree).find('option' + (selectSelected ? '[selected]' : '')).map(function () {
         | 
| 18 18 | 
             
                      return {
         | 
| 19 19 | 
             
                        id: $(this).val(),
         | 
| 20 20 | 
             
                        queue: $(this).attr('data-drapper-keywords'),
         | 
| 21 21 | 
             
                        hint: $(this).attr('data-drapper-hint'),
         | 
| 22 22 | 
             
                        value: $(this).html()
         | 
| 23 | 
            -
                      }
         | 
| 23 | 
            +
                      };
         | 
| 24 24 | 
             
                    });
         | 
| 25 | 
            -
                  }
         | 
| 25 | 
            +
                  };
         | 
| 26 26 |  | 
| 27 | 
            -
                  var getOptionByItem = function(item) {
         | 
| 28 | 
            -
                    return $(decoree).find('option[value=' + item['id'] + ']')
         | 
| 29 | 
            -
                  }
         | 
| 27 | 
            +
                  var getOptionByItem = function (item) {
         | 
| 28 | 
            +
                    return $(decoree).find('option[value=' + item['id'] + ']');
         | 
| 29 | 
            +
                  };
         | 
| 30 30 |  | 
| 31 | 
            -
                  var optionsToTokenInput = function() {
         | 
| 31 | 
            +
                  var optionsToTokenInput = function () {
         | 
| 32 32 | 
             
                    return $.extend({
         | 
| 33 33 | 
             
                      theme: 'facebook',
         | 
| 34 34 | 
             
                      propertyToSearch: "queue",
         | 
| 35 | 
            -
                      resultsFormatter: function(item) { return "<li>" + item.hint + "</li>" },
         | 
| 36 | 
            -
                      tokenFormatter: function(item) { return "<li>" + item.value + "</li>" },
         | 
| 35 | 
            +
                      resultsFormatter: function (item) { return "<li>" + item.hint + "</li>"; },
         | 
| 36 | 
            +
                      tokenFormatter: function (item) { return "<li>" + item.value + "</li>"; },
         | 
| 37 37 | 
             
                      preventDuplicates: true,
         | 
| 38 38 | 
             
                      hintText: "Type in a search term",
         | 
| 39 | 
            -
                      onAdd: function(item) {
         | 
| 40 | 
            -
                         | 
| 39 | 
            +
                      onAdd: function (item) {
         | 
| 40 | 
            +
                        getOptionByItem(item).attr('selected', 'selected');
         | 
| 41 | 
            +
                        $(decoree).trigger('change');
         | 
| 41 42 | 
             
                      },
         | 
| 42 | 
            -
                      onDelete: function(item) {
         | 
| 43 | 
            -
                         | 
| 43 | 
            +
                      onDelete: function (item) {
         | 
| 44 | 
            +
                        getOptionByItem(item).removeAttr('selected');
         | 
| 45 | 
            +
                        $(decoree).trigger('change');
         | 
| 44 46 | 
             
                      },
         | 
| 45 47 | 
             
                      prePopulate: getData(true)
         | 
| 46 48 | 
             
                    }, decoree.config);
         | 
| 47 | 
            -
                  }
         | 
| 49 | 
            +
                  };
         | 
| 48 50 |  | 
| 49 | 
            -
                  var tokenInput = function() {
         | 
| 50 | 
            -
                    var findTokenInput = function() {
         | 
| 51 | 
            +
                  var tokenInput = function () {
         | 
| 52 | 
            +
                    var findTokenInput = function () {
         | 
| 51 53 | 
             
                      decoree.wrapper().find('input[data-drapper-autocomplete-container]');
         | 
| 52 | 
            -
                    }
         | 
| 53 | 
            -
                    var createTokenInput = function() {
         | 
| 54 | 
            +
                    };
         | 
| 55 | 
            +
                    var createTokenInput = function () {
         | 
| 54 56 | 
             
                      return $(document.createElement('input')).attr({
         | 
| 55 57 | 
             
                        'type': 'text',
         | 
| 56 58 | 
             
                        'data-drapper-autocomplete-container': true
         | 
| 57 59 | 
             
                      }).appendTo(decoree.wrapper());
         | 
| 58 | 
            -
                    }
         | 
| 60 | 
            +
                    };
         | 
| 59 61 | 
             
                    return findTokenInput() || createTokenInput();
         | 
| 60 | 
            -
                  }
         | 
| 62 | 
            +
                  };
         | 
| 61 63 |  | 
| 62 | 
            -
                  var hideDecoree = function() {
         | 
| 64 | 
            +
                  var hideDecoree = function () {
         | 
| 63 65 | 
             
                    $(decoree).css({
         | 
| 64 66 | 
             
                      visibility: 'hidden',
         | 
| 65 67 | 
             
                      position: 'absolute',
         | 
| 66 68 | 
             
                      zIndex: -1
         | 
| 67 | 
            -
                    })
         | 
| 69 | 
            +
                    });
         | 
| 68 70 | 
             
                    return true;
         | 
| 69 71 | 
             
                  };
         | 
| 70 72 |  | 
| @@ -72,5 +74,5 @@ | |
| 72 74 | 
             
                  $(tokenInput()).tokenInput(getData(), optionsToTokenInput());
         | 
| 73 75 | 
             
                }
         | 
| 74 76 | 
             
              });
         | 
| 75 | 
            -
            } | 
| 77 | 
            +
            }(jQuery));
         | 
| 76 78 |  | 
    
        metadata
    CHANGED
    
    | @@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version | |
| 5 5 | 
             
              segments: 
         | 
| 6 6 | 
             
              - 0
         | 
| 7 7 | 
             
              - 0
         | 
| 8 | 
            -
              -  | 
| 9 | 
            -
              version: 0.0. | 
| 8 | 
            +
              - 6
         | 
| 9 | 
            +
              version: 0.0.6
         | 
| 10 10 | 
             
            platform: ruby
         | 
| 11 11 | 
             
            authors: 
         | 
| 12 12 | 
             
            - Alexey Osipenko
         | 
| @@ -14,7 +14,7 @@ autorequire: | |
| 14 14 | 
             
            bindir: bin
         | 
| 15 15 | 
             
            cert_chain: []
         | 
| 16 16 |  | 
| 17 | 
            -
            date: 2012-03- | 
| 17 | 
            +
            date: 2012-03-20 00:00:00 +02:00
         | 
| 18 18 | 
             
            default_executable: 
         | 
| 19 19 | 
             
            dependencies: 
         | 
| 20 20 | 
             
            - !ruby/object:Gem::Dependency 
         |