Magazento_Productivity - Version 1.0.1

Version Notes

Fist stable

Download this release

Release Info

Developer volgodark
Extension Magazento_Productivity
Version 1.0.1
Comparing to
See all releases


Code changes from version 1.0.0 to 1.0.1

app/etc/modules/Ip_Productactivity.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Ip_Productactivity>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Ip_Productactivity>
8
+ </modules>
9
+ </config>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magazento_Productivity</name>
4
- <version>1.0.0</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Show best, popular, new reviews and new products and reviews to your customers</summary>
10
  <description>Show best, popular, new reviews and new products and reviews to your customers</description>
11
- <notes>test community release</notes>
12
- <authors><author><name>volgodark</name><user>auto-converted</user><email>volgodark@gmail.com</email></author></authors>
13
  <date>2012-12-03</date>
14
- <time>22:17:50</time>
15
- <contents><target name="magecommunity"><dir name="Ip"><dir name="Productactivity"><dir name="Block"><file name="Developer.php" hash="e779bd431338e7f703148338ef02fdc4"/><file name="New.php" hash="c05d663f09f242ef8bbdf04dbf5925a9"/><file name="Popular.php" hash="d296c325bbc3fcd51d839e559e0baa6b"/><file name="Review.php" hash="d79ceddd7d74c6cf77c94e7d04b808bc"/><file name="Toprated.php" hash="413c113f5849eb5b055fc071d3df33c2"/><file name="Topsell.php" hash="a3172ab702d3e7ef2c5844407098cfd9"/></dir><dir name="Helper"><file name="Data.php" hash="ca7d799b81f41b7098e04ce0daefaa8d"/></dir><dir name="Model"><file name="Data.php" hash="0f41804ab583e2fef0eae3e98e7810b4"/></dir><dir name="etc"><file name="config.xml" hash="c1974d781b7e2eae921b158c249cd929"/><file name="system.xml" hash="aacdce560d44c6c8b2bb29176168924d"/></dir></dir></dir></target></contents>
16
  <compatible/>
17
- <dependencies/>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Magazento_Productivity</name>
4
+ <version>1.0.1</version>
5
  <stability>stable</stability>
6
  <license>GPL</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>Show best, popular, new reviews and new products and reviews to your customers</summary>
10
  <description>Show best, popular, new reviews and new products and reviews to your customers</description>
11
+ <notes>Fist stable</notes>
12
+ <authors><author><name>volgodark</name><user>volgodark</user><email>volgodark@gmail.com</email></author></authors>
13
  <date>2012-12-03</date>
