Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 3634

Show
Ignore:
Timestamp:
02/22/06 09:59:22 (3 years ago)
Author:
madrobby
Message:

Update script.aculo.us to V1.5.3 [Thomas Fuchs]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/actionpack/CHANGELOG

    r3626 r3634  
    11*SVN* 
     2 
     3* Update script.aculo.us to V1.5.3 [Thomas Fuchs] 
    24 
    35* Added various InPlaceEditor options, #3746, #3891, #3896, #3906 [Bill Burcham, ruairi, sl33p3r] 
  • trunk/actionpack/lib/action_view/helpers/javascripts/controls.js

    r3378 r3634  
    317317Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { 
    318318  initialize: function(element, update, url, options) { 
    319          this.baseInitialize(element, update, options); 
     319    this.baseInitialize(element, update, options); 
    320320    this.options.asynchronous  = true; 
    321321    this.options.onComplete    = this.onComplete.bind(this); 
     
    484484      highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor, 
    485485      highlightendcolor: "#FFFFFF", 
    486       externalControl: null, 
     486      externalControl: null, 
    487487      submitOnBlur: false, 
    488       ajaxOptions: {} 
     488      ajaxOptions: {}, 
     489      evalScripts: false 
    489490    }, options || {}); 
    490491 
     
    555556      okButton.type = "submit"; 
    556557      okButton.value = this.options.okText; 
     558      okButton.className = 'editor_ok_button'; 
    557559      this.form.appendChild(okButton); 
    558560    } 
     
    563565      cancelLink.appendChild(document.createTextNode(this.options.cancelText)); 
    564566      cancelLink.onclick = this.onclickCancel.bind(this); 
     567      cancelLink.className = 'editor_cancel';       
    565568      this.form.appendChild(cancelLink); 
    566569    } 
     
    591594      textField.value = text; 
    592595      textField.style.backgroundColor = this.options.highlightcolor; 
     596      textField.className = 'editor_field'; 
    593597      var size = this.options.size || this.options.cols || 0; 
    594598      if (size != 0) textField.size = size; 
     
    604608      textArea.rows = this.options.rows; 
    605609      textArea.cols = this.options.cols || 40; 
     610      textArea.className = 'editor_field';       
    606611      if (this.options.submitOnBlur) 
    607612        textArea.onblur = this.onSubmit.bind(this); 
     
    656661    this.onLoading(); 
    657662     
    658     new Ajax.Updater( 
    659       {  
    660         success: this.element, 
    661          // don't update on failure (this could be an option) 
    662         failure: null 
    663       }, 
    664       this.url, 
    665       Object.extend({ 
    666         parameters: this.options.callback(form, value), 
    667         onComplete: this.onComplete.bind(this), 
    668         onFailure: this.onFailure.bind(this) 
    669       }, this.options.ajaxOptions) 
    670     ); 
     663    if (this.options.evalScripts) { 
     664      new Ajax.Request( 
     665        this.url, Object.extend({ 
     666          parameters: this.options.callback(form, value), 
     667          onComplete: this.onComplete.bind(this), 
     668          onFailure: this.onFailure.bind(this), 
     669          asynchronous:true,  
     670          evalScripts:true 
     671        }, this.options.ajaxOptions)); 
     672    } else  { 
     673      new Ajax.Updater( 
     674        { success: this.element, 
     675          // don't update on failure (this could be an option) 
     676          failure: null },  
     677        this.url, Object.extend({ 
     678          parameters: this.options.callback(form, value), 
     679          onComplete: this.onComplete.bind(this), 
     680          onFailure: this.onFailure.bind(this) 
     681        }, this.options.ajaxOptions)); 
     682    } 
    671683    // stop the event to avoid a page refresh in Safari 
    672684    if (arguments.length > 1) { 
     
    749761  } 
    750762}; 
     763 
     764Ajax.InPlaceCollectionEditor = Class.create(); 
     765Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype); 
     766Object.extend(Ajax.InPlaceCollectionEditor.prototype, { 
     767  createEditField: function() { 
     768    if (!this.cached_selectTag) { 
     769      var selectTag = document.createElement("select"); 
     770      var collection = this.options.collection || []; 
     771      var optionTag; 
     772      collection.each(function(e,i) { 
     773        optionTag = document.createElement("option"); 
     774        optionTag.value = (e instanceof Array) ? e[0] : e; 
     775        if(this.options.value==optionTag.value) optionTag.selected = true; 
     776        optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); 
     777        selectTag.appendChild(optionTag); 
     778      }.bind(this)); 
     779      this.cached_selectTag = selectTag; 
     780    } 
     781 
     782    this.editField = this.cached_selectTag; 
     783    if(this.options.loadTextURL) this.loadExternalText(); 
     784    this.form.appendChild(this.editField); 
     785    this.options.callback = function(form, value) { 
     786      return "value=" + encodeURIComponent(value); 
     787    } 
     788  } 
     789}); 
    751790 
    752791// Delayed observer, like Form.Element.Observer,  
  • trunk/actionpack/lib/action_view/helpers/javascripts/dragdrop.js

    r3595 r3634  
    350350   
    351351  keyPress: function(event) { 
    352     if(!event.keyCode==Event.KEY_ESC) return; 
     352    if(event.keyCode!=Event.KEY_ESC) return; 
    353353    this.finishDrag(event, false); 
    354354    Event.stop(event); 
     
    480480      ghosting:    false, 
    481481      scroll:      false, 
    482       format:      null
     482      format:      /^[^_]*_(.*)$/
    483483      onChange:    Prototype.emptyFunction, 
    484484      onUpdate:    Prototype.emptyFunction 
     
    637637  sequence: function(element) { 
    638638    element = $(element); 
    639     var sortableOptions = this.options(element); 
    640     var options = Object.extend({ 
    641       tag:  sortableOptions.tag, 
    642       only: sortableOptions.only, 
    643       name: element.id, 
    644       format: sortableOptions.format || /^[^_]*_(.*)$/ 
    645     }, arguments[1] || {}); 
     639    var options = Object.extend(this.options(element), arguments[1] || {}); 
     640     
    646641    return $(this.findElements(element, options) || []).map( function(item) { 
    647642      return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; 
     
    649644  }, 
    650645 
     646  setSequence: function(element, new_sequence) { 
     647    element = $(element); 
     648    var options = Object.extend(this.options(element), arguments[2] || {}); 
     649     
     650    var nodeMap = {}; 
     651    this.findElements(element, options).each( function(n) { 
     652        if (n.id.match(options.format)) 
     653            nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; 
     654        n.parentNode.removeChild(n); 
     655    }); 
     656    
     657    new_sequence.each(function(ident) { 
     658        var n = nodeMap[ident]; 
     659        if (n) { 
     660            n[1].appendChild(n[0]); 
     661            delete nodeMap[ident]; 
     662        } 
     663    }); 
     664  }, 
     665 
    651666  serialize: function(element) { 
    652667    element = $(element); 
     668    var name = encodeURIComponent( 
     669      (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); 
    653670    return Sortable.sequence(element, arguments[1]).map( function(item) { 
    654       return encodeURIComponent(element.id) + "[]=" + encodeURIComponent(item); 
     671      return name + "[]=" + encodeURIComponent(item); 
    655672    }).join('&'); 
    656673  } 
  • trunk/actionpack/lib/action_view/helpers/javascripts/effects.js

    r3595 r3634  
    585585Effect.BlindDown = function(element) { 
    586586  element = $(element); 
    587   var oldHeight = Element.getStyle(element, 'height'); 
    588587  var elementDimensions = Element.getDimensions(element); 
    589588  return new Effect.Scale(element, 100,  
     
    598597        show(effect.element);  
    599598      }},   
    600       afterFinishInternal: function(effect) { with(Element) { 
    601         undoClipping(effect.element); 
    602         setStyle(effect.element, {height: oldHeight}); 
    603       }} 
     599      afterFinishInternal: function(effect) { 
     600        Element.undoClipping(effect.element); 
     601      } 
    604602    }, arguments[1] || {}) 
    605603  ); 
  • trunk/railties/CHANGELOG

    r3618 r3634  
    11*SVN* 
     2 
     3* Update script.aculo.us to V1.5.3 [Thomas Fuchs] 
    24 
    35* Added SIGTRAP signal handler to RailsFCGIHandler that'll force the process into a breakpoint after the next request. This breakpoint can then be caught with script/breakpointer and give you access to the Ruby image inside that process. Useful for debugging memory leaks among other things [DHH] 
  • trunk/railties/html/javascripts/controls.js

    r3378 r3634  
    317317Object.extend(Object.extend(Ajax.Autocompleter.prototype, Autocompleter.Base.prototype), { 
    318318  initialize: function(element, update, url, options) { 
    319          this.baseInitialize(element, update, options); 
     319    this.baseInitialize(element, update, options); 
    320320    this.options.asynchronous  = true; 
    321321    this.options.onComplete    = this.onComplete.bind(this); 
     
    484484      highlightcolor: Ajax.InPlaceEditor.defaultHighlightColor, 
    485485      highlightendcolor: "#FFFFFF", 
    486       externalControl: null, 
     486      externalControl: null, 
    487487      submitOnBlur: false, 
    488       ajaxOptions: {} 
     488      ajaxOptions: {}, 
     489      evalScripts: false 
    489490    }, options || {}); 
    490491 
     
    555556      okButton.type = "submit"; 
    556557      okButton.value = this.options.okText; 
     558      okButton.className = 'editor_ok_button'; 
    557559      this.form.appendChild(okButton); 
    558560    } 
     
    563565      cancelLink.appendChild(document.createTextNode(this.options.cancelText)); 
    564566      cancelLink.onclick = this.onclickCancel.bind(this); 
     567      cancelLink.className = 'editor_cancel';       
    565568      this.form.appendChild(cancelLink); 
    566569    } 
     
    591594      textField.value = text; 
    592595      textField.style.backgroundColor = this.options.highlightcolor; 
     596      textField.className = 'editor_field'; 
    593597      var size = this.options.size || this.options.cols || 0; 
    594598      if (size != 0) textField.size = size; 
     
    604608      textArea.rows = this.options.rows; 
    605609      textArea.cols = this.options.cols || 40; 
     610      textArea.className = 'editor_field';       
    606611      if (this.options.submitOnBlur) 
    607612        textArea.onblur = this.onSubmit.bind(this); 
     
    656661    this.onLoading(); 
    657662     
    658     new Ajax.Updater( 
    659       {  
    660         success: this.element, 
    661          // don't update on failure (this could be an option) 
    662         failure: null 
    663       }, 
    664       this.url, 
    665       Object.extend({ 
    666         parameters: this.options.callback(form, value), 
    667         onComplete: this.onComplete.bind(this), 
    668         onFailure: this.onFailure.bind(this) 
    669       }, this.options.ajaxOptions) 
    670     ); 
     663    if (this.options.evalScripts) { 
     664      new Ajax.Request( 
     665        this.url, Object.extend({ 
     666          parameters: this.options.callback(form, value), 
     667          onComplete: this.onComplete.bind(this), 
     668          onFailure: this.onFailure.bind(this), 
     669          asynchronous:true,  
     670          evalScripts:true 
     671        }, this.options.ajaxOptions)); 
     672    } else  { 
     673      new Ajax.Updater( 
     674        { success: this.element, 
     675          // don't update on failure (this could be an option) 
     676          failure: null },  
     677        this.url, Object.extend({ 
     678          parameters: this.options.callback(form, value), 
     679          onComplete: this.onComplete.bind(this), 
     680          onFailure: this.onFailure.bind(this) 
     681        }, this.options.ajaxOptions)); 
     682    } 
    671683    // stop the event to avoid a page refresh in Safari 
    672684    if (arguments.length > 1) { 
     
    749761  } 
    750762}; 
     763 
     764Ajax.InPlaceCollectionEditor = Class.create(); 
     765Object.extend(Ajax.InPlaceCollectionEditor.prototype, Ajax.InPlaceEditor.prototype); 
     766Object.extend(Ajax.InPlaceCollectionEditor.prototype, { 
     767  createEditField: function() { 
     768    if (!this.cached_selectTag) { 
     769      var selectTag = document.createElement("select"); 
     770      var collection = this.options.collection || []; 
     771      var optionTag; 
     772      collection.each(function(e,i) { 
     773        optionTag = document.createElement("option"); 
     774        optionTag.value = (e instanceof Array) ? e[0] : e; 
     775        if(this.options.value==optionTag.value) optionTag.selected = true; 
     776        optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); 
     777        selectTag.appendChild(optionTag); 
     778      }.bind(this)); 
     779      this.cached_selectTag = selectTag; 
     780    } 
     781 
     782    this.editField = this.cached_selectTag; 
     783    if(this.options.loadTextURL) this.loadExternalText(); 
     784    this.form.appendChild(this.editField); 
     785    this.options.callback = function(form, value) { 
     786      return "value=" + encodeURIComponent(value); 
     787    } 
     788  } 
     789}); 
    751790 
    752791// Delayed observer, like Form.Element.Observer,  
  • trunk/railties/html/javascripts/dragdrop.js

    r3595 r3634  
    350350   
    351351  keyPress: function(event) { 
    352     if(!event.keyCode==Event.KEY_ESC) return; 
     352    if(event.keyCode!=Event.KEY_ESC) return; 
    353353    this.finishDrag(event, false); 
    354354    Event.stop(event); 
     
    480480      ghosting:    false, 
    481481      scroll:      false, 
    482       format:      null
     482      format:      /^[^_]*_(.*)$/
    483483      onChange:    Prototype.emptyFunction, 
    484484      onUpdate:    Prototype.emptyFunction 
     
    637637  sequence: function(element) { 
    638638    element = $(element); 
    639     var sortableOptions = this.options(element); 
    640     var options = Object.extend({ 
    641       tag:  sortableOptions.tag, 
    642       only: sortableOptions.only, 
    643       name: element.id, 
    644       format: sortableOptions.format || /^[^_]*_(.*)$/ 
    645     }, arguments[1] || {}); 
     639    var options = Object.extend(this.options(element), arguments[1] || {}); 
     640     
    646641    return $(this.findElements(element, options) || []).map( function(item) { 
    647642      return item.id.match(options.format) ? item.id.match(options.format)[1] : ''; 
     
    649644  }, 
    650645 
     646  setSequence: function(element, new_sequence) { 
     647    element = $(element); 
     648    var options = Object.extend(this.options(element), arguments[2] || {}); 
     649     
     650    var nodeMap = {}; 
     651    this.findElements(element, options).each( function(n) { 
     652        if (n.id.match(options.format)) 
     653            nodeMap[n.id.match(options.format)[1]] = [n, n.parentNode]; 
     654        n.parentNode.removeChild(n); 
     655    }); 
     656    
     657    new_sequence.each(function(ident) { 
     658        var n = nodeMap[ident]; 
     659        if (n) { 
     660            n[1].appendChild(n[0]); 
     661            delete nodeMap[ident]; 
     662        } 
     663    }); 
     664  }, 
     665 
    651666  serialize: function(element) { 
    652667    element = $(element); 
     668    var name = encodeURIComponent( 
     669      (arguments[1] && arguments[1].name) ? arguments[1].name : element.id); 
    653670    return Sortable.sequence(element, arguments[1]).map( function(item) { 
    654       return encodeURIComponent(element.id) + "[]=" + encodeURIComponent(item); 
     671      return name + "[]=" + encodeURIComponent(item); 
    655672    }).join('&'); 
    656673  } 
  • trunk/railties/html/javascripts/effects.js

    r3595 r3634  
    585585Effect.BlindDown = function(element) { 
    586586  element = $(element); 
    587   var oldHeight = Element.getStyle(element, 'height'); 
    588587  var elementDimensions = Element.getDimensions(element); 
    589588  return new Effect.Scale(element, 100,  
     
    598597        show(effect.element);  
    599598      }},   
    600       afterFinishInternal: function(effect) { with(Element) { 
    601         undoClipping(effect.element); 
    602         setStyle(effect.element, {height: oldHeight}); 
    603       }} 
     599      afterFinishInternal: function(effect) { 
     600        Element.undoClipping(effect.element); 
     601      } 
    604602    }, arguments[1] || {}) 
    605603  );