[Proto-Scripty] Re: Where is ver. 2.0 is coming?

2011-12-01 Thread Victor
1. Declaration with value assignment
2. Declare loop variables and cache length inside of for() - this can 
increase performance http://jsperf.com/caching-array-length/67 - caching 
length outside of for() is slower in almost all results (all Firefox and 
Safari, IE9 and some Chrome results)
3. Unnecessary return values

Example can be rewritten as:
  SelectParser.select_to_array = function(select) {
var parser = new SelectParser(), _ref = select.childNodes;
for (var _i = 0, _len = _ref.length; _i  _len; _i++) {
  parser.add_node(_ref[_i]);
}
return parser.parsed;
  };

yet another real example: 

CoffeeScript (with use of Prototype):
class Chosen extends AbstractChosen
...  
  no_results_clear: -
nr = null
nr.remove() while nr = @search_results.down(.no-results)

CoffeeScript translated to JavaScript:
Chosen.prototype.no_results_clear = function() {
  var nr, _results;
  nr = null;
  _results = [];
  while (nr = this.search_results.down(.no-results)) {
_results.push(nr.remove());
  }
  return _results;
};

and pure JavaScript:
var Chosen = Class.create(AbstractChosen, {
...
  no_results_clear: function() {
this.search_results.select(.no-results).invoke(remove);
  },
...
});

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/prototype-scriptaculous/-/FBTDmhOjgWoJ.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



Re: [Proto-Scripty] Re: Where is ver. 2.0 is coming?

2011-12-01 Thread Phil Petree
Hysterical!!!  Thanks for that laugh!!!
On Dec 1, 2011 9:01 AM, Victor vkhomyac...@gmail.com wrote:

 1. Declaration with value assignment
 2. Declare loop variables and cache length inside of for() - this can
 increase performance http://jsperf.com/caching-array-length/67 -
 caching length outside of for() is slower in almost all results (all
 Firefox and Safari, IE9 and some Chrome results)
 3. Unnecessary return values

 Example can be rewritten as:
   SelectParser.select_to_array = function(select) {
 var parser = new SelectParser(), _ref = select.childNodes;
 for (var _i = 0, _len = _ref.length; _i  _len; _i++) {
   parser.add_node(_ref[_i]);
 }
 return parser.parsed;
   };

 yet another real example:

 CoffeeScript (with use of Prototype):
 class Chosen extends AbstractChosen
 ...
   no_results_clear: -
 nr = null
 nr.remove() while nr = @search_results.down(.no-results)

 CoffeeScript translated to JavaScript:
 Chosen.prototype.no_results_clear = function() {
   var nr, _results;
   nr = null;
   _results = [];
   while (nr = this.search_results.down(.no-results)) {
 _results.push(nr.remove());
   }
   return _results;
 };

 and pure JavaScript:
 var Chosen = Class.create(AbstractChosen, {
 ...
   no_results_clear: function() {
 this.search_results.select(.no-results).invoke(remove);
   },
 ...
 });

  --
 You received this message because you are subscribed to the Google Groups
 Prototype  script.aculo.us group.
 To view this discussion on the web visit
 https://groups.google.com/d/msg/prototype-scriptaculous/-/FBTDmhOjgWoJ.
 To post to this group, send email to
 prototype-scriptaculous@googlegroups.com.
 To unsubscribe from this group, send email to
 prototype-scriptaculous+unsubscr...@googlegroups.com.
 For more options, visit this group at
 http://groups.google.com/group/prototype-scriptaculous?hl=en.


-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.



[Proto-Scripty] Sortable Dragging Items in a list

2011-12-01 Thread marathon
I have a list that I have added a sortable on when I drag a item to
the end of the list the positon or offset in the list moves back up
the list so I can never drag an item to the last item in the list. If
I have ghosting on as I drag the item to the bottom of the list the
ghosted image moves up the screen. I can see the y offset or delta
change as I move up and down the list so the ghosted image move away
or toward my cursor as I move it. Any help would be appreciated.


function alignPositionValues()
{
var idx=1;
$('fieldslist').select('li').each(function(listItem) {

listItem.down('input[type=hidden]').writeAttribute('value',1*idx);
idx = idx + 1;
});
Cookie.set('fieldsscroller', $('fieldsscroller').scrollTop, 
{path:
'/'});
$(button-refresh).click();
}


Event.observe(window,blur,function() {
$('fieldsscroller').scrollTop = (Cookie.get('fieldsscroller') 
|| 0);
});

Event.observe(window,load,function() {
$('fieldsscroller').scrollTop = (Cookie.get('fieldsscroller') 
|| 0);

tsjsSyncTableWidths('fieldslist', 'fieldshdr');
Position.includeScrollOffsets = true;
Sortable.create('fieldslist', {
onUpdate: alignPositionValues,
constraint: 'vertical',
overlap: 'vertical',
ghosting: true,
scroll: 'fieldsscroller'
});
});

div id=fieldsscroller class=listbackground verticalscroller
leftborder bottomborder rightborder style=position:relative; height:
600px;  top:0px; left:0px; overflow-x:auto;
div style=width:100%; height:100%
  ul id=fieldslist style=list-style-type:none; padding:0px;margin:
5px
WEBOBJECT NAME=DisplayFieldsRepetition
WEBOBJECT NAME=FieldItem/WEBOBJECT
/WEBOBJECT
  /ul
/div


Grant Hickey

-- 
You received this message because you are subscribed to the Google Groups 
Prototype  script.aculo.us group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.