right-rails 1.2.2 → 1.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (131) hide show
  1. data/CHANGELOG +7 -0
  2. data/README.rdoc +1 -1
  3. data/Rakefile +1 -1
  4. data/init.rb +1 -0
  5. data/lib/generators/right_rails/right_rails_generator.rb +15 -6
  6. data/lib/right_rails.rb +1 -1
  7. data/lib/right_rails/controller_extensions.rb +28 -15
  8. data/lib/right_rails/helpers/misc.rb +38 -38
  9. data/lib/right_rails/helpers/rails.rb +50 -7
  10. data/lib/rjs_renderer.rb +26 -0
  11. data/spec/lib/right_rails/controller_extensions_spec.rb +25 -14
  12. data/spec/lib/right_rails/helpers/forms_spec.rb +6 -6
  13. data/spec/lib/right_rails/helpers/rails_spec.rb +44 -45
  14. data/vendor/assets/images/rightjs-ui/rte.png +0 -0
  15. data/vendor/assets/javascripts/right-safe-src.js +2 -2
  16. data/vendor/assets/javascripts/right-safe.js +2 -2
  17. data/vendor/assets/javascripts/right-src.js +386 -100
  18. data/vendor/assets/javascripts/right.js +2 -2
  19. data/vendor/assets/javascripts/right/calendar-src.js +19 -3
  20. data/vendor/assets/javascripts/right/calendar.js +2 -2
  21. data/vendor/assets/javascripts/right/colorpicker-src.js +59 -20
  22. data/vendor/assets/javascripts/right/colorpicker.js +2 -2
  23. data/vendor/assets/javascripts/right/i18n/de.js +43 -42
  24. data/vendor/assets/javascripts/right/i18n/es.js +1 -0
  25. data/vendor/assets/javascripts/right/i18n/fi.js +1 -0
  26. data/vendor/assets/javascripts/right/i18n/fr.js +1 -0
  27. data/vendor/assets/javascripts/right/i18n/hu.js +1 -0
  28. data/vendor/assets/javascripts/right/i18n/it.js +1 -0
  29. data/vendor/assets/javascripts/right/i18n/jp.js +1 -0
  30. data/vendor/assets/javascripts/right/i18n/lt.js +96 -0
  31. data/vendor/assets/javascripts/right/i18n/nl.js +1 -0
  32. data/vendor/assets/javascripts/right/i18n/pt-br.js +1 -0
  33. data/vendor/assets/javascripts/right/i18n/ru.js +1 -0
  34. data/vendor/assets/javascripts/right/i18n/ua.js +1 -0
  35. data/vendor/assets/javascripts/right/jquerysh-src.js +4 -4
  36. data/vendor/assets/javascripts/right/jquerysh.js +2 -2
  37. data/vendor/assets/javascripts/right/rails-src.js +51 -15
  38. data/vendor/assets/javascripts/right/rails.js +2 -2
  39. data/vendor/assets/javascripts/right/resizable-src.js +11 -11
  40. data/vendor/assets/javascripts/right/rte-src.js +33 -13
  41. data/vendor/assets/javascripts/right/rte.js +2 -2
  42. data/vendor/assets/javascripts/right/slider-src.js +137 -28
  43. data/vendor/assets/javascripts/right/slider.js +2 -2
  44. metadata +24 -126
  45. data/generators/right_rails/right_rails_generator.rb +0 -46
  46. data/generators/right_rails/templates/iframed.html.erb +0 -10
  47. data/generators/right_scaffold/right_scaffold_generator.rb +0 -53
  48. data/generators/right_scaffold/templates/controller.rb +0 -99
  49. data/generators/right_scaffold/templates/helper.rb +0 -2
  50. data/generators/right_scaffold/templates/layout.html.erb +0 -18
  51. data/generators/right_scaffold/templates/style.css +0 -54
  52. data/generators/right_scaffold/templates/view__form.html.erb +0 -16
  53. data/generators/right_scaffold/templates/view__item.html.erb +0 -13
  54. data/generators/right_scaffold/templates/view_edit.html.erb +0 -6
  55. data/generators/right_scaffold/templates/view_index.html.erb +0 -9
  56. data/generators/right_scaffold/templates/view_new.html.erb +0 -5
  57. data/generators/right_scaffold/templates/view_show.html.erb +0 -10
  58. data/lib/generators/right_rails/templates/iframed.html.erb +0 -10
  59. data/public/images/rightjs-ui/colorpicker.png +0 -0
  60. data/public/images/rightjs-ui/resizable.png +0 -0
  61. data/public/images/rightjs-ui/rte.png +0 -0
  62. data/public/javascripts/right-olds-src.js +0 -652
  63. data/public/javascripts/right-olds.js +0 -9
  64. data/public/javascripts/right-safe-src.js +0 -68
  65. data/public/javascripts/right-safe.js +0 -7
  66. data/public/javascripts/right-src.js +0 -6014
  67. data/public/javascripts/right.js +0 -7
  68. data/public/javascripts/right/autocompleter-src.js +0 -625
  69. data/public/javascripts/right/autocompleter.js +0 -7
  70. data/public/javascripts/right/billboard-src.js +0 -564
  71. data/public/javascripts/right/billboard.js +0 -7
  72. data/public/javascripts/right/calendar-src.js +0 -1464
  73. data/public/javascripts/right/calendar.js +0 -7
  74. data/public/javascripts/right/casting-src.js +0 -183
  75. data/public/javascripts/right/casting.js +0 -7
  76. data/public/javascripts/right/colorpicker-src.js +0 -981
  77. data/public/javascripts/right/colorpicker.js +0 -7
  78. data/public/javascripts/right/dialog-src.js +0 -768
  79. data/public/javascripts/right/dialog.js +0 -7
  80. data/public/javascripts/right/dnd-src.js +0 -591
  81. data/public/javascripts/right/dnd.js +0 -7
  82. data/public/javascripts/right/effects-src.js +0 -508
  83. data/public/javascripts/right/effects.js +0 -7
  84. data/public/javascripts/right/i18n/de.js +0 -95
  85. data/public/javascripts/right/i18n/en-us.js +0 -11
  86. data/public/javascripts/right/i18n/es.js +0 -95
  87. data/public/javascripts/right/i18n/fi.js +0 -96
  88. data/public/javascripts/right/i18n/fr.js +0 -95
  89. data/public/javascripts/right/i18n/hu.js +0 -100
  90. data/public/javascripts/right/i18n/it.js +0 -95
  91. data/public/javascripts/right/i18n/jp.js +0 -99
  92. data/public/javascripts/right/i18n/nl.js +0 -95
  93. data/public/javascripts/right/i18n/pt-br.js +0 -95
  94. data/public/javascripts/right/i18n/ru.js +0 -95
  95. data/public/javascripts/right/i18n/ua.js +0 -99
  96. data/public/javascripts/right/in-edit-src.js +0 -373
  97. data/public/javascripts/right/in-edit.js +0 -7
  98. data/public/javascripts/right/jquerysh-src.js +0 -362
  99. data/public/javascripts/right/jquerysh.js +0 -7
  100. data/public/javascripts/right/json-src.js +0 -147
  101. data/public/javascripts/right/json.js +0 -7
  102. data/public/javascripts/right/keys-src.js +0 -87
  103. data/public/javascripts/right/keys.js +0 -7
  104. data/public/javascripts/right/lightbox-src.js +0 -931
  105. data/public/javascripts/right/lightbox.js +0 -7
  106. data/public/javascripts/right/rails-src.js +0 -402
  107. data/public/javascripts/right/rails.js +0 -7
  108. data/public/javascripts/right/rater-src.js +0 -384
  109. data/public/javascripts/right/rater.js +0 -7
  110. data/public/javascripts/right/resizable-src.js +0 -465
  111. data/public/javascripts/right/resizable.js +0 -7
  112. data/public/javascripts/right/rte-src.js +0 -2685
  113. data/public/javascripts/right/rte.js +0 -7
  114. data/public/javascripts/right/selectable-src.js +0 -725
  115. data/public/javascripts/right/selectable.js +0 -7
  116. data/public/javascripts/right/sizzle-src.js +0 -1132
  117. data/public/javascripts/right/sizzle.js +0 -7
  118. data/public/javascripts/right/slider-src.js +0 -395
  119. data/public/javascripts/right/slider.js +0 -7
  120. data/public/javascripts/right/sortable-src.js +0 -430
  121. data/public/javascripts/right/sortable.js +0 -7
  122. data/public/javascripts/right/table-src.js +0 -176
  123. data/public/javascripts/right/table.js +0 -7
  124. data/public/javascripts/right/tabs-src.js +0 -1157
  125. data/public/javascripts/right/tabs.js +0 -7
  126. data/public/javascripts/right/tags-src.js +0 -745
  127. data/public/javascripts/right/tags.js +0 -7
  128. data/public/javascripts/right/tooltips-src.js +0 -331
  129. data/public/javascripts/right/tooltips.js +0 -7
  130. data/public/javascripts/right/uploader-src.js +0 -302
  131. data/public/javascripts/right/uploader.js +0 -7
