right-rails 1.0.9 → 1.0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,167 @@
1
+ /**
2
+ * Tables specific dom-wrapper
3
+ *
4
+ * Copyright (C) 2010 Nikolay Nemshilov
5
+ */
6
+ var Table = RightJS.Table = (function(RightJS) {
7
+ /**
8
+ * Tables specific dom-wrapper
9
+ *
10
+ * Copyright (C) 2010 Nikolay Nemshilov
11
+ */
12
+
13
+ /**
14
+ * Table plugin initialization script
15
+ *
16
+ * Copyright (C) 2010 Nikolay Nemshilov
17
+ */
18
+ var R = RightJS,
19
+ $ = RightJS.$,
20
+ $E = RightJS.$E,
21
+ isHash = RightJS.isHash,
22
+ isElement = RightJS.isElement,
23
+ Class = RightJS.Class,
24
+ Object = RightJS.Object,
25
+ Element = RightJS.Element;
26
+
27
+
28
+
29
+ var Table = Element.Wrappers.TABLE = new Class(Element, {
30
+
31
+ extend: {
32
+ Options: {
33
+ ascMarker: '▼', // asc marker content
34
+ descMarker: '▲', // desc marker content
35
+ algorithm: 'text', // default sorting algorithm 'text' or 'numeric'
36
+ order: 'asc' // default order
37
+ }
38
+ },
39
+
40
+ /**
41
+ * Basic constructor
42
+ *
43
+ * @param mixed raw dom-element or an options list
44
+ * @return void
45
+ */
46
+ initialize: function(arg) {
47
+ var options = arg || {}, element = options;
48
+
49
+ if (isHash(options) && !isElement(options)) {
50
+ element = 'table';
51
+ }
52
+
53
+ this.$super(element, options);
54
+
55
+ this.options = Object.merge(
56
+ Table.Options, eval('('+ this.get('data-table') + ')')
57
+ );
58
+ },
59
+
60
+ /**
61
+ * Sorts the table by the given index
62
+ *
63
+ * @param mixed Number column index or TH element
64
+ * @param String order direction 'asc' or 'desc'
65
+ * @param String optional algorythm 'string', 'numeric'
66
+ * @return Table this
67
+ */
68
+ sort: function(index, direction, algorithm) {
69
+ var th = index instanceof Element ? index : this.header().last().children('th')[index];
70
+ if (!th) { return this; } // in case something goes wrong
71
+
72
+ // reading data from the TH cell
73
+ index = th.parent().children('th').indexOf(th);
74
+ direction = direction || (this.marker && this.marker.parent() === th ? this.marker.asc ? 'desc' : 'asc' : null);
75
+ algorithm = algorithm || (th.hasClass('numeric') ? 'numeric' : null);
76
+
77
+ // handling the fallback from the options
78
+ direction = direction || this.options.order;
79
+ algorithm = algorithm || this.options.algorithm;
80
+
81
+ // collecting the list of sortable rows
82
+ var rows = this.rows().map(function(row) {
83
+ var cell = row.children('td')[index], text = cell ? cell.text() : '';
84
+
85
+ if (algorithm === 'numeric') {
86
+ text = R(text).toFloat();
87
+ }
88
+
89
+ return { row: row, text: text };
90
+ });
91
+
92
+ // creating an anchor where to insert the rows
93
+ var anchor = rows[0] ?
94
+ $E('tr').insertTo(rows[0].row, 'before') :
95
+ $E('tr').insertTo(this.first('tbody') || this);
96
+
97
+ // finding the exact sorting algorithm
98
+ if (typeof(algorithm) !== 'function') {
99
+ algorithm = direction === 'asc' ? function(a, b) {
100
+ return a.text > b.text ? 1 : a.text < b.text ? -1 : 0;
101
+ } : function(a, b) {
102
+ return a.text > b.text ? -1 : a.text < b.text ? 1 : 0;
103
+ };
104
+ }
105
+
106
+ // sorting the rows and reinsert them in the correct order
107
+ rows.sort(algorithm).reverse().each(function(hash) {
108
+ anchor.insert(hash.row, 'after');
109
+ });
110
+
111
+ anchor.remove();
112
+
113
+ // putting the sorting marker
114
+ this.marker = (
115
+ this.marker || th.first('span.sort-marker') || $E('span', {'class': 'sort-marker'})
116
+ ).update(
117
+ this.options[direction === 'asc' ? 'ascMarker' : 'descMarker']
118
+ ).insertTo(th, 'bottom');
119
+ this.marker.asc = direction === 'asc';
120
+
121
+ return this;
122
+ },
123
+
124
+ /**
125
+ * Returns the table data-rows
126
+ *
127
+ * @return Array table data rows
128
+ */
129
+ rows: function() {
130
+ return this.find('tr').reject(function(row) {
131
+ return row.first('th') || row.parent('tfoot');
132
+ });
133
+ },
134
+
135
+ /**
136
+ * Returns the table header rows
137
+ *
138
+ * @return Array table header rows
139
+ */
140
+ header: function() {
141
+ return this.find('tr').filter('first', 'th');
142
+ },
143
+
144
+ /**
145
+ * Returns the table footer rows
146
+ *
147
+ * @return Array table footer rows
148
+ */
149
+ footer: function() {
150
+ return this.find('tfoot > tr');
151
+ }
152
+ });
153
+
154
+ /**
155
+ * Document level hooks for the table plugin
156
+ *
157
+ * Copyright (C) 2010 Nikolay Nemshilov
158
+ */
159
+ $(document).onClick(function(event) {
160
+ var th = event.find('th.sortable');
161
+
162
+ if (th) {
163
+ th.parent('table').sort(th);
164
+ }
165
+ });
166
+ return Table;
167
+ })(RightJS);
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Tables specific dom-wrapper
3
+ *
4
+ * Copyright (C) 2010 Nikolay Nemshilov
5
+ */
6
+ var Table=RightJS.Table=function(e){var m=e.$,h=e.$E,n=e.isHash,o=e.isElement,p=e.Object,i=e.Element,k=i.Wrappers.TABLE=new e.Class(i,{extend:{Options:{ascMarker:"&#x25BC;",descMarker:"&#x25B2;",algorithm:"text",order:"asc"}},initialize:function(a){var c=a=a||{};if(n(a)&&!o(a))c="table";this.$super(c,a);this.options=p.merge(k.Options,eval("("+this.get("data-table")+")"))},sort:function(a,c,f){var g=a instanceof i?a:this.header().last().children("th")[a];if(!g)return this;a=g.parent().children("th").indexOf(g);
7
+ c=c||(this.marker&&this.marker.parent()===g?this.marker.asc?"desc":"asc":null);f=f||(g.hasClass("numeric")?"numeric":null);c=c||this.options.order;f=f||this.options.algorithm;var j=this.rows().map(function(d){var b=d.children("td")[a];b=b?b.text():"";if(f==="numeric")b=e(b).toFloat();return{row:d,text:b}}),l=j[0]?h("tr").insertTo(j[0].row,"before"):h("tr").insertTo(this.first("tbody")||this);if(typeof f!=="function")f=c==="asc"?function(d,b){return d.text>b.text?1:d.text<b.text?-1:0}:function(d,b){return d.text>
8
+ b.text?-1:d.text<b.text?1:0};j.sort(f).reverse().each(function(d){l.insert(d.row,"after")});l.remove();this.marker=(this.marker||g.first("span.sort-marker")||h("span",{"class":"sort-marker"})).update(this.options[c==="asc"?"ascMarker":"descMarker"]).insertTo(g,"bottom");this.marker.asc=c==="asc";return this},rows:function(){return this.find("tr").reject(function(a){return a.first("th")||a.parent("tfoot")})},header:function(){return this.find("tr").filter("first","th")},footer:function(){return this.find("tfoot > tr")}});
9
+ m(document).onClick(function(a){(a=a.find("th.sortable"))&&a.parent("table").sort(a)});return k}(RightJS);
@@ -44,7 +44,7 @@ PROTO = 'prototype', A_proto = Array[PROTO],
44
44
  to_s = Object[PROTO].toString, slice = A_proto.slice,