14
+ <time>22:40:58</time>
15
+ <contents><target name="magecommunity"><dir name="Ip"><dir name="Productactivity"><dir name="Block"><file name="Developer.php" hash="e779bd431338e7f703148338ef02fdc4"/><file name="New.php" hash="c05d663f09f242ef8bbdf04dbf5925a9"/><file name="Popular.php" hash="d296c325bbc3fcd51d839e559e0baa6b"/><file name="Review.php" hash="d79ceddd7d74c6cf77c94e7d04b808bc"/><file name="Toprated.php" hash="413c113f5849eb5b055fc071d3df33c2"/><file name="Topsell.php" hash="a3172ab702d3e7ef2c5844407098cfd9"/></dir><dir name="Helper"><file name="Data.php" hash="ca7d799b81f41b7098e04ce0daefaa8d"/></dir><dir name="Model"><file name="Data.php" hash="0f41804ab583e2fef0eae3e98e7810b4"/></dir><dir name="etc"><file name="config.xml" hash="c1974d781b7e2eae921b158c249cd929"/><file name="system.xml" hash="aacdce560d44c6c8b2bb29176168924d"/></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><file name="ip_productactivity.xml" hash=""/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Ip_Productactivity.xml" hash="8bc75d6951ff272798ae6b97bbbae8c6"/></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="ip_productactivity"><dir name="img"><file name="all.gif" hash="8a5e2259f5cbf06bdbf303a258be4590"/><file name="drop.gif" hash="1be9ffe42c8d599225596272663e3e06"/><file name="drop.png" hash="4178363d189e1a18093bf7412a0b7808"/><file name="home.png" hash="31fed0cd2dfe3ed662ed92a9cb4af580"/><file name="menu_tabs_sprite.png" hash="16fcb5977b65ca67b0f20008d950afba"/></dir><file name="livepipe.js" hash="3f8ee3a15b811a4a11817f1662599213"/><file name="promo.jpg" hash="8e34bc79c2f2927ce674471e463cddc0"/><file name="style.css" hash="a746f2398f2c450e8f1e62782cd6ece4"/><file name="tabs.css" hash="21d3a70626a48d4e039a774fc66eefd4"/><file name="tabs.js" hash="bbdba6abfaef6a655ef12e61f3eb2f90"/></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.1.1</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
skin/frontend/base/default/ip_productactivity/img/all.gif ADDED
Binary file
skin/frontend/base/default/ip_productactivity/img/drop.gif ADDED
Binary file
skin/frontend/base/default/ip_productactivity/img/drop.png ADDED
Binary file
skin/frontend/base/default/ip_productactivity/img/home.png ADDED
Binary file
skin/frontend/base/default/ip_productactivity/img/menu_tabs_sprite.png ADDED
Binary file
skin/frontend/base/default/ip_productactivity/livepipe.js ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/core
7
+ * @require prototype.js
8
+ */
9
+
10
+ if(typeof(Control) == 'undefined')
11
+ Control = {};
12
+
13
+ var $proc = function(proc){
14
+ return typeof(proc) == 'function' ? proc : function(){return proc};
15
+ };
16
+
17
+ var $value = function(value){
18
+ return typeof(value) == 'function' ? value() : value;
19
+ };
20
+
21
+ Object.Event = {
22
+ extend: function(object){
23
+ object._objectEventSetup = function(event_name){
24
+ this._observers = this._observers || {};
25
+ this._observers[event_name] = this._observers[event_name] || [];
26
+ };
27
+ object.observe = function(event_name,observer){
28
+ if(typeof(event_name) == 'string' && typeof(observer) != 'undefined'){
29
+ this._objectEventSetup(event_name);
30
+ if(!this._observers[event_name].include(observer))
31
+ this._observers[event_name].push(observer);
32
+ }else
33
+ for(var e in event_name)
34
+ this.observe(e,event_name[e]);
35
+ };
36
+ object.stopObserving = function(event_name,observer){
37
+ this._objectEventSetup(event_name);
38
+ if(event_name && observer)
39
+ this._observers[event_name] = this._observers[event_name].without(observer);
40
+ else if(event_name)
41
+ this._observers[event_name] = [];
42
+ else
43
+ this._observers = {};
44
+ };
45
+ object.observeOnce = function(event_name,outer_observer){
46
+ var inner_observer = function(){
47
+ outer_observer.apply(this,arguments);
48
+ this.stopObserving(event_name,inner_observer);
49
+ }.bind(this);
50
+ this._objectEventSetup(event_name);
51
+ this._observers[event_name].push(inner_observer);
52
+ };
53
+ object.notify = function(event_name){
54
+ this._objectEventSetup(event_name);
55
+ var collected_return_values = [];
56
+ var args = $A(arguments).slice(1);
57
+ try{
58
+ for(var i = 0; i < this._observers[event_name].length; ++i)
59
+ collected_return_values.push(this._observers[event_name][i].apply(this,args) || null);
60
+ }catch(e){
61
+ if(e == $break)
62
+ return false;
63
+ else
64
+ throw e;
65
+ }
66
+ return collected_return_values;
67
+ };
68
+ if(object.prototype){
69
+ object.prototype._objectEventSetup = object._objectEventSetup;
70
+ object.prototype.observe = object.observe;
71
+ object.prototype.stopObserving = object.stopObserving;
72
+ object.prototype.observeOnce = object.observeOnce;
73
+ object.prototype.notify = function(event_name){
74
+ if(object.notify){
75
+ var args = $A(arguments).slice(1);
76
+ args.unshift(this);
77
+ args.unshift(event_name);
78
+ object.notify.apply(object,args);
79
+ }
80
+ this._objectEventSetup(event_name);
81
+ var args = $A(arguments).slice(1);
82
+ var collected_return_values = [];
83
+ try{
84
+ if(this.options && this.options[event_name] && typeof(this.options[event_name]) == 'function')
85
+ collected_return_values.push(this.options[event_name].apply(this,args) || null);
86
+ var callbacks_copy = this._observers[event_name]; // since original array will be modified after observeOnce calls
87
+ for(var i = 0; i < callbacks_copy.length; ++i)
88
+ collected_return_values.push(callbacks_copy[i].apply(this,args) || null);
89
+ }catch(e){
90
+ if(e == $break)
91
+ return false;
92
+ else
93
+ throw e;
94
+ }
95
+ return collected_return_values;
96
+ };
97
+ }
98
+ }
99
+ };
100
+
101
+ /* Begin Core Extensions */
102
+
103
+ //Element.observeOnce
104
+ Element.addMethods({
105
+ observeOnce: function(element,event_name,outer_callback){
106
+ var inner_callback = function(){
107
+ outer_callback.apply(this,arguments);
108
+ Element.stopObserving(element,event_name,inner_callback);
109
+ };
110
+ Element.observe(element,event_name,inner_callback);
111
+ }
112
+ });
113
+
114
+ //mouse:wheel
115
+ (function(){
116
+ function wheel(event){
117
+ var delta, element, custom_event;
118
+ // normalize the delta
119
+ if (event.wheelDelta) { // IE & Opera
120
+ delta = event.wheelDelta / 120;
121
+ } else if (event.detail) { // W3C
122
+ delta =- event.detail / 3;
123
+ }
124
+ if (!delta) { return; }
125
+ element = Event.extend(event).target;
126
+ element = Element.extend(element.nodeType === Node.TEXT_NODE ? element.parentNode : element);
127
+ custom_event = element.fire('mouse:wheel',{ delta: delta });
128
+ if (custom_event.stopped) {
129
+ Event.stop(event);
130
+ return false;
131
+ }
132
+ }
133
+ document.observe('mousewheel',wheel);
134
+ document.observe('DOMMouseScroll',wheel);
135
+ })();
136
+
137
+ /* End Core Extensions */
138
+
139
+ //from PrototypeUI
140
+ var IframeShim = Class.create({
141
+ initialize: function() {
142
+ this.element = new Element('iframe',{
143
+ style: 'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',
144
+ src: 'javascript:void(0);',
145
+ frameborder: 0
146
+ });
147
+ $(document.body).insert(this.element);
148
+ },
149
+ hide: function() {
150
+ this.element.hide();
151
+ return this;
152
+ },
153
+ show: function() {
154
+ this.element.show();
155
+ return this;
156
+ },
157
+ positionUnder: function(element) {
158
+ var element = $(element);
159
+ var offset = element.cumulativeOffset();
160
+ var dimensions = element.getDimensions();
161
+ this.element.setStyle({
162
+ left: offset[0] + 'px',
163
+ top: offset[1] + 'px',
164
+ width: dimensions.width + 'px',
165
+ height: dimensions.height + 'px',
166
+ zIndex: element.getStyle('zIndex') - 1
167
+ }).show();
168
+ return this;
169
+ },
170
+ setBounds: function(bounds) {
171
+ for(prop in bounds)
172
+ bounds[prop] += 'px';
173
+ this.element.setStyle(bounds);
174
+ return this;
175
+ },
176
+ destroy: function() {
177
+ if(this.element)
178
+ this.element.remove();
179
+ return this;
180
+ }
181
+ });
skin/frontend/base/default/ip_productactivity/promo.jpg ADDED
Binary file
skin/frontend/base/default/ip_productactivity/style.css ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .block-productactivity { font-size: 11px; line-height: 1.25; }
2
+ .block-productactivity .products-grid {
3
+ background: none;
4
+ border-bottom: 0;
5
+ position: relative;
6
+ }
7
+ .content-home-wrapper { padding: 10px;}
8
+
9
+ .block-productactivity .title-homepage-new {
10
+ background: none repeat scroll 0 0 #E46404;
11
+ }
12
+ .block-productactivity .title-homepage-topsellers {
13
+ background: none repeat scroll 0 0 #93C627;
14
+ }
15
+ .block-productactivity .title-homepage-popular {
16
+ background: none repeat scroll 0 0 #CC3112;
17
+ }
18
+ .block-productactivity .title-homepage-toprated {
19
+ background: none repeat scroll 0 0 #709CC1;
20
+ }
21
+ .block-productactivity .title-homepage-reviews {
22
+ background: none repeat scroll 0 0 #336699;
23
+ }
24
+
25
+ .block-productactivity .block-title {
26
+ border-bottom: 1px solid #CACACA;
27
+ height: 25px;
28
+ overflow: hidden;
29
+ }
30
+
31
+ .block-productactivity .block-title span {
32
+ color: #FFFFFF;
33
+ font: bold 12px/2em Arial,Helvetica,sans-serif;
34
+ padding: 12px 0 3px 10px;
35
+ text-transform: uppercase;
36
+ }
37
+ .block-productactivity {
38
+ border: 1px solid #B6B6B6;
39
+ color: #333;
40
+ font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
41
+ font-size: 10px;
42
+ margin: 0 0 0px;
43
+ }
44
+
45
+ .block-productactivity .block-title span {
46
+ color: #FFFFFF;
47
+ font: bold 12px/2em Arial,Helvetica,sans-serif;
48
+ padding: 12px 0 3px 10px;
49
+ text-transform: uppercase;
50
+ }
51
+ .block-productactivity .block-content {
52
+ background: #FAF7EE;
53
+ min-height: 400px;
54
+ }
55
+
56
+ .block-productactivity .block-content li.item {
57
+ padding: 7px 9px;
58
+ float: left;
59
+ }
60
+
61
+
62
+ .block-productactivity .block-content .product-name {
63
+ color: #1E7EC8;
64
+ color: #203548;
65
+ font-size: 13px;
66
+ font-weight: bold;
67
+ margin: 0 0 5px;
68
+ }
69
+
70
+ .block-productactivity .products-grid .product-name a {
71
+ color: #1E7EC8;
72
+ }
73
+ .block-productactivity .block-productactivity a {
74
+ font-size: 12px;
75
+ font-weight: bold;
76
+ }
77
+ .block-productactivity .product-name a {
78
+ color: #1E7EC8;
79
+ }
80
+ .block-productactivity .products-grid .price-box {
81
+ margin: 5px 0;
82
+ }
83
+ .block-productactivity .link-cart {
84
+ color: #DC6809 !important;
85
+ font-weight: bold;
86
+ font-size: 12px;
87
+ text-decoration: underline !important;
88
+ }
89
+
90
+ .block-productactivity .product-image {
91
+ float: left;
92
+ margin-right: 5px;
93
+ }
94
+
95
+ .block-productactivity .products-grid .product-image {
96
+ display: block;
97
+ height: 135px;
98
+ margin: 0 0 10px;
99
+ width: 135px;
100
+ }
101
+ .block-productactivity img {
102
+ border: 1px solid #E5DCC3;
103
+ }
104
+
105
+
106
+
107
+ .block-productactivity dl {
108
+ clear: both;
109
+ display: block;
110
+ float: left;
111
+ width: 100%;
112
+ margin-bottom: 8px;
113
+ padding-bottom: 8px;
114
+ border-bottom: 1px solid #E5DCC3;
115
+ }
116
+
117
+ .block-productactivity dl.last {
118
+ border: 0;
119
+ }
120
+
121
+ .block-productactivity li.odd {
122
+ background-color: #E5DCC3;
123
+ }
124
+
125
+ #productactivity-no-products {
126
+ margin: 0 auto;
127
+ width: 50%;
128
+ padding-top: 160px;
129
+ }
130
+ .block-productactivity .block-content #productactivity-no-products li.item {
131
+ border: 1px solid #B6B6B6;
132
+ }
133
+
134
+ .ip_productactivity_box {
135
+ margin-top: 5px;
136
+ clear: both;
137
+ float: left;
138
+ width: 100%;
139
+ padding-top: 5px;
140
+ }
141
+
142
+ .ip_productactivity_box .add-to-links {
143
+ font-size: 10px;
144
+ margin: 5px 0 0;
145
+ }
146
+
147
+ .magazento-powered, .magazento-powered a {
148
+ color: #BBB !important;
149
+ font-size: 9px;
150
+ text-align: right;
151
+ text-decoration: none;
152
+ }
skin/frontend/base/default/ip_productactivity/tabs.css ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /* Subsection Tabs
2
+ --------------------*/
3
+ #main-ops-container ul.subsection_tabs {
4
+ list-style: none;
5
+ margin: 0;
6
+ padding: 0;
7
+ clear: both;
8
+ height: 27px;
9
+ background: white url("img/menu_tabs_sprite.png") repeat-x 0 -156px;
10
+ border: 1px solid #B6B6B6;
11
+ border-bottom: 0;
12
+ }
13
+
14
+ #main-ops-container ul.subsection_tabs li {
15
+ float:left;
16
+ text-align:center;
17
+ border-right: solid 1px #CDCDCD;
18
+ }
19
+ #main-ops-container ul.subsection_tabs li.last {
20
+ border-right: 0;
21
+ }
22
+
23
+ #main-ops-container ul.subsection_tabs li.tab a {
24
+ display: block;
25
+ height: 19px;
26
+ padding: 4px 12px;
27
+ color: #666;
28
+ font-weight: normal;
29
+ text-decoration: none;
30
+ font-size: 12px;
31
+ text-transform: uppercase;
32
+ }
33
+
34
+ #main-ops-container ul.subsection_tabs li.tab a:hover {
35
+
36
+ }
37
+ #main-ops-container ul.subsection_tabs li.tab a {
38
+ background: #fff url("img/menu_tabs_sprite.png") no-repeat 0 -156px;
39
+ }
40
+
41
+ #main-ops-container ul.subsection_tabs li.tab a.active {
42
+ background: #FAF7EE;
43
+ font-weight: bold;
44
+ height: 20px;
45
+ }
46
+
47
+ #main-ops-container ul.subsection_tabs li.source_code {
48
+ float:right;
49
+ }
50
+
51
+ #main-ops-container a {
52
+ text-decoration: none;
53
+ font-weight: bold;
54
+ color: #2777A1;
55
+ }
skin/frontend/base/default/ip_productactivity/tabs.js ADDED
@@ -0,0 +1,465 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/tabs
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global window, document, Prototype, $, $A, $H, $break, Class, Element, Event, Control */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.Tabs requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.Tabs requires Object.Event to be loaded."; }
16
+
17
+ Control.Tabs = Class.create({
18
+ initialize: function(tab_list_container,options){
19
+ if(!$(tab_list_container)) {
20
+ throw "Control.Tabs could not find the element: " + tab_list_container; }
21
+ this.activeContainer = false;
22
+ this.activeLink = false;
23
+ this.containers = $H({});
24
+ this.links = [];
25
+ this.options = {
26
+ beforeChange: Prototype.emptyFunction,
27
+ afterChange: Prototype.emptyFunction,
28
+ hover: false,
29
+ tracked: true,
30
+ linkSelector: 'li a',
31
+ linkAttribute: 'href',
32
+ setClassOnContainer: false,
33
+ activeClassName: 'active',
34
+ disabledClassName: 'disabled',
35
+ defaultTab: 'first',
36
+ autoLinkExternal: true,
37
+ targetRegExp: /#(.+)$/,
38
+ showFunction: Element.show,
39
+ hideFunction: Element.hide
40
+ };
41
+ Object.extend(this.options,options || {});
42
+ if (this.options.tracked) {
43
+ Control.Tabs.instances.push(this);
44
+ }
45
+ var filterLinks;
46
+ switch (this.options.linkAttribute) {
47
+ case 'href':
48
+ case 'src':
49
+ filterLinks = function(link){
50
+ return (/^#/).test(link.getAttribute(this.options.linkAttribute).replace(
51
+ window.location.href.split('#')[0],''));
52
+ };
53
+ break;
54
+
55
+ default:
56
+ if (typeof(this.options.linkAttribute) == 'function') {
57
+ filterLinks = this.options.linkAttribute;
58
+ }
59
+ else {
60
+ filterLinks = function(link) {
61
+ return link.hasAttribute(this.options.linkAttribute);
62
+ };
63
+ }
64
+ }
65
+
66
+ (typeof(this.options.linkSelector) == 'string' ?
67
+ $(tab_list_container).select(this.options.linkSelector) :
68
+ this.options.linkSelector($(tab_list_container))
69
+ ).findAll(filterLinks.bind(this)).each(function(link){
70
+ this.addTab(link);
71
+ }.bind(this));
72
+ this.containers.values().each(Element.hide);
73
+ if(this.options.defaultTab == 'first') {
74
+ this.setActiveTab(this.links.first());
75
+ } else if(this.options.defaultTab == 'last') {
76
+ this.setActiveTab(this.links.last());
77
+ } else {
78
+ this.setActiveTab(this.options.defaultTab); }
79
+ var targets = this.options.targetRegExp.exec(window.location);
80
+ if(targets && targets[1]){
81
+ targets[1].split(',').each(function(target){
82
+ this.setActiveTab(this.links.find(function(link){
83
+ return link.key == target;
84
+ }));
85
+ }.bind(this));
86
+ }
87
+ if(this.options.autoLinkExternal){
88
+ $A(document.getElementsByTagName('a')).each(function(a){
89
+ if(!this.links.include(a)){
90
+ var clean_href = a.href.replace(window.location.href.split('#')[0],'');
91
+ if(clean_href.substring(0,1) == '#'){
92
+ if(this.containers.keys().include(clean_href.substring(1))){
93
+ $(a).observe('click',function(event,clean_href){
94
+ this.setActiveTab(clean_href.substring(1));
95
+ }.bindAsEventListener(this,clean_href));
96
+ }
97
+ }
98
+ }
99
+ }.bind(this));
100
+ }
101
+ },
102
+ addTab: function(link){
103
+ this.links.push(link);
104
+
105
+ switch (this.options.linkAttribute) {
106
+ case 'href':
107
+ case 'src':
108
+ link.key = link.getAttribute(this.options.linkAttribute).replace(
109
+ window.location.href.split('#')[0],'').split('#').last().replace(/#/,'');
110
+ break;
111
+
112
+ default:
113
+ if (typeof(this.options.linkAttribute) == 'function') {
114
+ link.key = this.options.linkAttribute(link);
115
+ }
116
+ else {
117
+ link.key = link.getAttribute(this.options.linkAttribute);
118
+ }
119
+ }
120
+ var container = this.options.tabs_container ? this.options.tabs_container.down('#'+link.key) : $(link.key);
121
+ if(!container) {
122
+ throw "Control.Tabs: #" + link.key + " was not found on the page."; }
123
+ this.containers.set(link.key,container);
124
+ link[this.options.hover ? 'onmouseover' : 'onclick'] = function(link){
125
+ if(window.event) {
126
+ Event.stop(window.event); }
127
+ this.setActiveTab(link);
128
+ return false;
129
+ }.bind(this,link);
130
+ },
131
+ getTab: function (link) {
132
+ if(!link && typeof(link) == 'undefined') {
133
+ return null; }
134
+ if(typeof(link) == 'string'){
135
+ return this.getTab(this.links.find(function(_link){
136
+ return _link.key == link;
137
+ }));
138
+ }else if(typeof(link) == 'number'){
139
+ return this.getTab(this.links[link]);
140
+ }else {
141
+ return this.containers.get(link.key);
142
+ }
143
+ },
144
+ setActiveTab: function(link){
145
+ if(!link && typeof(link) == 'undefined') {
146
+ return; }
147
+ if(typeof(link) == 'string'){
148
+ this.setActiveTab(this.links.find(function(_link){
149
+ return _link.key == link;
150
+ }));
151
+ }else if(typeof(link) == 'number'){
152
+ this.setActiveTab(this.links[link]);
153
+ }else if(!(this.options.setClassOnContainer ? $(link.parentNode) : link).hasClassName(this.options.disabledClassName)){
154
+ if(link == this.activeLink) {
155
+ return; }
156
+ if(this.notify('beforeChange',this.activeContainer,this.containers.get(link.key)) === false) {
157
+ return; }
158
+ if(this.activeContainer) {
159
+ this.options.hideFunction(this.activeContainer); }
160
+ this.links.each(function(item){
161
+ (this.options.setClassOnContainer ? $(item.parentNode) : item).removeClassName(this.options.activeClassName);
162
+ }.bind(this));
163
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).addClassName(this.options.activeClassName);
164
+ this.activeContainer = this.containers.get(link.key);
165
+ this.activeLink = link;
166
+ this.options.showFunction(this.containers.get(link.key));
167
+ this.notify('afterChange',this.containers.get(link.key));
168
+ }
169
+ },
170
+ disableTab: function (link) {
171
+ if(!link && typeof(link) == 'undefined') {
172
+ return; }
173
+ if(typeof(link) == 'string'){
174
+ this.disableTab(this.links.find(function(_link){
175
+ return _link.key == link;
176
+ }));
177
+ }else if(typeof(link) == 'number'){
178
+ this.disableTab(this.links[link]);
179
+ }else{
180
+ if ({'INPUT':true,'BUTTON':true,'SELECT':true,'TEXTAREA':true}[link.nodeName]) {
181
+ link.disabled = true; }
182
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).addClassName(this.options.disabledClassName);
183
+ }
184
+ },
185
+ enableTab: function (link) {
186
+ if(!link && typeof(link) == 'undefined') {
187
+ return; }
188
+ if(typeof(link) == 'string'){
189
+ this.enableTab(this.links.find(function(_link){
190
+ return _link.key == link;
191
+ }));
192
+ }else if(typeof(link) == 'number'){
193
+ this.enableTab(this.links[link]);
194
+ }else{
195
+ if ({'INPUT':true,'BUTTON':true,'SELECT':true,'TEXTAREA':true}[link.nodeName]) {
196
+ link.disabled = false; }
197
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).removeClassName(this.options.disabledClassName);
198
+ }
199
+ },
200
+ next: function(){
201
+ this.links.each(function(link,i){
202
+ if(this.activeLink == link && this.links[i + 1]){
203
+ this.setActiveTab(this.links[i + 1]);
204
+ throw $break;
205
+ }
206
+ }.bind(this));
207
+ },
208
+ previous: function(){
209
+ this.links.each(function(link,i){
210
+ if(this.activeLink == link && this.links[i - 1]){
211
+ this.setActiveTab(this.links[i - 1]);
212
+ throw $break;
213
+ }
214
+ }.bind(this));
215
+ },
216
+ first: function(){
217
+ this.setActiveTab(this.links.first());
218
+ },
219
+ last: function(){
220
+ this.setActiveTab(this.links.last());
221
+ }
222
+ });
223
+ Object.extend(Control.Tabs,{
224
+ instances: [],
225
+ findByTabId: function(id){
226
+ return Control.Tabs.instances.find(function(tab){
227
+ return tab.links.find(function(link){
228
+ return link.key == id;
229
+ });
230
+ });
231
+ }
232
+ });
233
+ Object.Event.extend(Control.Tabs);/**
234
+ * @author Ryan Johnson <http://syntacticx.com/>
235
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
236
+ * @package LivePipe UI
237
+ * @license MIT
238
+ * @url http://livepipe.net/control/tabs
239
+ * @require prototype.js, livepipe.js
240
+ */
241
+
242
+ /*global window, document, Prototype, $, $A, $H, $break, Class, Element, Event, Control */
243
+
244
+ if(typeof(Prototype) == "undefined") {
245
+ throw "Control.Tabs requires Prototype to be loaded."; }
246
+ if(typeof(Object.Event) == "undefined") {
247
+ throw "Control.Tabs requires Object.Event to be loaded."; }
248
+
249
+ Control.Tabs = Class.create({
250
+ initialize: function(tab_list_container,options){
251
+ if(!$(tab_list_container)) {
252
+ throw "Control.Tabs could not find the element: " + tab_list_container; }
253
+ this.activeContainer = false;
254
+ this.activeLink = false;
255
+ this.containers = $H({});
256
+ this.links = [];
257
+ this.options = {
258
+ beforeChange: Prototype.emptyFunction,
259
+ afterChange: Prototype.emptyFunction,
260
+ hover: false,
261
+ tracked: true,
262
+ linkSelector: 'li a',
263
+ linkAttribute: 'href',
264
+ setClassOnContainer: false,
265
+ activeClassName: 'active',
266
+ disabledClassName: 'disabled',
267
+ defaultTab: 'first',
268
+ autoLinkExternal: true,
269
+ targetRegExp: /#(.+)$/,
270
+ showFunction: Element.show,
271
+ hideFunction: Element.hide
272
+ };
273
+ Object.extend(this.options,options || {});
274
+ if (this.options.tracked) {
275
+ Control.Tabs.instances.push(this);
276
+ }
277
+ var filterLinks;
278
+ switch (this.options.linkAttribute) {
279
+ case 'href':
280
+ case 'src':
281
+ filterLinks = function(link){
282
+ return (/^#/).test(link.getAttribute(this.options.linkAttribute).replace(
283
+ window.location.href.split('#')[0],''));
284
+ };
285
+ break;
286
+
287
+ default:
288
+ if (typeof(this.options.linkAttribute) == 'function') {
289
+ filterLinks = this.options.linkAttribute;
290
+ }
291
+ else {
292
+ filterLinks = function(link) {
293
+ return link.hasAttribute(this.options.linkAttribute);
294
+ };
295
+ }
296
+ }
297
+
298
+ (typeof(this.options.linkSelector) == 'string' ?
299
+ $(tab_list_container).select(this.options.linkSelector) :
300
+ this.options.linkSelector($(tab_list_container))
301
+ ).findAll(filterLinks.bind(this)).each(function(link){
302
+ this.addTab(link);
303
+ }.bind(this));
304
+ this.containers.values().each(Element.hide);
305
+ if(this.options.defaultTab == 'first') {
306
+ this.setActiveTab(this.links.first());
307
+ } else if(this.options.defaultTab == 'last') {
308
+ this.setActiveTab(this.links.last());
309
+ } else {
310
+ this.setActiveTab(this.options.defaultTab); }
311
+ var targets = this.options.targetRegExp.exec(window.location);
312
+ if(targets && targets[1]){
313
+ targets[1].split(',').each(function(target){
314
+ this.setActiveTab(this.links.find(function(link){
315
+ return link.key == target;
316
+ }));
317
+ }.bind(this));
318
+ }
319
+ if(this.options.autoLinkExternal){
320
+ $A(document.getElementsByTagName('a')).each(function(a){
321
+ if(!this.links.include(a)){
322
+ var clean_href = a.href.replace(window.location.href.split('#')[0],'');
323
+ if(clean_href.substring(0,1) == '#'){
324
+ if(this.containers.keys().include(clean_href.substring(1))){
325
+ $(a).observe('click',function(event,clean_href){
326
+ this.setActiveTab(clean_href.substring(1));
327
+ }.bindAsEventListener(this,clean_href));
328
+ }
329
+ }
330
+ }
331
+ }.bind(this));
332
+ }
333
+ },
334
+ addTab: function(link){
335
+ this.links.push(link);
336
+
337
+ switch (this.options.linkAttribute) {
338
+ case 'href':
339
+ case 'src':
340
+ link.key = link.getAttribute(this.options.linkAttribute).replace(
341
+ window.location.href.split('#')[0],'').split('#').last().replace(/#/,'');
342
+ break;
343
+
344
+ default:
345
+ if (typeof(this.options.linkAttribute) == 'function') {
346
+ link.key = this.options.linkAttribute(link);
347
+ }
348
+ else {
349
+ link.key = link.getAttribute(this.options.linkAttribute);
350
+ }
351
+ }
352
+ var container = this.options.tabs_container ? this.options.tabs_container.down('#'+link.key) : $(link.key);
353
+ if(!container) {
354
+ throw "Control.Tabs: #" + link.key + " was not found on the page."; }
355
+ this.containers.set(link.key,container);
356
+ link[this.options.hover ? 'onmouseover' : 'onmouseover'] = function(link){
357
+ if(window.event) {
358
+ Event.stop(window.event); }
359
+ this.setActiveTab(link);
360
+ return false;
361
+ }.bind(this,link);
362
+ },
363
+ getTab: function (link) {
364
+ if(!link && typeof(link) == 'undefined') {
365
+ return null; }
366
+ if(typeof(link) == 'string'){
367
+ return this.getTab(this.links.find(function(_link){
368
+ return _link.key == link;
369
+ }));
370
+ }else if(typeof(link) == 'number'){
371
+ return this.getTab(this.links[link]);
372
+ }else {
373
+ return this.containers.get(link.key);
374
+ }
375
+ },
376
+ setActiveTab: function(link){
377
+ if(!link && typeof(link) == 'undefined') {
378
+ return; }
379
+ if(typeof(link) == 'string'){
380
+ this.setActiveTab(this.links.find(function(_link){
381
+ return _link.key == link;
382
+ }));
383
+ }else if(typeof(link) == 'number'){
384
+ this.setActiveTab(this.links[link]);
385
+ }else if(!(this.options.setClassOnContainer ? $(link.parentNode) : link).hasClassName(this.options.disabledClassName)){
386
+ if(link == this.activeLink) {
387
+ return; }
388
+ if(this.notify('beforeChange',this.activeContainer,this.containers.get(link.key)) === false) {
389
+ return; }
390
+ if(this.activeContainer) {
391
+ this.options.hideFunction(this.activeContainer); }
392
+ this.links.each(function(item){
393
+ (this.options.setClassOnContainer ? $(item.parentNode) : item).removeClassName(this.options.activeClassName);
394
+ }.bind(this));
395
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).addClassName(this.options.activeClassName);
396
+ this.activeContainer = this.containers.get(link.key);
397
+ this.activeLink = link;
398
+ this.options.showFunction(this.containers.get(link.key));
399
+ this.notify('afterChange',this.containers.get(link.key));
400
+ }
401
+ },
402
+ disableTab: function (link) {
403
+ if(!link && typeof(link) == 'undefined') {
404
+ return; }
405
+ if(typeof(link) == 'string'){
406
+ this.disableTab(this.links.find(function(_link){
407
+ return _link.key == link;
408
+ }));
409
+ }else if(typeof(link) == 'number'){
410
+ this.disableTab(this.links[link]);
411
+ }else{
412
+ if ({'INPUT':true,'BUTTON':true,'SELECT':true,'TEXTAREA':true}[link.nodeName]) {
413
+ link.disabled = true; }
414
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).addClassName(this.options.disabledClassName);
415
+ }
416
+ },
417
+ enableTab: function (link) {
418
+ if(!link && typeof(link) == 'undefined') {
419
+ return; }
420
+ if(typeof(link) == 'string'){
421
+ this.enableTab(this.links.find(function(_link){
422
+ return _link.key == link;
423
+ }));
424
+ }else if(typeof(link) == 'number'){
425
+ this.enableTab(this.links[link]);
426
+ }else{
427
+ if ({'INPUT':true,'BUTTON':true,'SELECT':true,'TEXTAREA':true}[link.nodeName]) {
428
+ link.disabled = false; }
429
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).removeClassName(this.options.disabledClassName);
430
+ }
431
+ },
432
+ next: function(){
433
+ this.links.each(function(link,i){
434
+ if(this.activeLink == link && this.links[i + 1]){
435
+ this.setActiveTab(this.links[i + 1]);
436
+ throw $break;
437
+ }
438
+ }.bind(this));
439
+ },
440
+ previous: function(){
441
+ this.links.each(function(link,i){
442
+ if(this.activeLink == link && this.links[i - 1]){
443
+ this.setActiveTab(this.links[i - 1]);
444
+ throw $break;
445
+ }
446
+ }.bind(this));
447
+ },
448
+ first: function(){
449
+ this.setActiveTab(this.links.first());
450
+ },
451
+ last: function(){
452
+ this.setActiveTab(this.links.last());
453
+ }
454
+ });
455
+ Object.extend(Control.Tabs,{
456
+ instances: [],
457
+ findByTabId: function(id){
458
+ return Control.Tabs.instances.find(function(tab){
459
+ return tab.links.find(function(link){
460
+ return link.key == id;
461
+ });
462
+ });
463
+ }
464
+ });
465
+ Object.Event.extend(Control.Tabs);