Changeset 114

Show
Ignore:
Timestamp:
03/02/07 17:33:48 (2 years ago)
Author:
bermiferrer
Message:

Updating script.aculo.us to the latest version

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/AkActionView/helpers/url_helper.php

    r95 r114  
    292292        } 
    293293 
     294        $onclick = ''; 
    294295        if ($popup && $post){ 
    295296            trigger_error(Ak::t("You can't use popup and post in the same link"), E_USER_ERROR); 
    296         } 
    297         elseif($confirm && $popup){ 
    298             $html_options['onclick'] = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_popup_javascript_function($popup).' };return false;'; 
    299         } 
    300         elseif ($confirm && $post) { 
    301             $html_options['onclick'] = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_post_javascript_function().' };return false;'; 
    302         } 
    303         elseif ($confirm) { 
    304             $html_options['onclick'] = 'return '.$this->_confirm_javascript_function($confirm).';'; 
    305         } 
    306         elseif ($post) { 
    307             $html_options['onclick'] = $this->_post_javascript_function().'return false;'; 
    308         } 
    309         elseif ($popup) { 
    310             $html_options['onclick'] = $this->_popup_javascript_function($popup).'return false;'; 
    311         } 
    312         else{ 
    313             $html_options['onclick'] = null; 
    314         } 
    315         return; 
     297             
     298        }elseif($confirm && $popup){ 
     299            $onclick = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_popup_javascript_function($popup).' };return false;'; 
     300             
     301        }elseif ($confirm && $post) { 
     302            $onclick = 'if ('.$this->_confirm_javascript_function($confirm).') { '.$this->_post_javascript_function().' };return false;'; 
     303             
     304        }elseif ($confirm) { 
     305            $onclick = 'return '.$this->_confirm_javascript_function($confirm).';'; 
     306             
     307        }elseif ($post) { 
     308            $onclick = $this->_post_javascript_function().'return false;'; 
     309             
     310        }elseif ($popup) { 
     311            $onclick = $this->_popup_javascript_function($popup).'return false;'; 
     312             
     313        } 
     314        $html_options['onclick'] = empty($html_options['onclick']) ? $onclick : $html_options['onclick'].$onclick; 
    316315    } 
    317316 
  • trunk/public/javascripts/builder.js

    r2 r114  
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     1// script.aculo.us builder.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    24// 
    3 // See scriptaculous.js for full license. 
     5// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     6// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    47 
    58var Builder = { 
     
    3437       
    3538    // see if browser added wrapping tags 
    36     if(element && (element.tagName != elementName)) 
     39    if(element && (element.tagName.toUpperCase() != elementName)) 
    3740      element = element.getElementsByTagName(elementName)[0]; 
    3841     
     
    6265                element[attr == 'class' ? 'className' : attr] = arguments[1][attr]; 
    6366            } 
    64             if(element.tagName != elementName) 
     67            if(element.tagName.toUpperCase() != elementName) 
    6568              element = parentElement.getElementsByTagName(elementName)[0]; 
    6669            } 
     
    7679     return document.createTextNode(text); 
    7780  }, 
     81 
     82  ATTR_MAP: { 
     83    'className': 'class', 
     84    'htmlFor': 'for' 
     85  }, 
     86 
    7887  _attributes: function(attributes) { 
    7988    var attrs = []; 
    8089    for(attribute in attributes) 
    81       attrs.push((attribute=='className' ? 'class' : attribute) + 
     90      attrs.push((attribute in this.ATTR_MAP ? this.ATTR_MAP[attribute] : attribute) + 
    8291          '="' + attributes[attribute].toString().escapeHTML() + '"'); 
    8392    return attrs.join(" "); 
     
    98107  _isStringOrNumber: function(param) { 
    99108    return(typeof param=='string' || typeof param=='number'); 
     109  }, 
     110  build: function(html) { 
     111    var element = this.node('div'); 
     112    $(element).update(html.strip()); 
     113    return element.down(); 
     114  }, 
     115  dump: function(scope) {  
     116    if(typeof scope != 'object' && typeof scope != 'function') scope = window; //global scope  
     117   
     118    var tags = ("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY " + 
     119      "BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET " + 
     120      "FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+ 
     121      "KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+ 
     122      "PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+ 
     123      "TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/); 
     124   
     125    tags.each( function(tag){  
     126      scope[tag] = function() {  
     127        return Builder.node.apply(Builder, [tag].concat($A(arguments)));   
     128      }  
     129    }); 
    100130  } 
    101131} 
  • trunk/public/javascripts/controls.js

    r2 r114  
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    2 //           (c) 2005 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 
    3 //           (c) 2005 Jon Tirsen (http://www.tirsen.com) 
     1// script.aculo.us controls.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     4//           (c) 2005, 2006 Ivan Krstic (http://blogs.law.harvard.edu/ivan) 
     5//           (c) 2005, 2006 Jon Tirsen (http://www.tirsen.com) 
    46// Contributors: 
    57//  Richard Livsey 
     
    79//  Rob Wills 
    810//  
    9 // See scriptaculous.js for full license. 
     11// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     12// For details, see the script.aculo.us web site: http://script.aculo.us/ 
    1013 
    1114// Autocompleter.Base handles all the autocompletion functionality  
     
    3336// useful when one of the tokens is \n (a newline), as it  
    3437// allows smart autocompletion after linebreaks. 
     38 
     39if(typeof Effect == 'undefined') 
     40  throw("controls.js requires including script.aculo.us' effects.js library"); 
    3541 
    3642var Autocompleter = {} 
     
    4652    this.entryCount  = 0; 
    4753 
    48     if (this.setOptions) 
     54    if(this.setOptions) 
    4955      this.setOptions(options); 
    5056    else 
     
    5662    this.options.minChars     = this.options.minChars || 1; 
    5763    this.options.onShow       = this.options.onShow ||  
    58     function(element, update){  
    59       if(!update.style.position || update.style.position=='absolute') { 
    60         update.style.position = 'absolute'; 
    61         Position.clone(element, update, {setHeight: false, offsetTop: element.offsetHeight}); 
    62       } 
    63       Effect.Appear(update,{duration:0.15}); 
    64     }; 
     64      function(element, update){  
     65        if(!update.style.position || update.style.position=='absolute') { 
     66          update.style.position = 'absolute'; 
     67          Position.clone(element, update, { 
     68            setHeight: false,  
     69            offsetTop: element.offsetHeight 
     70          }); 
     71        } 
     72        Effect.Appear(update,{duration:0.15}); 
     73      }; 
    6574    this.options.onHide = this.options.onHide ||  
    66     function(element, update){ new Effect.Fade(update,{duration:0.15}) }; 
    67  
    68     if (typeof(this.options.tokens) == 'string')  
     75      function(element, update){ new Effect.Fade(update,{duration:0.15}) }; 
     76 
     77    if(typeof(this.options.tokens) == 'string')  
    6978      this.options.tokens = new Array(this.options.tokens); 
    7079 
     
    95104   
    96105  fixIEOverlapping: function() { 
    97     Position.clone(this.update, this.iefix); 
     106    Position.clone(this.update, this.iefix, {setTop:(!this.update.style.height)}); 
    98107    this.iefix.style.zIndex = 1; 
    99108    this.update.style.zIndex = 2; 
     
    203212    if(this.index > 0) this.index-- 
    204213      else this.index = this.entryCount-1; 
     214    this.getEntry(this.index).scrollIntoView(true); 
    205215  }, 
    206216   
     
    208218    if(this.index < this.entryCount-1) this.index++ 
    209219      else this.index = 0; 
     220    this.getEntry(this.index).scrollIntoView(false); 
    210221  }, 
    211222   
     
    255266      this.update.innerHTML = choices; 
    256267      Element.cleanWhitespace(this.update); 
    257       Element.cleanWhitespace(this.update.firstChild); 
    258  
    259       if(this.update.firstChild && this.update.firstChild.childNodes) { 
     268      Element.cleanWhitespace(this.update.down()); 
     269 
     270      if(this.update.firstChild && this.update.down().childNodes) { 
    260271        this.entryCount =  
    261           this.update.firstChild.childNodes.length; 
     272          this.update.down().childNodes.length; 
    262273        for (var i = 0; i < this.entryCount; i++) { 
    263274          var entry = this.getEntry(i); 
     
    270281 
    271282      this.stopIndicator(); 
    272  
    273283      this.index = 0; 
    274       this.render(); 
     284       
     285      if(this.entryCount==1 && this.options.autoSelect) { 
     286        this.selectEntry(); 
     287        this.hide(); 
     288      } else { 
     289        this.render(); 
     290      } 
    275291    } 
    276292  }, 
     
    460476 
    461477    this.options = Object.extend({ 
     478      paramName: "value", 
    462479      okButton: true, 
    463480      okText: "ok", 
     
    532549    this.createForm(); 
    533550    this.element.parentNode.insertBefore(this.form, this.element); 
    534     Field.scrollFreeActivate(this.editField); 
     551    if (!this.options.loadTextURL) Field.scrollFreeActivate(this.editField); 
    535552    // stop the event to avoid a page refresh in Safari 
    536553    if (evt) { 
     
    591608      textField.obj = this; 
    592609      textField.type = "text"; 
    593       textField.name = "value"
     610      textField.name = this.options.paramName
    594611      textField.value = text; 
    595612      textField.style.backgroundColor = this.options.highlightcolor; 
     
    604621      var textArea = document.createElement("textarea"); 
    605622      textArea.obj = this; 
    606       textArea.name = "value"
     623      textArea.name = this.options.paramName
    607624      textArea.value = this.convertHTMLLineBreaks(text); 
    608625      textArea.rows = this.options.rows; 
     
    637654    this.editField.disabled = false; 
    638655    this.editField.value = transport.responseText.stripTags(); 
     656    Field.scrollFreeActivate(this.editField); 
    639657  }, 
    640658  onclickCancel: function() { 
     
    773791        optionTag = document.createElement("option"); 
    774792        optionTag.value = (e instanceof Array) ? e[0] : e; 
     793        if((typeof this.options.value == 'undefined') &&  
     794          ((e instanceof Array) ? this.element.innerHTML == e[1] : e == optionTag.value)) optionTag.selected = true; 
    775795        if(this.options.value==optionTag.value) optionTag.selected = true; 
    776796        optionTag.appendChild(document.createTextNode((e instanceof Array) ? e[1] : e)); 
  • trunk/public/javascripts/dragdrop.js

    r2 r114  
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    2 //           (c) 2005 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 
     1// script.aculo.us dragdrop.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     4//           (c) 2005, 2006 Sammi Williams (http://www.oriontransfer.co.nz, sammi@oriontransfer.co.nz) 
    35//  
    4 // See scriptaculous.js for full license. 
    5  
    6 /*--------------------------------------------------------------------------*/ 
     6// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     7// For details, see the script.aculo.us web site: http://script.aculo.us/ 
     8 
     9if(typeof Effect == 'undefined') 
     10  throw("dragdrop.js requires including script.aculo.us' effects.js library"); 
    711 
    812var Droppables = { 
     
    146150   
    147151  activate: function(draggable) { 
    148     window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 
    149     this.activeDraggable = draggable; 
     152    if(draggable.options.delay) {  
     153      this._timeout = setTimeout(function() {  
     154        Draggables._timeout = null;  
     155        window.focus();  
     156        Draggables.activeDraggable = draggable;  
     157      }.bind(this), draggable.options.delay);  
     158    } else { 
     159      window.focus(); // allows keypress events if window isn't currently focused, fails for Safari 
     160      this.activeDraggable = draggable; 
     161    } 
    150162  }, 
    151163   
     
    161173    if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return; 
    162174    this._lastPointer = pointer; 
     175     
    163176    this.activeDraggable.updateDrag(event, pointer); 
    164177  }, 
    165178   
    166179  endDrag: function(event) { 
     180    if(this._timeout) {  
     181      clearTimeout(this._timeout);  
     182      this._timeout = null;  
     183    } 
    167184    if(!this.activeDraggable) return; 
    168185    this._lastPointer = null; 
     
    191208        if(o[eventName]) o[eventName](eventName, draggable, event); 
    192209      }); 
     210    if(draggable.options[eventName]) draggable.options[eventName](draggable, event); 
    193211  }, 
    194212   
     
    205223 
    206224var Draggable = Class.create(); 
     225Draggable._dragging    = {}; 
     226 
    207227Draggable.prototype = { 
    208228  initialize: function(element) { 
    209     var options = Object.extend(
     229    var defaults =
    210230      handle: false, 
    211       starteffect: function(element) { 
    212         element._opacity = Element.getOpacity(element);  
    213         new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});  
    214       }, 
    215231      reverteffect: function(element, top_offset, left_offset) { 
    216232        var dur = Math.sqrt(Math.abs(top_offset^2)+Math.abs(left_offset^2))*0.02; 
    217         element._revert = new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur}); 
     233        new Effect.Move(element, { x: -left_offset, y: -top_offset, duration: dur, 
     234          queue: {scope:'_draggable', position:'end'} 
     235        }); 
    218236      }, 
    219237      endeffect: function(element) { 
    220         var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0 
    221         new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity});  
     238        var toOpacity = typeof element._opacity == 'number' ? element._opacity : 1.0; 
     239        new Effect.Opacity(element, {duration:0.2, from:0.7, to:toOpacity,  
     240          queue: {scope:'_draggable', position:'end'}, 
     241          afterFinish: function(){  
     242            Draggable._dragging[element] = false  
     243          } 
     244        });  
    222245      }, 
    223246      zindex: 1000, 
     
    226249      scrollSensitivity: 20, 
    227250      scrollSpeed: 15, 
    228       snap: false   // false, or xy or [x,y] or function(x,y){ return [x,y] } 
    229     }, arguments[1] || {}); 
     251      snap: false,  // false, or xy or [x,y] or function(x,y){ return [x,y] } 
     252      delay: 0 
     253    }; 
     254     
     255    if(!arguments[1] || typeof arguments[1].endeffect == 'undefined') 
     256      Object.extend(defaults, { 
     257        starteffect: function(element) { 
     258          element._opacity = Element.getOpacity(element); 
     259          Draggable._dragging[element] = true; 
     260          new Effect.Opacity(element, {duration:0.2, from:element._opacity, to:0.7});  
     261        } 
     262      }); 
     263     
     264    var options = Object.extend(defaults, arguments[1] || {}); 
    230265 
    231266    this.element = $(element); 
    232267     
    233     if(options.handle && (typeof options.handle == 'string')) { 
    234       var h = Element.childrenWithClassName(this.element, options.handle, true); 
    235       if(h.length>0) this.handle = h[0]; 
    236     } 
     268    if(options.handle && (typeof options.handle == 'string')) 
     269      this.handle = this.element.down('.'+options.handle, 0); 
     270     
    237271    if(!this.handle) this.handle = $(options.handle); 
    238272    if(!this.handle) this.handle = this.element; 
    239273     
    240     if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) 
     274    if(options.scroll && !options.scroll.scrollTo && !options.scroll.outerHTML) { 
    241275      options.scroll = $(options.scroll); 
     276      this._isScrollChild = Element.childOf(this.element, options.scroll); 
     277    } 
    242278 
    243279    Element.makePositioned(this.element); // fix IE     
     
    265301   
    266302  initDrag: function(event) { 
     303    if(typeof Draggable._dragging[this.element] != 'undefined' && 
     304      Draggable._dragging[this.element]) return; 
    267305    if(Event.isLeftClick(event)) {     
    268306      // abort on form elements, fixes a Firefox issue 
    269307      var src = Event.element(event); 
    270       if(src.tagName && ( 
    271         src.tagName=='INPUT' || 
    272         src.tagName=='SELECT' || 
    273         src.tagName=='OPTION' || 
    274         src.tagName=='BUTTON' || 
    275         src.tagName=='TEXTAREA')) return; 
     308      if((tag_name = src.tagName.toUpperCase()) && ( 
     309        tag_name=='INPUT' || 
     310        tag_name=='SELECT' || 
     311        tag_name=='OPTION' || 
     312        tag_name=='BUTTON' || 
     313        tag_name=='TEXTAREA')) return; 
    276314         
    277       if(this.element._revert) { 
    278         this.element._revert.cancel(); 
    279         this.element._revert = null; 
    280       } 
    281        
    282315      var pointer = [Event.pointerX(event), Event.pointerY(event)]; 
    283316      var pos     = Position.cumulativeOffset(this.element); 
     
    315348     
    316349    Draggables.notify('onStart', this, event); 
     350         
    317351    if(this.options.starteffect) this.options.starteffect(this.element); 
    318352  }, 
     
    323357    Droppables.show(pointer, this.element); 
    324358    Draggables.notify('onDrag', this, event); 
     359     
    325360    this.draw(pointer); 
    326361    if(this.options.change) this.options.change(this); 
     
    334369      } else { 
    335370        p = Position.page(this.options.scroll); 
    336         p[0] += this.options.scroll.scrollLeft
    337         p[1] += this.options.scroll.scrollTop
     371        p[0] += this.options.scroll.scrollLeft + Position.deltaX
     372        p[1] += this.options.scroll.scrollTop + Position.deltaY
    338373        p.push(p[0]+this.options.scroll.offsetWidth); 
    339374        p.push(p[1]+this.options.scroll.offsetHeight); 
     
    381416    if(this.options.endeffect)  
    382417      this.options.endeffect(this.element); 
    383  
     418       
    384419    Draggables.deactivate(this); 
    385420    Droppables.reset(); 
     
    401436  draw: function(point) { 
    402437    var pos = Position.cumulativeOffset(this.element); 
     438    if(this.options.ghosting) { 
     439      var r   = Position.realOffset(this.element); 
     440      pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY; 
     441    } 
     442     
    403443    var d = this.currentDelta(); 
    404444    pos[0] -= d[0]; pos[1] -= d[1]; 
    405445     
    406     if(this.options.scroll && (this.options.scroll != window)) { 
     446    if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) { 
    407447      pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft; 
    408448      pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop; 
     
    431471    if((!this.options.constraint) || (this.options.constraint=='vertical')) 
    432472      style.top  = p[1] + "px"; 
     473     
    433474    if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering 
    434475  }, 
     
    443484   
    444485  startScrolling: function(speed) { 
     486    if(!(speed[0] || speed[1])) return; 
    445487    this.scrollSpeed = [speed[0]*this.options.scrollSpeed,speed[1]*this.options.scrollSpeed]; 
    446488    this.lastScrolled = new Date(); 
     
    467509    Droppables.show(Draggables._lastPointer, this.element); 
    468510    Draggables.notify('onDrag', this); 
    469     Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 
    470     Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 
    471     Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 
    472     if (Draggables._lastScrollPointer[0] < 0) 
    473       Draggables._lastScrollPointer[0] = 0; 
    474     if (Draggables._lastScrollPointer[1] < 0) 
    475       Draggables._lastScrollPointer[1] = 0; 
    476     this.draw(Draggables._lastScrollPointer); 
     511    if (this._isScrollChild) { 
     512      Draggables._lastScrollPointer = Draggables._lastScrollPointer || $A(Draggables._lastPointer); 
     513      Draggables._lastScrollPointer[0] += this.scrollSpeed[0] * delta / 1000; 
     514      Draggables._lastScrollPointer[1] += this.scrollSpeed[1] * delta / 1000; 
     515      if (Draggables._lastScrollPointer[0] < 0) 
     516        Draggables._lastScrollPointer[0] = 0; 
     517      if (Draggables._lastScrollPointer[1] < 0) 
     518        Draggables._lastScrollPointer[1] = 0; 
     519      this.draw(Draggables._lastScrollPointer); 
     520    } 
    477521     
    478522    if(this.options.change) this.options.change(this); 
     
    526570 
    527571var Sortable = { 
     572  SERIALIZE_RULE: /^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/, 
     573   
    528574  sortables: {}, 
    529575   
    530576  _findRootElement: function(element) { 
    531     while (element.tagName != "BODY") {   
     577    while (element.tagName.toUpperCase() != "BODY") {   
    532578      if(element.id && Sortable.sortables[element.id]) return element; 
    533579      element = element.parentNode; 
     
    566612      handle:      false,      // or a CSS class 
    567613      only:        false, 
     614      delay:       0, 
    568615      hoverclass:  null, 
    569616      ghosting:    false, 
     
    571618      scrollSensitivity: 20, 
    572619      scrollSpeed: 15, 
    573       format:      /^[^_]*_(.*)$/
     620      format:      this.SERIALIZE_RULE
    574621      onChange:    Prototype.emptyFunction, 
    575622      onUpdate:    Prototype.emptyFunction 
     
    585632      scrollSpeed: options.scrollSpeed, 
    586633      scrollSensitivity: options.scrollSensitivity, 
     634      delay:       options.delay, 
    587635      ghosting:    options.ghosting, 
    588636      constraint:  options.constraint, 
     
    613661      hoverclass:  options.hoverclass, 
    614662      onHover:     Sortable.onHover 
    615       //greedy:      !options.dropOnEmpty 
    616663    } 
    617664     
     
    638685      // handles are per-draggable 
    639686      var handle = options.handle ?  
    640         Element.childrenWithClassName(e, options.handle)[0] : e;     
     687        $(e).down('.'+options.handle,0) : e;     
    641688      options.draggables.push( 
    642689        new Draggable(e, Object.extend(options_for_draggable, { handle: handle }))); 
     
    709756      var index; 
    710757       
    711       var children = Sortable.findElements(dropon, {tag: droponOptions.tag}); 
     758      var children = Sortable.findElements(dropon, {tag: droponOptions.tag, only: droponOptions.only}); 
    712759      var child = null; 
    713760             
     
    736783 
    737784  unmark: function() { 
    738     if(Sortable._marker) Element.hide(Sortable._marker); 
     785    if(Sortable._marker) Sortable._marker.hide(); 
    739786  }, 
    740787 
     
    745792 
    746793    if(!Sortable._marker) { 
    747       Sortable._marker = $('dropmarker') || document.createElement('DIV'); 
    748       Element.hide(Sortable._marker); 
    749       Element.addClassName(Sortable._marker, 'dropmarker'); 
    750       Sortable._marker.style.position = 'absolute'; 
     794      Sortable._marker =  
     795        ($('dropmarker') || Element.extend(document.createElement('DIV'))). 
     796          hide().addClassName('dropmarker').setStyle({position:'absolute'}); 
    751797      document.getElementsByTagName("body").item(0).appendChild(Sortable._marker); 
    752798    }     
    753799    var offsets = Position.cumulativeOffset(dropon); 
    754     Sortable._marker.style.left = offsets[0] + 'px'; 
    755     Sortable._marker.style.top = offsets[1] + 'px'; 
     800    Sortable._marker.setStyle({left: offsets[0]+'px', top: offsets[1] + 'px'}); 
    756801     
    757802    if(position=='after') 
    758803      if(sortable.overlap == 'horizontal')  
    759         Sortable._marker.style.left = (offsets[0]+dropon.clientWidth) + 'px'
     804        Sortable._marker.setStyle({left: (offsets[0]+dropon.clientWidth) + 'px'})
    760805      else 
    761         Sortable._marker.style.top = (offsets[1]+dropon.clientHeight) + 'px'
    762      
    763     Element.show(Sortable._marker); 
     806        Sortable._marker.setStyle({top: (offsets[1]+dropon.clientHeight) + 'px'})
     807     
     808    Sortable._marker.show(); 
    764809  }, 
    765810   
     
    776821        element: element, 
    777822        parent: parent, 
    778         children: new Array
     823        children: []
    779824        position: parent.children.length, 
    780         container: Sortable._findChildrenElement(children[i], options.treeTag.toUpperCase()
     825        container: $(children[i]).down(options.treeTag
    781826      } 
    782827       
     
    789834 
    790835    return parent;  
    791   }, 
    792  
    793   /* Finds the first element of the given tag type within a parent element. 
    794     Used for finding the first LI[ST] within a L[IST]I[TEM].*/ 
    795   _findChildrenElement: function (element, containerTag) { 
    796     if (element && element.hasChildNodes) 
    797       for (var i = 0; i < element.childNodes.length; ++i) 
    798         if (element.childNodes[i].tagName == containerTag) 
    799           return element.childNodes[i]; 
    800    
    801     return null; 
    802836  }, 
    803837 
     
    816850      id: null, 
    817851      parent: null, 
    818       children: new Array
     852      children: []
    819853      container: element, 
    820854      position: 0 
    821855    } 
    822856     
    823     return Sortable._tree (element, options, root); 
     857    return Sortable._tree(element, options, root); 
    824858  }, 
    825859 
     
    870904    if (options.tree) { 
    871905      return Sortable.tree(element, arguments[1]).children.map( function (item) { 
    872         return [name + Sortable._constructIndex(item) + "=" +  
     906        return [name + Sortable._constructIndex(item) + "[id]=" +  
    873907                encodeURIComponent(item.id)].concat(item.children.map(arguments.callee)); 
    874908      }).flatten().join('&'); 
     
    881915} 
    882916 
    883 /* Returns true if child is contained within element */ 
     917// Returns true if child is contained within element 
    884918Element.isParent = function(child, element) { 
    885919  if (!child.parentNode || child == element) return false; 
    886  
    887920  if (child.parentNode == element) return true; 
    888  
    889921  return Element.isParent(child.parentNode, element); 
    890922} 
     
    909941 
    910942Element.offsetSize = function (element, type) { 
    911   if (type == 'vertical' || type == 'height') 
    912     return element.offsetHeight; 
    913   else 
    914     return element.offsetWidth; 
     943  return element['offset' + ((type=='vertical' || type=='height') ? 'Height' : 'Width')]; 
    915944} 
  • trunk/public/javascripts/effects.js

    <
    r2 r114  
    1 // Copyright (c) 2005 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
     1// script.aculo.us effects.js v1.7.0, Fri Jan 19 19:16:36 CET 2007 
     2 
     3// Copyright (c) 2005, 2006 Thomas Fuchs (http://script.aculo.us, http://mir.aculo.us) 
    24// Contributors: 
    35//  Justin Palmer (http://encytemedia.com/) 
     
    57//  Martin Bialasinki 
    68//  
    7 // See scriptaculous.js for full license.   
    8  
    9 /* ------------- element ext -------------- */   
    10   
     9// script.aculo.us is freely distributable under the terms of an MIT-style license. 
     10// For details, see the script.aculo.us web site: http://script.aculo.us/  
     11 
    1112// converts rgb() and #xxx to #xxxxxx format,   
    1213// returns self (or first argument) if not convertable   
    1314String.prototype.parseColor = function() {   
    14   var color = '#';   
     15  var color = '#'; 
    1516  if(this.slice(0,4) == 'rgb(') {   
    1617    var cols = this.slice(4,this.length-1).split(',');   
     
    2526} 
    2627 
     28/*--------------------------------------------------------------------------*/ 
     29 
    2730Element.collectTextNodes = function(element) {   
    2831  return $A($(element).childNodes).collect( function(node) { 
     
    4043} 
    4144 
    42 Element.setStyle = function(element, style) { 
    43   element = $(element); 
    44   for(k in style) element.style[k.camelize()] = style[k]; 
    45 
    46  
    47 Element.setContentZoom = function(element, percent) {   
    48   Element.setStyle(element, {fontSize: (percent/100) + 'em'});    
    49   if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0);   
    50 
    51  
    52 Element.getOpacity = function(element){   
    53   var opacity; 
    54   if (opacity = Element.getStyle(element, 'opacity'))   
    55     return parseFloat(opacity);   
    56   if (opacity = (Element.getStyle(element, 'filter') || '').match(/alpha\(opacity=(.*)\)/))   
    57     if(opacity[1]) return parseFloat(opacity[1]) / 100;   
    58   return 1.0;   
    59 
    60  
    61 Element.setOpacity = function(element, value){   
    62   element= $(element);   
    63   if (value == 1){ 
    64     Element.setStyle(element, { opacity:  
    65       (/Gecko/.test(navigator.userAgent) && !/Konqueror|Safari|KHTML/.test(navigator.userAgent)) ?  
    66       0.999999 : null }); 
    67     if(/MSIE/.test(navigator.userAgent))   
    68       Element.setStyle(element, {filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'')});   
    69   } else {   
    70     if(value < 0.00001) value = 0;   
    71     Element.setStyle(element, {opacity: value}); 
    72     if(/MSIE/.test(navigator.userAgent))   
    73      Element.setStyle(element,  
    74        { filter: Element.getStyle(element,'filter').replace(/alpha\([^\)]*\)/gi,'') + 
    75                  'alpha(opacity='+value*100+')' });   
    76   }    
    77 }   
    78   
    79 Element.getInlineOpacity = function(element){   
     45Element.setContentZoom = function(element, percent) { 
     46  element = $(element);   
     47  element.setStyle({fontSize: (percent/100) + 'em'});    
     48  if(navigator.appVersion.indexOf('AppleWebKit')>0) window.scrollBy(0,0); 
     49  return element; 
     50
     51 
     52Element.getOpacity = function(element){ 
     53  return $(element).getStyle('opacity'); 
     54
     55 
     56Element.setOpacity = function(element, value){ 
     57  return $(element).setStyle({opacity:value}); 
     58
     59 
     60Element.getInlineOpacity = function(element){ 
    8061  return $(element).style.opacity || ''; 
    81  
    82  
    83 Element.childrenWithClassName = function(element, className) {   
    84   return $A($(element).getElementsByTagName('*')).select( 
    85     function(c) { return Element.hasClassName(c, className) }); 
    8662} 
    8763 
     
    9268    element.appendChild(n); 
    9369    element.removeChild(n); 
    94   } catch(e) {} 
    95 
     70  } catch(e) { } 
     71}; 
     72 
     73/*--------------------------------------------------------------------------*/ 
    9674 
    9775Array.prototype.call = function() { 
     
    10381 
    10482var Effect = { 
     83  _elementDoesNotExistError: { 
     84    name: 'ElementDoesNotExistError', 
     85    message: 'The specified DOM element does not exist, but is required for this effect to operate' 
     86  }, 
    10587  tagifyText: function(element) { 
     88    if(typeof Builder == 'undefined') 
     89      throw("Effect.tagifyText requires including script.aculo.us' builder.js library"); 
     90       
    10691    var tagifyStyle = 'position:relative'; 
    107     if(/MSIE/.test(navigator.userAgent)) tagifyStyle += ';zoom:1'; 
     92    if(/MSIE/.test(navigator.userAgent) && !window.opera) tagifyStyle += ';zoom:1'; 
     93     
    10894    element = $(element); 
    10995    $A(element.childNodes).each( function(child) { 
     
    149135      queue: { position:'end', scope:(element.id || 'global'), limit: 1 } 
    150136    }, arguments[2] || {}); 
    151     Effect[Element.visible(element) ?  
     137    Effect[element.visible() ?  
    152138      Effect.PAIRS[effect][1] : Effect.PAIRS[effect][0]](element, options); 
    153139  } 
     
    158144/* ------------- transitions ------------- */ 
    159145 
    160 Effect.Transitions = {} 
    161  
    162 Effect.Transitions.linear = function(pos) { 
    163   return pos; 
    164 
    165 Effect.Transitions.sinoidal = function(pos) { 
    166   return (-Math.cos(pos*Math.PI)/2) + 0.5; 
    167 
    168 Effect.Transitions.reverse  = function(pos) { 
    169   return 1-pos; 
    170 
    171 Effect.Transitions.flicker = function(pos) { 
    172   return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 
    173 
    174 Effect.Transitions.wobble = function(pos) { 
    175   return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 
    176 
    177 Effect.Transitions.pulse = function(pos) { 
    178   return (Math.floor(pos*10) % 2 == 0 ?  
    179     (pos*10-Math.floor(pos*10)) : 1-(pos*10-Math.floor(pos*10))); 
    180 
    181 Effect.Transitions.none = function(pos) { 
    182   return 0; 
    183 
    184 Effect.Transitions.full = function(pos) { 
    185   return 1; 
    186 
     146Effect.Transitions = { 
     147  linear: Prototype.K, 
     148  sinoidal: function(pos) { 
     149    return (-Math.cos(pos*Math.PI)/2) + 0.5; 
     150  }, 
     151  reverse: function(pos) { 
     152    return 1-pos; 
     153  }, 
     154  flicker: function(pos) { 
     155    return ((-Math.cos(pos*Math.PI)/4) + 0.75) + Math.random()/4; 
     156  }, 
     157  wobble: function(pos) { 
     158    return (-Math.cos(pos*Math.PI*(9*pos))/2) + 0.5; 
     159  }, 
     160  pulse: function(pos, pulses) {  
     161    pulses = pulses || 5;  
     162    return ( 
     163      Math.round((pos % (1/pulses)) * pulses) == 0 ?  
     164            ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) :  
     165        1 - ((pos * pulses * 2) - Math.floor(pos * pulses * 2)) 
     166      ); 
     167  }, 
     168  none: function(pos) { 
     169    return 0; 
     170  }, 
     171  full: function(pos) { 
     172    return 1; 
     173  } 
     174}; 
    187175 
    188176/* ------------- core effects ------------- */ 
     
    211199          }); 
    212200        break; 
     201      case 'with-last': 
     202        timestamp = this.effects.pluck('startOn').max() || timestamp; 
     203        break; 
    213204      case 'end': 
    214205        // start effect after last queued effect has finished 
     
    224215     
    225216    if(!this.interval)  
    226       this.interval = setInterval(this.loop.bind(this), 40); 
     217      this.interval = setInterval(this.loop.bind(this), 15); 
    227218  }, 
    228219  remove: function(effect) { 
     
    235226  loop: function() { 
    236227    var timePos = new Date().getTime(); 
    237     this.effects.invoke('loop', timePos); 
     228    for(var i=0, len=this.effects.length;i<len;i++)  
     229      if(this.effects[i]) this.effects[i].loop(timePos); 
    238230  } 
    239231}); 
     
    255247  transition: Effect.Transitions.sinoidal, 
    256248  duration:   1.0,   // seconds 
    257   fps:        25.0,  // max. 25fps due to Effect.Queue implementation 
     249  fps:        60.0,  // max. 60fps due to Effect.Queue implementation 
    258250  sync:       false, // true for combining 
    259251  from:       0.0, 
     
    323315  }, 
    324316  inspect: function() { 
    325     return '#<Effect:' + $H(this).inspect() + ',options:' + $H(this.options).inspect() + '>'; 
     317    var data = $H(); 
     318    for(property in this) 
     319      if(typeof this[property] != 'function') data[property] = this[property]; 
     320    return '#<Effect:' + data.inspect() + ',options:' + $H(this.options).inspect() + '>'; 
    326321  } 
    327322} 
     
    347342}); 
    348343 
     344Effect.Event = Class.create(); 
     345Object.extend(Object.extend(Effect.Event.prototype, Effect.Base.prototype), { 
     346  initialize: function() { 
     347    var options = Object.extend({ 
     348      duration: 0 
     349    }, arguments[0] || {}); 
     350    this.start(options); 
     351  }, 
     352  update: Prototype.emptyFunction 
     353}); 
     354 
    349355Effect.Opacity = Class.create(); 
    350356Object.extend(Object.extend(Effect.Opacity.prototype, Effect.Base.prototype), { 
    351357  initialize: function(element) { 
    352358    this.element = $(element); 
     359    if(!this.element) throw(Effect._elementDoesNotExistError); 
    353360    // make this work on IE on elements without 'layout' 
    354     if(/MSIE/.test(navigator.userAgent) && (!this.element.hasLayout)) 
    355       Element.setStyle(this.element, {zoom: 1}); 
     361    if(/MSIE/.test(navigator.userAgent) && !window.opera && (!this.element.currentStyle.hasLayout)) 
     362      this.element.setStyle({zoom: 1}); 
    356363    var options = Object.extend({ 
    357       from: Element.getOpacity(this.element) || 0.0, 
     364      from: this.element.getOpacity() || 0.0, 
    358365      to:   1.0 
    359366    }, arguments[1] || {}); 
     
    361368  }, 
    362369  update: function(position) { 
    363     Element.setOpacity(this.element, position); 
     370    this.element.setOpacity(position); 
    364371  } 
    365372}); 
     
    369376  initialize: function(element) { 
    370377    this.element = $(element); 
     378    if(!this.element) throw(Effect._elementDoesNotExistError); 
    371379    var options = Object.extend({ 
    372380      x:    0, 
     
    381389    // ==> Always set top and left for position relative elements in your stylesheets  
    382390    // (to 0 if you do not need them)  
    383     Element.makePositioned(this.element); 
    384     this.originalLeft = parseFloat(Element.getStyle(this.element,'left') || '0'); 
    385     this.originalTop  = parseFloat(Element.getStyle(this.element,'top')  || '0'); 
     391    this.element.makePositioned(); 
     392    this.originalLeft = parseFloat(this.element.getStyle('left') || '0'); 
     393    this.originalTop  = parseFloat(this.element.getStyle('top')  || '0'); 
    386394    if(this.options.mode == 'absolute') { 
    387395      // absolute movement, so we need to calc deltaX and deltaY 
     
    391399  }, 
    392400  update: function(position) { 
    393     Element.setStyle(this.element,
    394       left: this.options.x  * position + this.originalLeft + 'px', 
    395       top:  this.options.y  * position + this.originalTop  + 'px' 
     401    this.element.setStyle(
     402      left: Math.round(this.options.x  * position + this.originalLeft) + 'px', 
     403      top:  Math.round(this.options.y  * position + this.originalTop)  + 'px' 
    396404    }); 
    397405  } 
     
    407415Object.extend(Object.extend(Effect.Scale.prototype, Effect.Base.prototype), { 
    408416  initialize: function(element, percent) { 
    409     this.element = $(element) 
     417    this.element = $(element); 
     418    if(!this.element) throw(Effect._elementDoesNotExistError); 
    410419    var options = Object.extend({ 
    411420      scaleX: true, 
     
    421430  setup: function() { 
    422431    this.restoreAfterFinish = this.options.restoreAfterFinish || false; 
    423     this.elementPositioning = Element.getStyle(this.element,'position'); 
     432    this.elementPositioning = this.element.getStyle('position'); 
    424433     
    425434    this.originalStyle = {}; 
     
    431440    this.originalLeft = this.element.offsetLeft; 
    432441     
    433     var fontSize = Element.getStyle(this.element,'font-size') || '100%'; 
    434     ['em','px','%'].each( function(fontSizeType) { 
     442    var fontSize = this.element.getStyle('font-size') || '100%'; 
     443    ['em','px','%','pt'].each( function(fontSizeType) { 
    435444      if(fontSize.indexOf(fontSizeType)>0) { 
    436445        this.fontSize     = parseFloat(fontSize);