@@ -1,7 +0,0 @@
1
- /**
2
- * RightJS-UI Autocompleter v2.2.1
3
- * http://rightjs.org/ui/autocompleter
4
- *
5
- * Copyright (C) 2010-2011 Nikolay Nemshilov
6
- */
7
- var Autocompleter=RightJS.Autocompleter=function(a,b){function g(a,c,d){var e=this.reAnchor||(this.reAnchor=new b.Element("div",{"class":"rui-re-anchor"})).insert(this),f=e.insertTo(a,"after").position(),g=a.dimensions(),h=this,i=parseInt(a.getStyle("borderTopWidth")),j=parseInt(a.getStyle("borderLeftWidth")),k=parseInt(a.getStyle("borderRightWidth")),l=parseInt(a.getStyle("borderBottomWidth")),m=g.top-f.y+i,n=g.left-f.x+j,o=g.width-j-k,p=g.height-i-l;h.setStyle("visibility:hidden").show(null),c==="right"?n+=o-h.size().x:m+=p,h.moveTo(n,m),d&&(c==="left"||c==="right"?h.setHeight(p):h.setWidth(o)),h.setStyle("visibility:visible").hide(null)}function f(a,c,d,e){b.Fx&&(d===undefined&&(d=a.options.fxName,e===undefined&&(e={duration:a.options.fxDuration,onFinish:b(a.fire).bind(a,c)},c==="hide"&&(e.duration=(b.Fx.Durations[e.duration]||e.duration)/2)))),(!b.Fx||!d)&&a.fire(c);return a.$super(d,e)}function c(a,c){c||(c=a,a="DIV");var d=new b.Class(b.Element.Wrappers[a]||b.Element,{initialize:function(c,d){this.key=c;var e=[{"class":"rui-"+c}];this instanceof b.Input||this instanceof b.Form||e.unshift(a),this.$super.apply(this,e),b.isString(d)&&(d=b.$(d)),d instanceof b.Element&&(this._=d._,"$listeners"in d&&(d.$listeners=d.$listeners),d={}),this.setOptions(d,this);return b.Wrapper.Cache[b.$uid(this._)]=this},setOptions:function(a,c){c&&(a=b.Object.merge(a,(new Function("return "+(c.get("data-"+this.key)||"{}")))())),a&&b.Options.setOptions.call(this,b.Object.merge(this.options,a));return this}}),e=new b.Class(d,c);b.Observer.createShortcuts(e.prototype,e.EVENTS||b([]));return e}var d=new b.Class(b.Element,{initialize:function(a){this.$super("div",{"class":"rui-spinner"}),this.dots=[];for(var c=0;c<(a||4);c++)this.dots.push(new b.Element("div"));this.dots[0].addClass("glowing"),this.insert(this.dots),b(this.shift).bind(this).periodical(300)},shift:function(){if(this.visible()){var a=this.dots.pop();this.dots.unshift(a),this.insert(a,"top")}}}),e={show:function(a,b){this.constructor.current=this;return f(this,"show",a,b)},hide:function(a,b){this.constructor.current=null;return f(this,"show",a,b)},showAt:function(a,c,d){this.hide(null).shownAt=a=b.$(a),g.call(this,a,c,d);return this.show()},toggleAt:function(a,b,c){return this.hidden()?this.showAt(a,b,c):this.hide()}},h=b,i=b.$,j=b.$w,k=b.$E,l=b.Xhr,m=b.RegExp,n=b.isArray,o=new c("UL",{include:e,extend:{version:"2.2.1",EVENTS:j("show hide update load select done"),Options:{url:a.location.href,param:"search",method:"get",minLength:1,threshold:200,cache:!0,local:null,fxName:"slide",fxDuration:"short",spinner:"native",cssRule:"input[data-autocompleter]"}},initialize:function(a,b){this.input=i(a),this.$super("autocompleter",b).addClass("rui-dd-menu").onMousedown(this.clicked),this.input.autocompleter=this},destroy:function(){delete this.input.autocompleter;return this},prev:function(){return this.pick("prev")},next:function(){return this.pick("next")},done:function(a){a=a||this.first("li.current"),a&&(a.radioClass("current"),this.input.setValue(a._.textContent||a._.innerText),this.fire("done"));return this.hide()},setOptions:function(a){this.$super(a,this.input),a=this.options,h(a.url).includes("%{search}")||(a.url+=(h(a.url).includes("?")?"&":"?")+a.param+"=%{search}")},pick:function(a){var b=this.children(),c=b.first("hasClass","current"),d=b.indexOf(c);a=="prev"?c=d<1?b.last():b[d<0?0:d-1]:a=="next"&&(c=d<0||d==b.length-1?b.first():b[d+1]);return this.fire("select",{item:c.radioClass("current")})},clicked:function(a){this.done(a.stop().find("li"))},keypressed:function(a){if(this.input.value().length<this.options.minLength)return this.hide();this.timeout&&this.timeout.cancel(),this.timeout=h(this.trigger).bind(this).delay(this.options.threshold)},trigger:function(){this.timeout=null,this.cache=this.cache||{};var a=this.input.value(),b=this.options;if(a.length<b.minLength)return this.hide();this.cache[a]?this.suggest(this.cache[a],a):n(b.local)?this.suggest(this.findLocal(a),a):this.request=l.load(b.url.replace("%{search}",encodeURIComponent(a)),{method:b.method,spinner:this.getSpinner(),onComplete:h(function(b){this.fire("load").suggest(b.text,a)}).bind(this)})},suggest:function(a,b){this.options.cache&&(this.cache[b]=a);if(h(a).blank())this.hide();else{this.update(a.replace(/<ul[^>]*>|<\/ul>/im,"")),this.fire("update");if(!this._connected||this.hidden())this.showAt(this.input,"bottom","resize"),this._connected=!0}return this},findLocal:function(a){var b=new m("("+m.escape(a)+")","ig");return h(this.options.local).map(function(a){if(a.match(b))return"<li>"+a.replace(b,"<strong>$1</strong>")+"</li>"}).compact().join("")},getSpinner:function(){var a=this.options,b=a.spinner;b=="native"&&(b=a.spinner=(new d(3)).insertTo(this),b.addClass("rui-autocompleter-spinner")),b instanceof d&&g.call(b,this.input,"right","resize");return b}});i(a).on({focus:function(a){var c=a.target;c&&c instanceof b.Element&&(c.autocompleter||c.match(o.Options.cssRule))&&(c.autocompleter||new o(c))},blur:function(a){var b=a.target?a.target.autocompleter:null;b&&b.visible()&&b.hide()},keydown:function(a){var b=a.target?a.target.autocompleter:null;if(b&&b.visible()){var c=({27:"hide",38:"prev",40:"next",13:"done"})[a.keyCode];c&&(a.stop(),b[c]())}},keyup:function(a){var b=a.target?a.target.autocompleter:null;b&&!h([9,27,37,38,39,40,13]).include(a.keyCode)&&b.keypressed(a)}});var p=a.createElement("style"),q=a.createTextNode("*.rui-dd-menu, *.rui-dd-menu li{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none} *.rui-dd-menu{display:none;position:absolute;z-index:9999;background:white;border:1px solid #BBB;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;box-shadow:#DDD .2em .2em .4em;-moz-box-shadow:#DDD .2em .2em .4em;-webkit-box-shadow:#DDD .2em .2em .4em} *.rui-dd-menu li{padding:.2em .4em;border-top:none;border-bottom:none;cursor:pointer} *.rui-dd-menu li.current{background:#DDD} *.rui-dd-menu li:hover{background:#EEE}dl.rui-dd-menu dt{padding:.3em .5em;cursor:default;font-weight:bold;font-style:italic;color:#444;background:#EEE}dl.rui-dd-menu dd li{padding-left:1.5em}div.rui-spinner,div.rui-spinner div{margin:0;padding:0;border:none;background:none;list-style:none;font-weight:normal;float:none;display:inline-block; *display:inline; *zoom:1;border-radius:.12em;-moz-border-radius:.12em;-webkit-border-radius:.12em}div.rui-spinner{text-align:center;white-space:nowrap;background:#EEE;border:1px solid #DDD;height:1.2em;padding:0 .2em}div.rui-spinner div{width:.4em;height:70%;background:#BBB;margin-left:1px}div.rui-spinner div:first-child{margin-left:0}div.rui-spinner div.glowing{background:#777}div.rui-re-anchor{margin:0;padding:0;background:none;border:none;float:none;display:inline;position:absolute;z-index:9999}.rui-autocompleter{border-top-color:#DDD !important;border-top-left-radius:0 !important;border-top-right-radius:0 !important;-moz-border-radius-topleft:0 !important;-moz-border-radius-topright:0 !important;-webkit-border-top-left-radius:0 !important;-webkit-border-top-right-radius:0 !important}.rui-autocompleter-spinner{border:none !important;background:none !important;position:absolute;z-index:9999}.rui-autocompleter-spinner div{margin-top:.2em !important; *margin-top:0.1em !important}");p.type="text/css",a.getElementsByTagName("head")[0].appendChild(p),p.styleSheet?p.styleSheet.cssText=q.nodeValue:p.appendChild(q);return o}(document,RightJS)
@@ -1,564 +0,0 @@
1
- /**
2
- * RightJS-UI Billboard v2.2.0
3
- * http://rightjs.org/ui/billboard
4
- *
5
- * Copyright (C) 2010-2011 Nikolay Nemshilov
6
- */
7
- var Billboard = RightJS.Billboard = (function(RightJS) {
8
- /**
9
- * This module defines the basic widgets constructor
10
- * it creates an abstract proxy with the common functionality
11
- * which then we reuse and override in the actual widgets
12
- *
13
- * Copyright (C) 2010-2011 Nikolay Nemshilov
14
- */
15
-
16
- /**
17
- * The widget units constructor
18
- *
19
- * @param String tag-name or Object methods
20
- * @param Object methods
21
- * @return Widget wrapper
22
- */
23
- function Widget(tag_name, methods) {
24
- if (!methods) {
25
- methods = tag_name;
26
- tag_name = 'DIV';
27
- }
28
-
29
- /**
30
- * An Abstract Widget Unit
31
- *
32
- * Copyright (C) 2010 Nikolay Nemshilov
33
- */
34
- var AbstractWidget = new RightJS.Class(RightJS.Element.Wrappers[tag_name] || RightJS.Element, {
35
- /**
36
- * The common constructor
37
- *
38
- * @param Object options
39
- * @param String optional tag name
40
- * @return void
41
- */
42
- initialize: function(key, options) {
43
- this.key = key;
44
- var args = [{'class': 'rui-' + key}];
45
-
46
- // those two have different constructors
47
- if (!(this instanceof RightJS.Input || this instanceof RightJS.Form)) {
48
- args.unshift(tag_name);
49
- }
50
- this.$super.apply(this, args);
51
-
52
- if (RightJS.isString(options)) {
53
- options = RightJS.$(options);
54
- }
55
-
56
- // if the options is another element then
57
- // try to dynamically rewrap it with our widget
58
- if (options instanceof RightJS.Element) {
59
- this._ = options._;
60
- if ('$listeners' in options) {
61
- options.$listeners = options.$listeners;
62
- }
63
- options = {};
64
- }
65
- this.setOptions(options, this);
66
-
67
- return (RightJS.Wrapper.Cache[RightJS.$uid(this._)] = this);
68
- },
69
-
70
- // protected
71
-
72
- /**
73
- * Catches the options
74
- *
75
- * @param Object user-options
76
- * @param Element element with contextual options
77
- * @return void
78
- */
79
- setOptions: function(options, element) {
80
- if (element) {
81
- options = RightJS.Object.merge(options, new Function("return "+(
82
- element.get('data-'+ this.key) || '{}'
83
- ))());
84
- }
85
-
86
- if (options) {
87
- RightJS.Options.setOptions.call(this, RightJS.Object.merge(this.options, options));
88
- }
89
-
90
- return this;
91
- }
92
- });
93
-
94
- /**
95
- * Creating the actual widget class
96
- *
97
- */
98
- var Klass = new RightJS.Class(AbstractWidget, methods);
99
-
100
- // creating the widget related shortcuts
101
- RightJS.Observer.createShortcuts(Klass.prototype, Klass.EVENTS || RightJS([]));
102
-
103
- return Klass;
104
- }
105
-
106
-
107
- /**
108
- * Billboard initialization script
109
- *
110
- * Copyright (C) 2010 Nikolay Nemshilov
111
- */
112
- var R = RightJS,
113
- $ = RightJS.$,
114
- $$ = RightJS.$$,
115
- $w = RightJS.$w,
116
- $E = RightJS.$E,
117
- Fx = RightJS.Fx,
118
- Class = RightJS.Class,
119
- Object = RightJS.Object;
120
-
121
-
122
-
123
-
124
- /**
125
- * Billboards basic class
126
- *
127
- * Copyright (C) 2010-2011 Nikolay Nemshilov
128
- */
129
- var Billboard = new Widget('UL', {
130
- extend: {
131
- version: '2.2.0',
132
-
133
- EVENTS: $w('change first last'),
134
-
135
- Options: {
136
- fxName: 'stripe', // visual effect name
137
- fxDuration: 'long', // visual effect duration
138
-
139
- autostart: true, // if it should automatically start rotate things
140
- delay: 4000, // delay between item shows
141
- loop: true, // loop after reaching the last one
142
-
143
- showButtons: true, // should it show the next/prev buttons or not
144
- prevButton: 'native', // prev item button, 'native' or an ID of your own
145
- nextButton: 'native', // next item button, 'native' or an ID of your own
146
-
147
- stripes: 10, // the number of stripes
148
-
149
- cssRule: '*.rui-billboard'
150
- }
151
- },
152
-
153
- /**
154
- * Basic constructor
155
- *
156
- * @param mixed an element reference
157
- * @return void
158
- */
159
- initialize: function(element) {
160
- this.$super('billboard', element);
161
-
162
- // initializing the buttons
163
- if (this.options.showButtons) {
164
- this.prevButton = this.options.prevButton !== 'native' ? $(this.options.prevButton) :
165
- $E('div', {'class': 'rui-billboard-button-prev', 'html': '&lsaquo;'}).insertTo(this);
166
- this.nextButton = this.options.nextButton !== 'native' ? $(this.options.nextButton) :
167
- $E('div', {'class': 'rui-billboard-button-next', 'html': '&rsaquo;'}).insertTo(this);
168
-
169
- this.prevButton.onClick(R(function(event) {
170
- event.stop(); this.showPrev();
171
- }).bind(this));
172
- this.nextButton.onClick(R(function(event) {
173
- event.stop(); this.showNext();
174
- }).bind(this));
175
- }
176
-
177
- // catching the 'first'/'last' events
178
- this.onChange(function(event) {
179
- if (event.item === this.items().first()) {
180
- this.fire('first');
181
- } else if (event.item === this.items().last()) {
182
- this.fire('last');
183
- }
184
- });
185
-
186
- // stopping/starting the slideshow with mouse over/out events
187
- this.on({
188
- mouseover: function() {
189
- this.stop();
190
- },
191
-
192
- mouseout: function(event) {
193
- if (this.options.autostart && !event.find('.rui-billboard')) {
194
- this.start();
195
- }
196
- }
197
- });
198
-
199
- // autostart
200
- if (this.options.autostart) {
201
- this.start();
202
- }
203
- },
204
-
205
- /**
206
- * Returns the list of items to swap
207
- *
208
- * @return Array swappable items
209
- */
210
- items: function() {
211
- return this.children().without(this.prevButton, this.nextButton);
212
- },
213
-
214
- /**
215
- * Show next item on the list
216
- *
217
- * @return Billboard this
218
- */
219
- showNext: function() {
220
- var items = this.items(), index = items.indexOf(this.current()) + 1;
221
-
222
- if (index == items.length && this.options.loop) {
223
- index = 0;
224
- }
225
-
226
- return this.current(index);
227
- },
228
-
229
- /**
230
- * Show prev item on the list
231
- *
232
- * @return Billboard this
233
- */
234
- showPrev: function() {
235
- var items = this.items(), index = items.indexOf(this.current()) - 1;
236
-
237
- if (index < 0 && this.options.loop) {
238
- index = items.length - 1;
239
- }
240
-
241
- return this.current(index);
242
- },
243
-
244
- /**
245
- * Gets/sets the current item
246
- *
247
- * @param mixed integer index or a LI element reference
248
- * @return Billboard this or current LI element
249
- */
250
- current: function(index) {
251
- var items = this.items();
252
-
253
- if (arguments.length) {
254
- if (index instanceof Element) {
255
- index = items.indexOf(index);
256
- }
257
-
258
- this.runFx(items[index]);
259
- } else {
260
- return items.length ? (
261
- items.first('hasClass', 'rui-billboard-current') ||
262
- items.first().addClass('rui-billboard-current')
263
- ) : null;
264
- }
265
-
266
- return this;
267
- },
268
-
269
- /**
270
- * Starts the slide show
271
- *
272
- * @return Billboard this
273
- */
274
- start: function() {
275
- this.timer = R(this.showNext).bind(this).periodical(this.options.delay);
276
- },
277
-
278
- /**
279
- * stops the slideshow
280
- *
281
- * @return Billboard this
282
- */
283
- stop: function() {
284
- if (this.timer) {
285
- this.timer.stop();
286
- }
287
- },
288
-
289
- /**
290
- * Wrapping the event trigger so it always sent the
291
- * current element references
292
- *
293
- * @param String event name
294
- * @param Object options
295
- * @return Billboard this
296
- */
297
- fire: function(name, options) {
298
- return this.$super(name, Object.merge({
299
- index: this.items().indexOf(this.current()),
300
- item: this.current()
301
- }, options));
302
- },
303
-
304
- // protected
305
-
306
- /**
307
- * Runs the fx transition
308
- *
309
- * @param Element new LI element
310
- * @return void
311
- */
312
- runFx: function(item) {
313
- if (item && !this._running) {
314
- var Fx = Billboard.Fx[R(this.options.fxName || '').capitalize()];
315
-
316
- if (Fx) {
317
- new Fx(this).start(this.current(), item);
318
- } else {
319
- this.current().removeClass('rui-billboard-current');
320
- item.addClass('rui-billboard-current');
321
- }
322
- }
323
- }
324
- });
325
-
326
- /**
327
- * Basic billboard visual effect
328
- *
329
- * Copyright (C) 2010 Nikolay Nemshilov
330
- */
331
- Billboard.Fx = new Class(Fx, {
332
-
333
- /**
334
- * basic constructor
335
- *
336
- * @param Billboard billboard
337
- * @return void
338
- */
339
- initialize: function(billboard) {
340
- this.container = $E('div', {'class': 'rui-billboard-fx-container'});
341
-
342
- this.$super(billboard, {
343
- duration: billboard.options.fxDuration,
344
- onStart: function() {
345
- billboard._running = true;
346
- billboard.insert(this.container);
347
- },
348
- onFinish: function() {
349
- this.container.remove();
350
- billboard._running = false;
351
- billboard.fire('change');
352
- }
353
- });
354
- },
355
-
356
- /**
357
- * Starts an fx on the given item
358
- *
359
- * @param {Element} old LI element
360
- * @param {Element} new LI element
361
- * @return void
362
- */
363
- prepare: function(old_item, new_item) {
364
- old_item.removeClass('rui-billboard-current');
365
- new_item.addClass('rui-billboard-current');
366
-
367
- this.clone = old_item.clone();
368
-
369
- this.container.update(this.clone);
370
- }
371
-
372
- });
373
-
374
- /**
375
- * Fade visual effects class
376
- *
377
- * Copyright (C) 2010 Nikolay Nemshilov
378
- */
379
- Billboard.Fx.Fade = new Class(Billboard.Fx, {
380
-
381
- /**
382
- * Starts an fx on the given item
383
- *
384
- * @param {Element} old LI element
385
- * @param {Element} new LI element
386
- * @return void
387
- */
388
- prepare: function(old_item, new_item) {
389
- this.$super(old_item, new_item);
390
- },
391
-
392
- /**
393
- * Rendering the effect
394
- *
395
- * @param Float delta value
396
- * @return void
397
- */
398
- render: function(delta) {
399
- this.container.setStyle({opacity: 1 - delta});
400
- }
401
-
402
- });
403
-
404
- /**
405
- * The slide visual effects class
406
- *
407
- * Copyright (C) 2010 Nikolay Nemshilov
408
- */
409
- Billboard.Fx.Slide = new Class(Billboard.Fx, {
410
-
411
- /**
412
- * overloading the 'prepare' method to add some stuff
413
- * to the container depending on which direction do we slide
414
- *
415
- * @param {Element} old LI element
416
- * @param {Element} new LI element
417
- * @return void
418
- */
419
- prepare: function(old_item, new_item) {
420
- this._width = this.element.current().size().x;
421
- this._direction = old_item.nextSiblings().include(new_item) ? -1 : 1;
422
-
423
- this.$super(old_item, new_item);
424
-
425
- this.clone.setStyle({width: this._width + 'px'});
426
- },
427
-
428
- /**
429
- * Rendering the Fx
430
- *
431
- * @param Float delta
432
- * @return void
433
- */
434
- render: function(delta) {
435
- this.clone._.style.left = this._direction * this._width * delta + 'px';
436
- }
437
-
438
- });
439
-
440
- /**
441
- * Stripe visual effects class
442
- *
443
- * Copyright (C) 2010-2011 Nikolay Nemshilov
444
- */
445
- Billboard.Fx.Stripe = new Class(Billboard.Fx, {
446
-
447
- directions: ['down', 'up', 'left', 'right'],
448
-
449
- /**
450
- * Breaking the original element onto sripes in here
451
- *
452
- * @param {Element} old LI element
453
- * @param {Element} new LI element
454
- * @return void
455
- */
456
- prepare: function(old_item, new_item) {
457
- this.$super(old_item, new_item);
458
-
459
- var length = this.element.options.stripes,
460
- width = this.element.items()[0].size().x / length,
461
- delay = 100,
462
- direction = this.directions.shift();
463
-
464
- this.directions.push(direction);
465
- this.container.clean();
466
-
467
- for (var i=0; i < length; i++) {
468
- var stripe = $E('div', {
469
- 'class': 'rui-billboard-stripe',
470
- 'style': {
471
- width: width + 1 + 'px',
472
- left: i * width + 'px'
473
- }
474
- }).insert(old_item.clone().setStyle({
475
- width: width * length + 'px',
476
- left: - i * width + 'px'
477
- }));
478
-
479
- this.container.append(stripe);
480
- var options = {
481
- duration: this.options.duration
482
- };
483
-
484
- if (direction !== 'right' && i === (length - 1) || (direction === 'right' && i === 0)) {
485
- options.onFinish = R(this.finish).bind(this, true);
486
- }
487
-
488
- switch (direction) {
489
- case 'up':
490
- R(function(stripe, options) {
491
- stripe.setHeight(stripe.size().y);
492
- stripe.morph({height: '0px'}, options);
493
- }).bind(this, stripe, options).delay(i * delay);
494
- break;
495
-
496
- case 'down':
497
- stripe.setStyle('top: auto; bottom: 0px');
498
- R(function(stripe, options) {
499
- stripe.setHeight(stripe.size().y);
500
- stripe.morph({height: '0px'}, options);
501
- }).bind(this, stripe, options).delay(i * delay);
502
- break;
503
-
504
- case 'left':
505
- R(function(stripe, options) {
506
- stripe.morph({width: '0px'}, options);
507
- }).bind(this, stripe, options).delay(i * delay);
508
- break;
509
-
510
- case 'right':
511
- R(function(stripe, options) {
512
- stripe.morph({width: '0px'}, options);
513
- }).bind(this, stripe, options).delay((length - i -1) * delay);
514
- break;
515
-
516
- default:
517
- this.finish(true);
518
- }
519
- }
520
- },
521
-
522
-
523
- /**
524
- * Stubbing the finish method so it didn't finish prematurely
525
- *
526
- * @return Fx this
527
- */
528
- finish: function(for_sure) {
529
- if (for_sure) {
530
- this.$super();
531
- }
532
- return this;
533
- }
534
-
535
- });
536
-
537
- /**
538
- * Document level hooks for billboards
539
- *
540
- * Copyright (C) 2010 Nikolay Nemshilov
541
- */
542
- $(document).onReady(function() {
543
- $$(Billboard.Options.cssRule).each(function(element) {
544
- if (!(element instanceof Billboard)) {
545
- element = new Billboard(element);
546
- }
547
- });
548
- });
549
-
550
- var embed_style = document.createElement('style'),
551
- embed_rules = document.createTextNode("*.rui-billboard, *.rui-billboard> *{margin:0;padding:0;list-style:none} *.rui-billboard{display:inline-block; *display:inline; *zoom:1;position:relative} *.rui-billboard> *{display:none;width:100%;height:100%} *.rui-billboard> *:first-child, *.rui-billboard> *.rui-billboard-current:first-child{display:block;position:relative} *.rui-billboard> *>img{margin:0;padding:0} *.rui-billboard-current{position:absolute;left:0;top:0;display:block;z-index:999} *.rui-billboard-button-prev, *.rui-billboard-button-next{position:absolute;z-index:99999;left:.25em;top:auto;bottom:.25em;display:block;width:.5em;height:auto;text-align:center;font-size:200%;font-family:Arial;font-weight:bold;padding:0em .5em .2em .5em;background:white;opacity:0;filter:alpha(opacity:0);cursor:pointer;border:.12em solid #888;border-radius:.2em;-moz-border-radius:.2em;-webkit-border-radius:.2em;user-select:none;-moz-user-select:none;-webkit-user-select:none;transition:opacity .3s ease-in-out;-o-transition:opacity .3s ease-in-out;-moz-transition:opacity .3s ease-in-out;-webkit-transition:opacity .3s ease-in-out} *.rui-billboard-button-next{left:auto;right:.25em;text-align:right} *.rui-billboard-button-prev:active{text-indent:-.1em} *.rui-billboard-button-next:active{text-indent:.2em} *.rui-billboard:hover *.rui-billboard-button-prev, *.rui-billboard:hover *.rui-billboard-button-next{opacity:0.4;filter:alpha(opacity:40)} *.rui-billboard:hover *.rui-billboard-button-prev:hover, *.rui-billboard:hover *.rui-billboard-button-next:hover{opacity:0.7;filter:alpha(opacity:70)}.rui-billboard-fx-container{position:absolute;left:0;top:0;display:block;z-index:9999;overflow:hidden}.rui-billboard-fx-container> *{position:absolute;left:0;top:0}.rui-billboard-stripe{overflow:hidden}.rui-billboard-stripe> *{position:relative}");
552
-
553
- embed_style.type = 'text/css';
554
- document.getElementsByTagName('head')[0].appendChild(embed_style);
555
-
556
- if(embed_style.styleSheet) {
557
- embed_style.styleSheet.cssText = embed_rules.nodeValue;
558
- } else {
559
- embed_style.appendChild(embed_rules);
560
- }
561
-
562
-
563
- return Billboard;
564
- })(RightJS);