Index: trunk/extensions/ArticleAssessmentPilot/css/ArticleAssessment.css |
— | — | @@ -91,6 +91,7 @@ |
92 | 92 | } |
93 | 93 | .article-assessment-wrapper .rating-field-label{ |
94 | 94 | float: left; |
| 95 | + font-weight: bold; |
95 | 96 | line-height: 24px; |
96 | 97 | } |
97 | 98 | .article-assessment-wrapper .rating-field-label { |
Index: trunk/extensions/ArticleAssessmentPilot/js/jquery.tipsy.js |
— | — | @@ -4,199 +4,199 @@ |
5 | 5 | // released under the MIT license |
6 | 6 | |
7 | 7 | (function($) { |
8 | | - |
9 | | - function Tipsy(element, options) { |
10 | | - this.$element = $(element); |
11 | | - this.options = options; |
12 | | - this.enabled = true; |
13 | | - this.fixTitle(); |
14 | | - } |
15 | | - |
16 | | - Tipsy.prototype = { |
17 | | - show: function() { |
18 | | - var title = this.getTitle(); |
19 | | - if (title && this.enabled) { |
20 | | - var $tip = this.tip(); |
21 | | - |
22 | | - $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title); |
23 | | - $tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity |
24 | | - $tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body); |
25 | | - |
26 | | - var pos = $.extend({}, this.$element.offset(), { |
27 | | - width: this.$element[0].offsetWidth, |
28 | | - height: this.$element[0].offsetHeight |
29 | | - }); |
30 | | - |
31 | | - var actualWidth = $tip[0].offsetWidth, actualHeight = $tip[0].offsetHeight; |
32 | | - var gravity = (typeof this.options.gravity == 'function') |
33 | | - ? this.options.gravity.call(this.$element[0]) |
34 | | - : this.options.gravity; |
35 | | - |
36 | | - var tp; |
37 | | - switch (gravity.charAt(0)) { |
38 | | - case 'n': |
39 | | - tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; |
40 | | - break; |
41 | | - case 's': |
42 | | - tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; |
43 | | - break; |
44 | | - case 'e': |
45 | | - tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}; |
46 | | - break; |
47 | | - case 'w': |
48 | | - tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}; |
49 | | - break; |
50 | | - } |
51 | | - |
52 | | - if (gravity.length == 2) { |
53 | | - if (gravity.charAt(1) == 'w') { |
54 | | - tp.left = pos.left + pos.width / 2 - 15; |
55 | | - } else { |
56 | | - tp.left = pos.left + pos.width / 2 - actualWidth + 15; |
57 | | - } |
58 | | - } |
59 | | - |
60 | | - $tip.css(tp).addClass('tipsy-' + gravity); |
61 | | - |
62 | | - if (this.options.fade) { |
63 | | - $tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity}); |
64 | | - } else { |
65 | | - $tip.css({visibility: 'visible', opacity: this.options.opacity}); |
66 | | - } |
67 | | - } |
68 | | - }, |
69 | | - |
70 | | - hide: function() { |
71 | | - if (this.options.fade) { |
72 | | - this.tip().stop().fadeOut(function() { $(this).remove(); }); |
73 | | - } else { |
74 | | - this.tip().remove(); |
75 | | - } |
76 | | - }, |
77 | | - |
78 | | - fixTitle: function() { |
79 | | - var $e = this.$element; |
80 | | - if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') { |
81 | | - $e.attr('original-title', $e.attr('title') || '').removeAttr('title'); |
82 | | - } |
83 | | - }, |
84 | | - |
85 | | - getTitle: function() { |
86 | | - var title, $e = this.$element, o = this.options; |
87 | | - this.fixTitle(); |
88 | | - var title, o = this.options; |
89 | | - if (typeof o.title == 'string') { |
90 | | - title = $e.attr(o.title == 'title' ? 'original-title' : o.title); |
91 | | - } else if (typeof o.title == 'function') { |
92 | | - title = o.title.call($e[0]); |
93 | | - } |
94 | | - title = ('' + title).replace(/(^\s*|\s*$)/, ""); |
95 | | - return title || o.fallback; |
96 | | - }, |
97 | | - |
98 | | - tip: function() { |
99 | | - if (!this.$tip) { |
100 | | - this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'); |
101 | | - } |
102 | | - return this.$tip; |
103 | | - }, |
104 | | - |
105 | | - validate: function() { |
106 | | - if (!this.$element[0].parentNode) { |
107 | | - this.hide(); |
108 | | - this.$element = null; |
109 | | - this.options = null; |
110 | | - } |
111 | | - }, |
112 | | - |
113 | | - enable: function() { this.enabled = true; }, |
114 | | - disable: function() { this.enabled = false; }, |
115 | | - toggleEnabled: function() { this.enabled = !this.enabled; } |
116 | | - }; |
117 | | - |
118 | | - $.fn.tipsy = function(options) { |
119 | | - |
120 | | - if (options === true) { |
121 | | - return this.data('tipsy'); |
122 | | - } else if (typeof options == 'string') { |
123 | | - var tipsy = this.data('tipsy'); |
124 | | - if (tipsy) tipsy[options](); |
125 | | - return this; |
126 | | - } |
127 | | - |
128 | | - options = $.extend({}, $.fn.tipsy.defaults, options); |
129 | | - |
130 | | - function get(ele) { |
131 | | - var tipsy = $.data(ele, 'tipsy'); |
132 | | - if (!tipsy) { |
133 | | - tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options)); |
134 | | - $.data(ele, 'tipsy', tipsy); |
135 | | - } |
136 | | - return tipsy; |
137 | | - } |
138 | | - |
139 | | - function enter() { |
140 | | - var tipsy = get(this); |
141 | | - tipsy.hoverState = 'in'; |
142 | | - if (options.delayIn == 0) { |
143 | | - tipsy.show(); |
144 | | - } else { |
145 | | - tipsy.fixTitle(); |
146 | | - setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn); |
147 | | - } |
148 | | - }; |
149 | | - |
150 | | - function leave() { |
151 | | - var tipsy = get(this); |
152 | | - tipsy.hoverState = 'out'; |
153 | | - if (options.delayOut == 0) { |
154 | | - tipsy.hide(); |
155 | | - } else { |
156 | | - setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut); |
157 | | - } |
158 | | - }; |
159 | | - |
160 | | - if (!options.live) this.each(function() { get(this); }); |
161 | | - |
162 | | - if (options.trigger != 'manual') { |
163 | | - var binder = options.live ? 'live' : 'bind', |
164 | | - eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus', |
165 | | - eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'; |
166 | | - this[binder](eventIn, enter)[binder](eventOut, leave); |
167 | | - } |
168 | | - |
169 | | - return this; |
170 | | - |
171 | | - }; |
172 | | - |
173 | | - $.fn.tipsy.defaults = { |
174 | | - delayIn: 0, |
175 | | - delayOut: 0, |
176 | | - fade: false, |
177 | | - fallback: '', |
178 | | - gravity: 'n', |
179 | | - html: false, |
180 | | - live: false, |
181 | | - offset: 0, |
182 | | - opacity: 0.8, |
183 | | - title: 'title', |
184 | | - trigger: 'hover' |
185 | | - }; |
186 | | - |
187 | | - // Overwrite this method to provide options on a per-element basis. |
188 | | - // For example, you could store the gravity in a 'tipsy-gravity' attribute: |
189 | | - // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' }); |
190 | | - // (remember - do not modify 'options' in place!) |
191 | | - $.fn.tipsy.elementOptions = function(ele, options) { |
192 | | - return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; |
193 | | - }; |
194 | | - |
195 | | - $.fn.tipsy.autoNS = function() { |
196 | | - return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; |
197 | | - }; |
198 | | - |
199 | | - $.fn.tipsy.autoWE = function() { |
200 | | - return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; |
201 | | - }; |
202 | | - |
| 8 | + |
| 9 | + function Tipsy(element, options) { |
| 10 | + this.$element = $(element); |
| 11 | + this.options = options; |
| 12 | + this.enabled = true; |
| 13 | + this.fixTitle(); |
| 14 | + } |
| 15 | + |
| 16 | + Tipsy.prototype = { |
| 17 | + show: function() { |
| 18 | + var title = this.getTitle(); |
| 19 | + if (title && this.enabled) { |
| 20 | + var $tip = this.tip(); |
| 21 | + |
| 22 | + $tip.find('.tipsy-inner')[this.options.html ? 'html' : 'text'](title); |
| 23 | + $tip[0].className = 'tipsy'; // reset classname in case of dynamic gravity |
| 24 | + $tip.remove().css({top: 0, left: 0, visibility: 'hidden', display: 'block'}).appendTo(document.body); |
| 25 | + |
| 26 | + var pos = $.extend({}, this.$element.offset(), { |
| 27 | + width: this.$element[0].offsetWidth, |
| 28 | + height: this.$element[0].offsetHeight |
| 29 | + }); |
| 30 | + |
| 31 | + var actualWidth = $tip[0].offsetWidth, actualHeight = $tip[0].offsetHeight; |
| 32 | + var gravity = (typeof this.options.gravity == 'function') |
| 33 | + ? this.options.gravity.call(this.$element[0]) |
| 34 | + : this.options.gravity; |
| 35 | + |
| 36 | + var tp; |
| 37 | + switch (gravity.charAt(0)) { |
| 38 | + case 'n': |
| 39 | + tp = {top: pos.top + pos.height + this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; |
| 40 | + break; |
| 41 | + case 's': |
| 42 | + tp = {top: pos.top - actualHeight - this.options.offset, left: pos.left + pos.width / 2 - actualWidth / 2}; |
| 43 | + break; |
| 44 | + case 'e': |
| 45 | + tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left - actualWidth - this.options.offset}; |
| 46 | + break; |
| 47 | + case 'w': |
| 48 | + tp = {top: pos.top + pos.height / 2 - actualHeight / 2, left: pos.left + pos.width + this.options.offset}; |
| 49 | + break; |
| 50 | + } |
| 51 | + |
| 52 | + if (gravity.length == 2) { |
| 53 | + if (gravity.charAt(1) == 'w') { |
| 54 | + tp.left = pos.left + pos.width / 2 - 15; |
| 55 | + } else { |
| 56 | + tp.left = pos.left + pos.width / 2 - actualWidth + 15; |
| 57 | + } |
| 58 | + } |
| 59 | + |
| 60 | + $tip.css(tp).addClass('tipsy-' + gravity); |
| 61 | + |
| 62 | + if (this.options.fade) { |
| 63 | + $tip.stop().css({opacity: 0, display: 'block', visibility: 'visible'}).animate({opacity: this.options.opacity}); |
| 64 | + } else { |
| 65 | + $tip.css({visibility: 'visible', opacity: this.options.opacity}); |
| 66 | + } |
| 67 | + } |
| 68 | + }, |
| 69 | + |
| 70 | + hide: function() { |
| 71 | + if (this.options.fade) { |
| 72 | + this.tip().stop().fadeOut(function() { $(this).remove(); }); |
| 73 | + } else { |
| 74 | + this.tip().remove(); |
| 75 | + } |
| 76 | + }, |
| 77 | + |
| 78 | + fixTitle: function() { |
| 79 | + var $e = this.$element; |
| 80 | + if ($e.attr('title') || typeof($e.attr('original-title')) != 'string') { |
| 81 | + $e.attr('original-title', $e.attr('title') || '').removeAttr('title'); |
| 82 | + } |
| 83 | + }, |
| 84 | + |
| 85 | + getTitle: function() { |
| 86 | + var title, $e = this.$element, o = this.options; |
| 87 | + this.fixTitle(); |
| 88 | + var title, o = this.options; |
| 89 | + if (typeof o.title == 'string') { |
| 90 | + title = $e.attr(o.title == 'title' ? 'original-title' : o.title); |
| 91 | + } else if (typeof o.title == 'function') { |
| 92 | + title = o.title.call($e[0]); |
| 93 | + } |
| 94 | + title = ('' + title).replace(/(^\s*|\s*$)/, ""); |
| 95 | + return title || o.fallback; |
| 96 | + }, |
| 97 | + |
| 98 | + tip: function() { |
| 99 | + if (!this.$tip) { |
| 100 | + this.$tip = $('<div class="tipsy"></div>').html('<div class="tipsy-arrow"></div><div class="tipsy-inner"></div>'); |
| 101 | + } |
| 102 | + return this.$tip; |
| 103 | + }, |
| 104 | + |
| 105 | + validate: function() { |
| 106 | + if (!this.$element[0].parentNode) { |
| 107 | + this.hide(); |
| 108 | + this.$element = null; |
| 109 | + this.options = null; |
| 110 | + } |
| 111 | + }, |
| 112 | + |
| 113 | + enable: function() { this.enabled = true; }, |
| 114 | + disable: function() { this.enabled = false; }, |
| 115 | + toggleEnabled: function() { this.enabled = !this.enabled; } |
| 116 | + }; |
| 117 | + |
| 118 | + $.fn.tipsy = function(options) { |
| 119 | + |
| 120 | + if (options === true) { |
| 121 | + return this.data('tipsy'); |
| 122 | + } else if (typeof options == 'string') { |
| 123 | + var tipsy = this.data('tipsy'); |
| 124 | + if (tipsy) tipsy[options](); |
| 125 | + return this; |
| 126 | + } |
| 127 | + |
| 128 | + options = $.extend({}, $.fn.tipsy.defaults, options); |
| 129 | + |
| 130 | + function get(ele) { |
| 131 | + var tipsy = $.data(ele, 'tipsy'); |
| 132 | + if (!tipsy) { |
| 133 | + tipsy = new Tipsy(ele, $.fn.tipsy.elementOptions(ele, options)); |
| 134 | + $.data(ele, 'tipsy', tipsy); |
| 135 | + } |
| 136 | + return tipsy; |
| 137 | + } |
| 138 | + |
| 139 | + function enter() { |
| 140 | + var tipsy = get(this); |
| 141 | + tipsy.hoverState = 'in'; |
| 142 | + if (options.delayIn == 0) { |
| 143 | + tipsy.show(); |
| 144 | + } else { |
| 145 | + tipsy.fixTitle(); |
| 146 | + setTimeout(function() { if (tipsy.hoverState == 'in') tipsy.show(); }, options.delayIn); |
| 147 | + } |
| 148 | + }; |
| 149 | + |
| 150 | + function leave() { |
| 151 | + var tipsy = get(this); |
| 152 | + tipsy.hoverState = 'out'; |
| 153 | + if (options.delayOut == 0) { |
| 154 | + tipsy.hide(); |
| 155 | + } else { |
| 156 | + setTimeout(function() { if (tipsy.hoverState == 'out') tipsy.hide(); }, options.delayOut); |
| 157 | + } |
| 158 | + }; |
| 159 | + |
| 160 | + if (!options.live) this.each(function() { get(this); }); |
| 161 | + |
| 162 | + if (options.trigger != 'manual') { |
| 163 | + var binder = options.live ? 'live' : 'bind', |
| 164 | + eventIn = options.trigger == 'hover' ? 'mouseenter' : 'focus', |
| 165 | + eventOut = options.trigger == 'hover' ? 'mouseleave' : 'blur'; |
| 166 | + this[binder](eventIn, enter)[binder](eventOut, leave); |
| 167 | + } |
| 168 | + |
| 169 | + return this; |
| 170 | + |
| 171 | + }; |
| 172 | + |
| 173 | + $.fn.tipsy.defaults = { |
| 174 | + delayIn: 0, |
| 175 | + delayOut: 0, |
| 176 | + fade: false, |
| 177 | + fallback: '', |
| 178 | + gravity: 'n', |
| 179 | + html: false, |
| 180 | + live: false, |
| 181 | + offset: 0, |
| 182 | + opacity: 0.8, |
| 183 | + title: 'title', |
| 184 | + trigger: 'hover' |
| 185 | + }; |
| 186 | + |
| 187 | + // Overwrite this method to provide options on a per-element basis. |
| 188 | + // For example, you could store the gravity in a 'tipsy-gravity' attribute: |
| 189 | + // return $.extend({}, options, {gravity: $(ele).attr('tipsy-gravity') || 'n' }); |
| 190 | + // (remember - do not modify 'options' in place!) |
| 191 | + $.fn.tipsy.elementOptions = function(ele, options) { |
| 192 | + return $.metadata ? $.extend({}, options, $(ele).metadata()) : options; |
| 193 | + }; |
| 194 | + |
| 195 | + $.fn.tipsy.autoNS = function() { |
| 196 | + return $(this).offset().top > ($(document).scrollTop() + $(window).height() / 2) ? 's' : 'n'; |
| 197 | + }; |
| 198 | + |
| 199 | + $.fn.tipsy.autoWE = function() { |
| 200 | + return $(this).offset().left > ($(document).scrollLeft() + $(window).width() / 2) ? 'e' : 'w'; |
| 201 | + }; |
| 202 | + |
203 | 203 | })(jQuery); |
Index: trunk/extensions/ArticleAssessmentPilot/js/jquery.cookie.js |
— | — | @@ -19,19 +19,19 @@ |
20 | 20 | * @desc Create a session cookie. |
21 | 21 | * @example $.cookie('the_cookie', null); |
22 | 22 | * @desc Delete a cookie by passing null as value. Keep in mind that you have to use the same path and domain |
23 | | - * used when the cookie was set. |
| 23 | + * used when the cookie was set. |
24 | 24 | * |
25 | 25 | * @param String name The name of the cookie. |
26 | 26 | * @param String value The value of the cookie. |
27 | 27 | * @param Object options An object literal containing key/value pairs to provide optional cookie attributes. |
28 | 28 | * @option Number|Date expires Either an integer specifying the expiration date from now on in days or a Date object. |
29 | | - * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. |
30 | | - * If set to null or omitted, the cookie will be a session cookie and will not be retained |
31 | | - * when the the browser exits. |
| 29 | + * If a negative value is specified (e.g. a date in the past), the cookie will be deleted. |
| 30 | + * If set to null or omitted, the cookie will be a session cookie and will not be retained |
| 31 | + * when the the browser exits. |
32 | 32 | * @option String path The value of the path atribute of the cookie (default: path of page that created the cookie). |
33 | 33 | * @option String domain The value of the domain attribute of the cookie (default: domain of page that created the cookie). |
34 | 34 | * @option Boolean secure If true, the secure attribute of the cookie will be set and the cookie transmission will |
35 | | - * require a secure protocol (like HTTPS). |
| 35 | + * require a secure protocol (like HTTPS). |
36 | 36 | * @type undefined |
37 | 37 | * |
38 | 38 | * @name $.cookie |
— | — | @@ -54,44 +54,44 @@ |
55 | 55 | * @author Klaus Hartl/klaus.hartl@stilbuero.de |
56 | 56 | */ |
57 | 57 | jQuery.cookie = function(name, value, options) { |
58 | | - if (typeof value != 'undefined') { // name and value given, set cookie |
59 | | - options = options || {}; |
60 | | - if (value === null) { |
61 | | - value = ''; |
62 | | - options.expires = -1; |
63 | | - } |
64 | | - var expires = ''; |
65 | | - if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { |
66 | | - var date; |
67 | | - if (typeof options.expires == 'number') { |
68 | | - date = new Date(); |
69 | | - date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); |
70 | | - } else { |
71 | | - date = options.expires; |
72 | | - } |
73 | | - expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE |
74 | | - } |
75 | | - // CAUTION: Needed to parenthesize options.path and options.domain |
76 | | - // in the following expressions, otherwise they evaluate to undefined |
77 | | - // in the packed version for some reason... |
78 | | - var path = options.path ? '; path=' + (options.path) : ''; |
79 | | - var domain = options.domain ? '; domain=' + (options.domain) : ''; |
80 | | - var secure = options.secure ? '; secure' : ''; |
81 | | - document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); |
82 | | - } else { // only name given, get cookie |
83 | | - var cookieValue = null; |
84 | | - if (document.cookie && document.cookie != '') { |
85 | | - var cookies = document.cookie.split(';'); |
86 | | - for (var i = 0; i < cookies.length; i++) { |
87 | | - var cookie = jQuery.trim(cookies[i]); |
88 | | - // Does this cookie string begin with the name we want? |
89 | | - if (cookie.substring(0, name.length + 1) == (name + '=')) { |
90 | | - cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |
91 | | - break; |
92 | | - } |
93 | | - } |
94 | | - } |
95 | | - return cookieValue; |
96 | | - } |
| 58 | + if (typeof value != 'undefined') { // name and value given, set cookie |
| 59 | + options = options || {}; |
| 60 | + if (value === null) { |
| 61 | + value = ''; |
| 62 | + options.expires = -1; |
| 63 | + } |
| 64 | + var expires = ''; |
| 65 | + if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) { |
| 66 | + var date; |
| 67 | + if (typeof options.expires == 'number') { |
| 68 | + date = new Date(); |
| 69 | + date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000)); |
| 70 | + } else { |
| 71 | + date = options.expires; |
| 72 | + } |
| 73 | + expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE |
| 74 | + } |
| 75 | + // CAUTION: Needed to parenthesize options.path and options.domain |
| 76 | + // in the following expressions, otherwise they evaluate to undefined |
| 77 | + // in the packed version for some reason... |
| 78 | + var path = options.path ? '; path=' + (options.path) : ''; |
| 79 | + var domain = options.domain ? '; domain=' + (options.domain) : ''; |
| 80 | + var secure = options.secure ? '; secure' : ''; |
| 81 | + document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join(''); |
| 82 | + } else { // only name given, get cookie |
| 83 | + var cookieValue = null; |
| 84 | + if (document.cookie && document.cookie != '') { |
| 85 | + var cookies = document.cookie.split(';'); |
| 86 | + for (var i = 0; i < cookies.length; i++) { |
| 87 | + var cookie = jQuery.trim(cookies[i]); |
| 88 | + // Does this cookie string begin with the name we want? |
| 89 | + if (cookie.substring(0, name.length + 1) == (name + '=')) { |
| 90 | + cookieValue = decodeURIComponent(cookie.substring(name.length + 1)); |
| 91 | + break; |
| 92 | + } |
| 93 | + } |
| 94 | + } |
| 95 | + return cookieValue; |
| 96 | + } |
97 | 97 | }; |
98 | 98 | |
Index: trunk/extensions/ArticleAssessmentPilot/js/ArticleAssessment.js |
— | — | @@ -2,7 +2,7 @@ |
3 | 3 | $.ArticleAssessment = { |
4 | 4 | 'config': { |
5 | 5 | 'authtoken': '', |
6 | | - 'userID': '', |
| 6 | + 'userID': wgUserName, |
7 | 7 | 'pageID': wgArticleId, |
8 | 8 | 'revID': wgCurRevisionId |
9 | 9 | }, |
— | — | @@ -16,13 +16,13 @@ |
17 | 17 | ], |
18 | 18 | 'fieldHintSuffix': '-tooltip', |
19 | 19 | 'fieldPrefix': 'articleassessment-rating-', |
20 | | - 'fieldHTML': '<div class="field-wrapper"> \ |
| 20 | + 'fieldHTML': '<div class="field-wrapper" id="articleassessment-rate-{FIELD}"> \ |
21 | 21 | <label for="rating_{FIELD}" original-title="{HINT}" class="rating-field-label">{LABEL}</label> \ |
22 | | - <select id="rating_{FIELD}" name="rating{FIELD}" class="rating-field"> \ |
| 22 | + <select id="rating_{FIELD}" name="rating[{FIELD}]" class="rating-field"> \ |
23 | 23 | <option value="1">1</option> \ |
24 | 24 | <option value="2">2</option> \ |
25 | 25 | <option value="3">3</option> \ |
26 | | - <option value="4" selected>4</option> \ |
| 26 | + <option value="4">4</option> \ |
27 | 27 | <option value="5">5</option> \ |
28 | 28 | </select> \ |
29 | 29 | </div>', |
— | — | @@ -62,18 +62,33 @@ |
63 | 63 | 'init': function( $$options ) { |
64 | 64 | // merge options with the config |
65 | 65 | var settings = $.extend( {}, $.ArticleAssessment.settings, $$options ); |
| 66 | + var config = $.ArticleAssessment.config; |
| 67 | + // if this is an anon user, get a unique identifier for them |
66 | 68 | // load up the stored ratings and update the markup if the cookie exists |
67 | 69 | var cookieSettings = $.cookie( 'mwArticleAssessment' ); |
68 | | - if ( cookieSettings == null ) { |
| 70 | + if ( true || typeof cookieSettings == 'undefined' ) { |
| 71 | + function randomString( string_length ) { |
| 72 | + var chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXTZabcdefghiklmnopqrstuvwxyz"; |
| 73 | + var randomstring = ''; |
| 74 | + for (var i=0; i<string_length; i++) { |
| 75 | + var rnum = Math.floor(Math.random() * chars.length); |
| 76 | + randomstring += chars.substring(rnum,rnum+1); |
| 77 | + } |
| 78 | + return randomstring; |
| 79 | + } |
69 | 80 | cookieSettings = { |
70 | | - 'ratings': { } |
| 81 | + uid: randomString( 32 ) |
71 | 82 | }; |
72 | 83 | $.cookie( 'mwArticleAssessment', cookieSettings ); |
73 | 84 | } |
| 85 | + if ( ! wgUserName ) { |
| 86 | + config.userID = cookieSettings.uid; |
| 87 | + } |
74 | 88 | // setup our markup |
75 | 89 | var $output = $( settings.structureHTML |
76 | 90 | .replace( /\{INSTRUCTIONS\}/g, mw.usability.getMsg('articleassessment-pleaserate') ) |
77 | | - .replace( /\{FEEDBACK\}/g, mw.usability.getMsg('articleassessment-featurefeedback') ) |
| 91 | + .replace( /\{FEEDBACK\}/g, mw.usability.getMsg('articleassessment-featurefeedback') |
| 92 | + .replace( /\[\[([^\|\]]*)\|([^\|\]]*)\]\]/, '<a href="' + wgArticlePath + '">$2</a>' ) ) |
78 | 93 | .replace( /\{YOURFEEDBACK\}/g, mw.usability.getMsg('articleassessment-yourfeedback') ) |
79 | 94 | .replace( /\{ARTICLERATING\}/g, mw.usability.getMsg('articleassessment-articlerating' ) ) |
80 | 95 | .replace( /\{RESULTSHIDE\}/g, mw.usability.getMsg('articleassessment-results-hide' ) |
— | — | @@ -84,17 +99,17 @@ |
85 | 100 | $output.find( '.article-assessment-rating-fields' ) |
86 | 101 | .append( $( settings.fieldHTML |
87 | 102 | .replace( /\{LABEL\}/g, mw.usability.getMsg( settings.fieldPrefix + settings.fieldMessages[field] ) ) |
88 | | - .replace( /\{FIELD\}/g, "[" + settings.fieldMessages[field] + "]" ) |
| 103 | + .replace( /\{FIELD\}/g, settings.fieldMessages[field] ) |
89 | 104 | .replace( /\{HINT\}/g, mw.usability.getMsg( settings.fieldPrefix + settings.fieldMessages[field] + settings.fieldHintSuffix ) ) ) ); |
90 | 105 | $output.find( '#article-assessment-ratings' ) |
91 | 106 | .append( $( settings.ratingHTML |
92 | 107 | .replace( /\{LABEL\}/g, mw.usability.getMsg(settings.fieldPrefix + settings.fieldMessages[field]) ) |
93 | 108 | .replace( /\{FIELD\}/g, settings.fieldMessages[field] ) |
94 | 109 | .replace( /\{VALUE\}/g, '0%' ) |
95 | | - .replace( /\{COUNT\}/g, mw.usability.getMsg( 'field-count' ) ) ) |
| 110 | + .replace( /\{COUNT\}/g, mw.usability.getMsg( 'articleassessment-noratings', [0, 0] ) ) ) |
96 | 111 | ); |
97 | 112 | } |
98 | | - $output.find( '#article-assessment' ).data( 'articleAssessment-context', { 'settings': settings }); |
| 113 | + $output.find( '#article-assessment' ).data( 'articleAssessment-context', { 'settings': settings, 'config': config } ); |
99 | 114 | // hook up the ratings show/hide |
100 | 115 | $output |
101 | 116 | .find( '.article-assessment-show-ratings a' ) |
— | — | @@ -136,9 +151,6 @@ |
137 | 152 | // attempt to fetch the ratings |
138 | 153 | $.ArticleAssessment.fn.getRatingData(); |
139 | 154 | |
140 | | - // attempt to fetch the user's past ratings if it looks like they may have rated this article before |
141 | | - $.ArticleAssessment.fn.getUserRatingData(); |
142 | | - |
143 | 155 | // initialize the star plugin |
144 | 156 | $( '.rating-field' ).each( function() { |
145 | 157 | $( this ) |
— | — | @@ -174,6 +186,7 @@ |
175 | 187 | 'list': 'articleassessment', |
176 | 188 | 'aarevid': wgCurRevisionId, |
177 | 189 | 'aapageid': wgArticleId, |
| 190 | + 'aauserrating': 1, |
178 | 191 | 'format': 'json' |
179 | 192 | }, |
180 | 193 | dataType: 'json', |
— | — | @@ -188,26 +201,35 @@ |
189 | 202 | 'afterGetRatingData' : function( data ) { |
190 | 203 | var settings = $( '#article-assessment' ).data( 'articleAssessment-context' ).settings; |
191 | 204 | // add the correct data to the markup |
192 | | - for( rating in data.query.articleassessment[0].ratings) { |
193 | | - var rating = data.query.articleassessment[0].ratings[rating], |
194 | | - $rating = $( '#' + rating.ratingdesc ), |
195 | | - label = mw.usability.getMsg( 'articleassessment-noratings', [rating.total, rating.count] ); |
196 | | - $rating |
197 | | - .find( '.article-assessment-rating-field-value' ) |
198 | | - .text( rating.total ) |
199 | | - .end() |
200 | | - .find( '.article-assessment-rating-count' ) |
201 | | - .text( label ); |
| 205 | + if( data.query.articleassessment.length > 0 ) { |
| 206 | + for( rating in data.query.articleassessment[0].ratings) { |
| 207 | + var rating = data.query.articleassessment[0].ratings[rating], |
| 208 | + $rating = $( '#' + rating.ratingdesc ), |
| 209 | + label = mw.usability.getMsg( 'articleassessment-noratings', [rating.total, rating.count] ); |
| 210 | + $rating |
| 211 | + .find( '.article-assessment-rating-field-value' ) |
| 212 | + .text( rating.total ) |
| 213 | + .end() |
| 214 | + .find( '.article-assessment-rating-count' ) |
| 215 | + .text( label ); |
| 216 | + if( rating.userrating ) { |
| 217 | + var $rateControl = $( '#' + rating.ratingdesc.replace( 'rating', 'rate' ) + ' .rating-field' ); |
| 218 | + $rateControl.children( '.ui-stars-star' ).eq( rating.userrating - 1 ).click(); |
| 219 | + } |
| 220 | + } |
| 221 | + // if the rating is stale, add the stale class |
| 222 | + if( true /* replace with conditional based on returned results of past user ratings */ ) { |
| 223 | + // add the stale star class to each on star |
| 224 | + $( '.ui-stars-star-on' ) |
| 225 | + .addClass( 'ui-stars-star-stale' ); |
| 226 | + // add the stale message |
| 227 | + $( '.article-assessment-submit' ) |
| 228 | + .append( settings.staleMSG.replace( /\{MSG\}/g, mw.usability.getMsg( 'articleassessment-stalemessage-revisioncount' ) |
| 229 | + .replace( /'''([^']*)'''/g, '<strong>$1</strong >' ) |
| 230 | + .replace( /''([^']*)''/, '<em>$1</em>' ) ) ); |
| 231 | + } |
202 | 232 | } |
203 | | - // if the rating is stale, add the stale class |
204 | | - if( true /* replace with conditional based on returned results of past user ratings */ ) { |
205 | | - // add the stale star class to each on star |
206 | | - $( '.ui-stars-star-on' ) |
207 | | - .addClass( 'ui-stars-star-stale' ); |
208 | | - // add the stale message |
209 | | - $( '.article-assessment-submit' ) |
210 | | - .append( settings.staleMSG.replace( /\{MSG\}/g, mw.usability.getMsg( 'articleassessment-stalemessage-revisioncount' ) ) ); |
211 | | - } |
| 233 | + |
212 | 234 | // initialize the ratings |
213 | 235 | $( '.article-assessment-rating-field-value' ).each( function() { |
214 | 236 | $( this ) |
— | — | @@ -216,26 +238,8 @@ |
217 | 239 | } ) |
218 | 240 | } ); |
219 | 241 | }, |
220 | | - 'getUserRatingData': function() { |
221 | | - var request = $.ajax( { |
222 | | - url: wgScriptPath + '/api.php', |
223 | | - data: { |
224 | | - 'action': 'articleassessment', |
225 | | - 'getUserResults': 1, |
226 | | - 'userId': wgUserName || "", |
227 | | - 'pageId': wgArticleId, |
228 | | - 'revId': wgCurRevisionId |
229 | | - }, |
230 | | - dataType: 'json', |
231 | | - success: function( data ) { |
232 | | - console.log(data); |
233 | | - }, |
234 | | - error: function(XMLHttpRequest, textStatus, errorThrown) { |
235 | | - // console.log( XMLHttpRequest, textStatus, errorThrown ); |
236 | | - } |
237 | | - } ); |
238 | | - }, |
239 | 242 | 'submitRating': function() { |
| 243 | + var config = $( '#article-assessment' ).data( 'articleAssessment-context' ).config; |
240 | 244 | // clear out the stale message |
241 | 245 | var results = {}; |
242 | 246 | $( '.rating-field input' ).each( function() { |
— | — | @@ -248,12 +252,13 @@ |
249 | 253 | url: wgScriptPath + '/api.php', |
250 | 254 | data: { |
251 | 255 | 'action': 'articleassessment', |
252 | | - 'aarevid': wgCurRevisionId, |
253 | | - 'aapageid': wgArticleId, |
| 256 | + 'aarevid': config.revID, |
| 257 | + 'aapageid': config.pageID, |
254 | 258 | 'aar1' : results['wellsourced'], |
255 | 259 | 'aar2' : results['neutrality'], |
256 | 260 | 'aar3' : results['completeness'], |
257 | 261 | 'aar4' : results['readability'], |
| 262 | + 'aauserid': config.userID, |
258 | 263 | 'format': 'json' |
259 | 264 | }, |
260 | 265 | dataType: 'json', |
— | — | @@ -261,7 +266,10 @@ |
262 | 267 | console.log(data); |
263 | 268 | } |
264 | 269 | } ); |
265 | | - } |
| 270 | + }, |
| 271 | + 'flashNotice': function( text, options ) { |
| 272 | + |
| 273 | + } |
266 | 274 | } |
267 | 275 | }; |
268 | 276 | // FIXME - this should be moved out of here |
Index: trunk/extensions/ArticleAssessmentPilot/js/jquery.stars.js |
— | — | @@ -6,7 +6,7 @@ |
7 | 7 | * Marek "Orkan" Zajac (orkans@gmail.com) |
8 | 8 | * http://plugins.jquery.com/project/Star_Rating_widget |
9 | 9 | * |
10 | | - * |
| 10 | + * TODO: Non of the API functions are working right now. Need to rewrite more of this so they will |
11 | 11 | */ |
12 | 12 | (function($) { |
13 | 13 | $.stars = { |
— | — | @@ -235,7 +235,7 @@ |
236 | 236 | value: function() { |
237 | 237 | return this.options.value; |
238 | 238 | }, |
239 | | - select: function(val) { |
| 239 | + select: function( val ) { |
240 | 240 | var o = this.options, e = (val == o.cancelValue) ? this.$cancel : this.$stars.eq(o.val2id[val]); |
241 | 241 | o.forceSelect = true; |
242 | 242 | e.triggerHandler('click.stars'); |
— | — | @@ -269,9 +269,37 @@ |
270 | 270 | o.oneVoteOnly && !o.disabled && this.disable(); |
271 | 271 | } |
272 | 272 | } |
273 | | -$.fn.stars = function ( $$options ) { |
| 273 | +$.fn.stars = function ( ) { |
| 274 | + var args = arguments; |
| 275 | + |
| 276 | + // var context = $( this ).data( 'stars-context' ); |
| 277 | + // if ( typeof context == 'undefined' || context == null ) { |
| 278 | + // context = { |
| 279 | + // options: { |
| 280 | + // } |
| 281 | + // }; |
| 282 | + // } |
| 283 | + // // // Handle various calling styles |
| 284 | + // if ( args.length > 0 ) { |
| 285 | + // if ( typeof args[0] == 'object' ) { |
| 286 | + // // Apply set of properties |
| 287 | + // // for ( var key in args[0] ) { |
| 288 | + // // $.suggestions.configure( context, key, args[0][key] ); |
| 289 | + // // } |
| 290 | + // return $( this ).each( function() { |
| 291 | + // $.stars.init( this, args[0] ); |
| 292 | + // } ); |
| 293 | + // } else if ( typeof args[0] == 'string' ) { |
| 294 | + // // call the function |
| 295 | + // var funcName = args[0]; |
| 296 | + // delete args[0]; |
| 297 | + // return $( this ).each( function() { |
| 298 | + // $.stars[funcName]( args ); |
| 299 | + // } ); |
| 300 | + // } |
| 301 | + // } |
274 | 302 | return $( this ).each( function() { |
275 | | - $.stars.init( this, $$options ); |
| 303 | + $.stars.init( this, args[0] ); |
276 | 304 | } ); |
277 | 305 | }; |
278 | 306 | } )( jQuery ); |