app/jquery/jquery-editable-1.3.3.js
author Sverre Rabbelier <srabbelier@gmail.com>
Mon, 14 Sep 2009 20:19:46 +0200
changeset 2920 afeac06aabb2
parent 2420 645f4de26f99
permissions -rw-r--r--
Set new Melange version number to 0-5-20090914 in app.yaml.template.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2420
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     1
(function($){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     2
/*
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     3
 * Editable 1.3.3
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     4
 *
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     5
 * Copyright (c) 2009 Arash Karimzadeh (arashkarimzadeh.com)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     6
 * Licensed under the MIT (MIT-LICENSE.txt)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     7
 * http://www.opensource.org/licenses/mit-license.php
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     8
 *
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
     9
 * Date: Mar 02 2009
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    10
 */
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    11
$.fn.editable = function(options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    12
  var defaults = {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    13
    onEdit: null,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    14
    onSubmit: null,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    15
    onCancel: null,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    16
    editClass: null,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    17
    submit: null,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    18
    cancel: null,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    19
    type: 'text', //text, textarea or select
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    20
    submitBy: 'blur', //blur,change,dblclick,click
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    21
    editBy: 'click',
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    22
    options: null
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    23
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    24
  if(options=='disable')
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    25
    return this.unbind(this.data('editable.options').editBy,this.data('editable.options').toEditable);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    26
  if(options=='enable')
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    27
    return this.bind(this.data('editable.options').editBy,this.data('editable.options').toEditable);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    28
  if(options=='destroy')
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    29
    return  this.unbind(this.data('editable.options').editBy,this.data('editable.options').toEditable)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    30
          .data('editable.previous',null)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    31
          .data('editable.current',null)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    32
          .data('editable.options',null);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    33
  
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    34
  var options = $.extend(defaults, options);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    35
  
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    36
  options.toEditable = function(){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    37
    $this = $(this);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    38
    $this.data('editable.current',$this.html());
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    39
    opts = $this.data('editable.options');
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    40
    $.editableFactory[opts.type].toEditable($this.empty(),opts);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    41
    // Configure events,styles for changed content
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    42
    $this.data('editable.previous',$this.data('editable.current'))
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    43
       .children()
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    44
         .focus()
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    45
         .addClass(opts.editClass);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    46
    // Submit Event
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    47
    if(opts.submit){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    48
      $('<button/>').appendTo($this)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    49
            .html(opts.submit)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    50
            .one('mouseup',function(){opts.toNonEditable($(this).parent(),true)});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    51
}else
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    52
      $this.one(opts.submitBy,function(){opts.toNonEditable($(this),true)})
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    53
         .children()
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    54
           .one(opts.submitBy,function(){opts.toNonEditable($(this).parent(),true)});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    55
    // Cancel Event
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    56
    if(opts.cancel)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    57
      $('<button/>').appendTo($this)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    58
            .html(opts.cancel)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    59
            .one('mouseup',function(){opts.toNonEditable($(this).parent(),false)});
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    60
    // Call User Function
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    61
    if($.isFunction(opts.onEdit))
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    62
      opts.onEdit.apply(  $this,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    63
                  [{
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    64
                    current:$this.data('editable.current'),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    65
                    previous:$this.data('editable.previous')
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    66
}]
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    67
                );
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    68
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    69
  options.toNonEditable = function($this,change){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    70
    opts = $this.data('editable.options');
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    71
    // Configure events,styles for changed content
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    72
    $this.one(opts.editBy,opts.toEditable)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    73
       .data( 'editable.current',
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    74
            change
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    75
            ?$.editableFactory[opts.type].getValue($this,opts)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    76
  :$this.data('editable.current')
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    77
          )
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    78
       .html(
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    79
            opts.type=='password'
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    80
               ?'*****'
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    81
  :$this.data('editable.current')
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    82
          );
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    83
    // Call User Function
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    84
    var func = null;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    85
    if($.isFunction(opts.onSubmit)&&change==true)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    86
      func = opts.onSubmit;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    87
    else if($.isFunction(opts.onCancel)&&change==false)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    88
      func = opts.onCancel;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    89
    if(func!=null)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    90
      func.apply($this,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    91
            [{
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    92
              current:$this.data('editable.current'),
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    93
              previous:$this.data('editable.previous')
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    94
}]
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    95
          );
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    96
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    97
  this.data('editable.options',options);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    98
  return  this.one(options.editBy,options.toEditable);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
    99
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   100
$.editableFactory = {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   101
  'text': {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   102
    toEditable: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   103
      $('<input/>').appendTo($this)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   104
             .val($this.data('editable.current'));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   105
},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   106
    getValue: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   107
      return $this.children().val();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   108
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   109
},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   110
  'password': {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   111
    toEditable: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   112
      $this.data('editable.current',$this.data('editable.password'));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   113
      $this.data('editable.previous',$this.data('editable.password'));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   114
      $('<input type="password"/>').appendTo($this)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   115
                     .val($this.data('editable.current'));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   116
},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   117
    getValue: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   118
      $this.data('editable.password',$this.children().val());
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   119
      return $this.children().val();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   120
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   121
},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   122
  'textarea': {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   123
    toEditable: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   124
      $('<textarea/>').appendTo($this)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   125
              .val($this.data('editable.current'));
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   126
},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   127
    getValue: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   128
      return $this.children().val();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   129
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   130
},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   131
  'select': {
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   132
    toEditable: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   133
      $select = $('<select/>').appendTo($this);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   134
      $.each( options.options,
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   135
          function(key,value){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   136
            $('<option/>').appendTo($select)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   137
                  .html(value)
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   138
                  .attr('value',key);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   139
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   140
           )
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   141
      $select.children().each(
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   142
        function(){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   143
          var opt = $(this);
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   144
          if(opt.text()==$this.data('editable.current'))
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   145
            return opt.attr('selected', 'selected').text();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   146
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   147
      )
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   148
},
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   149
    getValue: function($this,options){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   150
      var item = null;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   151
      $('select', $this).children().each(
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   152
        function(){
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   153
          if($(this).attr('selected'))
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   154
            return item = $(this).text();
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   155
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   156
      )
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   157
      return item;
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   158
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   159
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   160
}
645f4de26f99 Patch that adds the JS and CSS files for surveys.
Daniel Diniz <ajaksu@gmail.com>
parents:
diff changeset
   161
})(jQuery);