45
45
  dummy = function() { return function() {}; },
46
46
  HTML = document.documentElement, UID = 1, // !#server
47
- Wrappers_Cache = [], UID_KEY = '_rjs_id', // !#server
47
+ Wrappers_Cache = [], UID_KEY = '_rjs_id',
48
48
 
49
49
  /**
50
50
  * extends the first object with the keys and values of the second one
@@ -1368,9 +1368,11 @@ var Class = RightJS.Class = function() {
1368
1368
  var args = $A(arguments), properties = args.pop() || {},
1369
1369
  parent = args.pop();
1370
1370
 
1371
+ // !#server:begin
1371
1372
  if (parent && parent.ancestors && parent.ancestors[0] === Wrapper) {
1372
1373
  return new Wrapper(parent, properties);
1373
1374
  }
1375
+ // !#server:end
1374
1376
 
1375
1377
  // basic class object definition
1376
1378
  function klass() {
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: right-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 5
4
+ hash: 3
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 9
10
- version: 1.0.9
9
+ - 10
10
+ version: 1.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Nikolay Nemshilov
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-10-17 00:00:00 +04:00
18
+ date: 2010-10-24 00:00:00 +04:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -45,10 +45,14 @@ files:
45
45
  - public/images/rightjs-ui/resizable.png
46
46
  - public/javascripts/right/autocompleter-src.js
47
47
  - public/javascripts/right/autocompleter.js
48
+ - public/javascripts/right/billboard-src.js
49
+ - public/javascripts/right/billboard.js
48
50
  - public/javascripts/right/calendar-src.js
49
51
  - public/javascripts/right/calendar.js
50
52
  - public/javascripts/right/colorpicker-src.js
51
53
  - public/javascripts/right/colorpicker.js
54
+ - public/javascripts/right/dialog-src.js
55
+ - public/javascripts/right/dialog.js
52
56
  - public/javascripts/right/dnd-src.js
53
57
  - public/javascripts/right/dnd.js
54
58
  - public/javascripts/right/effects-src.js
@@ -87,6 +91,8 @@ files:
87
91
  - public/javascripts/right/slider.js
88
92
  - public/javascripts/right/sortable-src.js
89
93
  - public/javascripts/right/sortable.js
94
+ - public/javascripts/right/table-src.js
95
+ - public/javascripts/right/table.js
90
96
  - public/javascripts/right/tabs-src.js
91
97
  - public/javascripts/right/tabs.js
92
98
  - public/javascripts/right/tooltips-src.js