diff --git a/CHANGELOG b/CHANGELOG index 3b8daa56e..e6bc93b06 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ Version 1.1.3 to be released - Bug #1252: CJSON::encode() was not able to encode models and model arrays (Sam Dark) - Enh #663: Improved CSecurityManager to allow customizing the crypt/hash algorithms being used (Qiang) - Enh #862: Enhanced CSort virtual attributes and support for related tables (Qiang) +- Enh #930: Updated CStarRating's jQuery plugin to v3.13, updated jQuery Metadata plugin (Sam Dark) - Enh #952: Enhanced support for using defaultParams in CUrlManager (Qiang) - Enh #1158: Added translations in Latvian (lafriks) - Enh #1166: Added CActiveRecord::setOldPrimaryKey (Qiang) diff --git a/UPGRADE b/UPGRADE index f71f40ae5..42964c817 100644 --- a/UPGRADE +++ b/UPGRADE @@ -17,6 +17,7 @@ to be true. Also, if you have configured the 'widgets' property, you should rename it to be 'skinnableWidgets'. These changes are due to the introduction of the global widget customization feature. Please see the guide (the "Theming" section) for more details. +- Clean up your assets directory after updating. Upgrading from v1.1.1 --------------------- diff --git a/framework/web/js/packages.php b/framework/web/js/packages.php index 900ac557e..0005c4ce6 100644 --- a/framework/web/js/packages.php +++ b/framework/web/js/packages.php @@ -89,7 +89,6 @@ $dependencies=array( ), 'rating'=>array( 'jquery', - 'dimensions', 'metadata', ), 'bbq'=>array( diff --git a/framework/web/js/source/jquery.metadata.js b/framework/web/js/source/jquery.metadata.js index afc0f0c02..9da403fde 100644 --- a/framework/web/js/source/jquery.metadata.js +++ b/framework/web/js/source/jquery.metadata.js @@ -15,7 +15,7 @@ * Sets the type of metadata to use. Metadata is encoded in JSON, and each property * in the JSON will become a property of the element itself. * - * There are three supported types of metadata storage: + * There are four supported types of metadata storage: * * attr: Inside an attribute. The name parameter indicates *which* attribute. * @@ -23,6 +23,7 @@ * * elem: Inside a child element (e.g. a script tag). The * name parameter indicates *which* element. + * html5: Values are stored in data-* attributes. * * The metadata for an element is loaded the first time the element is accessed via jQuery. * @@ -46,6 +47,11 @@ * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" * @desc Reads metadata from a nested script element * + * @example

This is a p

+ * @before $.metadata.setType("html5") + * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" + * @desc Reads metadata from a series of data-* attributes + * * @param String type The encoding type * @param String name The name of the attribute to be used to get metadata (optional) * @cat Plugins/Metadata @@ -57,52 +63,73 @@ (function($) { $.extend({ - metadata : { - defaults : { - type: 'class', - name: 'metadata', - cre: /({.*})/, - single: 'metadata' - }, - setType: function( type, name ){ - this.defaults.type = type; - this.defaults.name = name; - }, - get: function( elem, opts ){ - var settings = $.extend({},this.defaults,opts); - // check for empty string in single property - if ( !settings.single.length ) settings.single = 'metadata'; - - var data = $.data(elem, settings.single); - // returned cached data if it already exists - if ( data ) return data; - - data = "{}"; - - if ( settings.type == "class" ) { - var m = settings.cre.exec( elem.className ); - if ( m ) - data = m[1]; - } else if ( settings.type == "elem" ) { - if( !elem.getElementsByTagName ) return; - var e = elem.getElementsByTagName(settings.name); - if ( e.length ) - data = $.trim(e[0].innerHTML); - } else if ( elem.getAttribute != undefined ) { - var attr = elem.getAttribute( settings.name ); - if ( attr ) - data = attr; - } - - if ( data.indexOf( '{' ) <0 ) - data = "{" + data + "}"; - - data = eval("(" + data + ")"); - - $.data( elem, settings.single, data ); - return data; - } - } + metadata : { + defaults : { + type: 'class', + name: 'metadata', + cre: /({.*})/, + single: 'metadata' + }, + setType: function( type, name ){ + this.defaults.type = type; + this.defaults.name = name; + }, + get: function( elem, opts ){ + var settings = $.extend({},this.defaults,opts); + // check for empty string in single property + if ( !settings.single.length ) settings.single = 'metadata'; + + var data = $.data(elem, settings.single); + // returned cached data if it already exists + if ( data ) return data; + + data = "{}"; + + var getData = function(data) { + if(typeof data != "string") return data; + + if( data.indexOf('{') < 0 ) { + data = eval("(" + data + ")"); + } + } + + var getObject = function(data) { + if(typeof data != "string") return data; + + data = eval("(" + data + ")"); + return data; + } + + if ( settings.type == "html5" ) { + var object = {}; + $( elem.attributes ).each(function() { + var name = this.nodeName; + if(name.match(/^data-/)) name = name.replace(/^data-/, ''); + else return true; + object[name] = getObject(this.nodeValue); + }); + } else { + if ( settings.type == "class" ) { + var m = settings.cre.exec( elem.className ); + if ( m ) + data = m[1]; + } else if ( settings.type == "elem" ) { + if( !elem.getElementsByTagName ) return; + var e = elem.getElementsByTagName(settings.name); + if ( e.length ) + data = $.trim(e[0].innerHTML); + } else if ( elem.getAttribute != undefined ) { + var attr = elem.getAttribute( settings.name ); + if ( attr ) + data = attr; + } + object = getObject(data.indexOf("{") < 0 ? "{" + data + "}" : data); + } + + $.data( elem, settings.single, object ); + return object; + } + } }); /** @@ -115,7 +142,7 @@ $.extend({ * @cat Plugins/Metadata */ $.fn.metadata = function( opts ){ - return $.metadata.get( this[0], opts ); + return $.metadata.get( this[0], opts ); }; })(jQuery); \ No newline at end of file diff --git a/framework/web/js/source/jquery.rating.js b/framework/web/js/source/jquery.rating.js index 335a05bca..119bfeb22 100644 --- a/framework/web/js/source/jquery.rating.js +++ b/framework/web/js/source/jquery.rating.js @@ -1,208 +1,383 @@ -/* - ### jQuery Star Rating Plugin v2.61 - 2009-01-23 ### - * Home: http://www.fyneworks.com/jquery/star-rating/ - * Code: http://code.google.com/p/jquery-star-rating-plugin/ - * - * Dual licensed under the MIT and GPL licenses: - * http://www.opensource.org/licenses/mit-license.php - * http://www.gnu.org/licenses/gpl.html - ### -*//* - Based on http://www.phpletter.com/Demo/Jquery-Star-Rating-Plugin/ - Original comments: - This is hacked version of star rating created by Ritesh Agrawal - It transforms a set of radio type input elements to star rating type and remain the radio element name and value, - so could be integrated with your form. It acts as a normal radio button. - modified by : Logan Cai (cailongqun[at]yahoo.com.cn) - - Last modified by Qiang Xue on Feb. 26, 2009 - added support to allow input names like post[rating] (previously this won't work). -*/ - -/*# AVOID COLLISIONS #*/ -;if(window.jQuery) (function($){ -/*# AVOID COLLISIONS #*/ - - // IE6 Background Image Fix - if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { } - // Thanks to http://www.visualjquery.com/rating/rating_redux.html - - // default settings - $.rating = { - cancel: 'Cancel Rating', // advisory title for the 'cancel' link - cancelValue: '', // value to submit when user click the 'cancel' link - split: 0, // split the star into how many parts? - - // Width of star image in case the plugin can't work it out. This can happen if - // the jQuery.dimensions plugin is not available OR the image is hidden at installation - starWidth: 16, - - //NB.: These don't need to be defined (can be undefined/null) so let's save some code! - //half: false, // just a shortcut to settings.split = 2 - //required: false, // disables the 'cancel' button so user can only select one of the specified values - //readOnly: false, // disable rating plugin interaction/ values cannot be changed - //focus: function(){}, // executed when stars are focused - //blur: function(){}, // executed when stars are focused - //callback: function(){}, // executed when a star is clicked - - // required properties: - groups: {},// allows multiple star ratings on one page - event: {// plugin event handlers - fill: function(n, el, settings, state){ // fill to the current mouse position. - //if(window.console) console.log(['fill', $(el), $(el).prevAll('.star_group_'+n.replace(/\[|\]/g, "_")), arguments]); - this.drain(n); - $(el).prevAll('.star_group_'+n.replace(/\[|\]/g, "_")).andSelf().addClass('star_'+(state || 'hover')); - // focus handler, as requested by focusdigital.co.uk - var lnk = $(el).children('a'); val = lnk.text(); - if(settings.focus) settings.focus.apply($.rating.groups[n].valueElem[0], [val, lnk[0]]); - }, - drain: function(n, el, settings) { // drain all the stars. - //if(window.console) console.log(['drain', $(el), $(el).prevAll('.star_group_'+n.replace(/\[|\]/g, "_")), arguments]); - $.rating.groups[n].valueElem.siblings('.star_group_'+n.replace(/\[|\]/g, "_")).removeClass('star_on').removeClass('star_hover'); - }, - reset: function(n, el, settings){ // Reset the stars to the default index. - if(!$($.rating.groups[n].current).is('.cancel')) - $($.rating.groups[n].current).prevAll('.star_group_'+n.replace(/\[|\]/g, "_")).andSelf().addClass('star_on'); - // blur handler, as requested by focusdigital.co.uk - var lnk = $(el).children('a'); val = lnk.text(); - if(settings.blur) settings.blur.apply($.rating.groups[n].valueElem[0], [val, lnk[0]]); - }, - click: function(n, el, settings){ // Selected a star or cancelled - $.rating.groups[n].current = el; - var lnk = $(el).children('a'); val = lnk.text(); - // Set value - $.rating.groups[n].valueElem.val(val); - // Update display - $.rating.event.drain(n, el, settings); - $.rating.event.reset(n, el, settings); - // click callback, as requested here: http://plugins.jquery.com/node/1655 - if(settings.callback) settings.callback.apply($.rating.groups[n].valueElem[0], [val, lnk[0]]); - } - }// plugin events - }; - - $.fn.rating = function(instanceSettings){ - if(this.length==0) return this; // quick fail - - instanceSettings = $.extend( - {}/* new object */, - $.rating/* global settings */, - instanceSettings || {} /* just-in-time settings */ - ); - - // loop through each matched element - this.each(function(i){ - - var settings = $.extend( - {}/* new object */, - instanceSettings || {} /* current call settings */, - ($.metadata? $(this).metadata(): ($.meta?$(this).data():null)) || {} /* metadata settings */ - ); - - ////if(window.console) console.log([this.name, settings.half, settings.split], '#'); - - // Generate internal control ID - var n = (this.name || 'unnamed-rating'); - - // Grouping - if(!$.rating.groups[n]) $.rating.groups[n] = {count: 0}; - i = $.rating.groups[n].count; $.rating.groups[n].count++; - - // Accept readOnly setting from 'disabled' property - $.rating.groups[n].readOnly = $.rating.groups[n].readOnly || settings.readOnly || $(this).attr('disabled'); - - // Things to do with the first element... - if(i == 0){ - // Create value element (disabled if readOnly) - $.rating.groups[n].valueElem = $(''); - // Insert value element into form - $(this).before($.rating.groups[n].valueElem); - - if($.rating.groups[n].readOnly || settings.required){ - // DO NOT display 'cancel' button - } - else{ - // Display 'cancel' button - $(this).before( - $('
' + settings.cancelValue + '
') - .mouseover(function(){ $.rating.event.drain(n, this, settings); $(this).addClass('star_on'); }) - .mouseout(function(){ $.rating.event.reset(n, this, settings); $(this).removeClass('star_on'); }) - .click(function(){ $.rating.event.click(n, this, settings); }) - ); - } - }; // if (i == 0) (first element) - - // insert rating option right after preview element - eStar = $('
' + this.value + '
'); - $(this).after(eStar); - - // Half-stars? - if(settings.half) settings.split = 2; - - // Prepare division settings - if(typeof settings.split=='number' && settings.split>0){ - var stw = ($.fn.width ? $(eStar).width() : 0) || settings.starWidth; - var spi = (i % settings.split), spw = Math.floor(stw/settings.split); - $(eStar) - // restrict star's width and hide overflow (already in CSS) - .width(spw) - // move the star left by using a negative margin - // this is work-around to IE's stupid box model (position:relative doesn't work) - .find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' }) - }; - - // Remember group name so controls within the same container don't get mixed up - $(eStar).addClass('star_group_'+n.replace(/\[|\]/g, "_")); - - // readOnly? - if($.rating.groups[n].readOnly)//{ //save a byte! - // Mark star as readOnly so user can customize display - $(eStar).addClass('star_readonly'); - //} //save a byte! - else//{ //save a byte! - $(eStar) - // Enable hover css effects - .addClass('star_live') - // Attach mouse events - .mouseover(function(){ $.rating.event.drain(n, this, settings); $.rating.event.fill(n, this, settings, 'hover'); }) - .mouseout(function(){ $.rating.event.drain(n, this, settings); $.rating.event.reset(n, this, settings); }) - .click(function(){ $.rating.event.click(n, this, settings); }); - //}; //save a byte! - - ////if(window.console) console.log(['###', n, this.checked, $.rating.groups[n].initial]); - if(this.checked) $.rating.groups[n].current = eStar; - - //remove this checkbox - $(this).remove(); - - // reset display if last element - if(i + 1 == this.length) $.rating.event.reset(n, this, settings); - - }); // each element - - // initialize groups... - for(n in $.rating.groups)//{ not needed, save a byte! - (function(c, v, n){ if(!c) return; - $.rating.event.fill(n, c, instanceSettings || {}, 'on'); - $(v).val($(c).children('a').text()); - }) - ($.rating.groups[n].current, $.rating.groups[n].valueElem, n); - //}; not needed, save a byte! - - return this; // don't break the chain... - }; - - - - /* - ### Default implementation ### - The plugin will attach itself to file inputs - with the class 'multi' when the page loads - */ - $(function(){ $('input[type=radio].star').rating(); }); - - - -/*# AVOID COLLISIONS #*/ -})(jQuery); -/*# AVOID COLLISIONS #*/ +/* + ### jQuery Star Rating Plugin v3.13 - 2009-03-26 ### + * Home: http://www.fyneworks.com/jquery/star-rating/ + * Code: http://code.google.com/p/jquery-star-rating-plugin/ + * + * Dual licensed under the MIT and GPL licenses: + * http://www.opensource.org/licenses/mit-license.php + * http://www.gnu.org/licenses/gpl.html + ### +*/ + +/*# AVOID COLLISIONS #*/ +;if(window.jQuery) (function($){ +/*# AVOID COLLISIONS #*/ + + // IE6 Background Image Fix + if ($.browser.msie) try { document.execCommand("BackgroundImageCache", false, true)} catch(e) { }; + // Thanks to http://www.visualjquery.com/rating/rating_redux.html + + // plugin initialization + $.fn.rating = function(options){ + if(this.length==0) return this; // quick fail + + // Handle API methods + if(typeof arguments[0]=='string'){ + // Perform API methods on individual elements + if(this.length>1){ + var args = arguments; + return this.each(function(){ + $.fn.rating.apply($(this), args); + }); + }; + // Invoke API method handler + $.fn.rating[arguments[0]].apply(this, $.makeArray(arguments).slice(1) || []); + // Quick exit... + return this; + }; + + // Initialize options for this call + var options = $.extend( + {}/* new object */, + $.fn.rating.options/* default options */, + options || {} /* just-in-time options */ + ); + + // Allow multiple controls with the same name by making each call unique + $.fn.rating.calls++; + + // loop through each matched element + this + .not('.star-rating-applied') + .addClass('star-rating-applied') + .each(function(){ + + // Load control parameters / find context / etc + var control, input = $(this); + var eid = (this.name || 'unnamed-rating').replace(/\[|\]/g, '_').replace(/^\_+|\_+$/g,''); + var context = $(this.form || document.body); + + // FIX: http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=23 + var raters = context.data('rating'); + if(!raters || raters.call!=$.fn.rating.calls) raters = { count:0, call:$.fn.rating.calls }; + var rater = raters[eid]; + + // if rater is available, verify that the control still exists + if(rater) control = rater.data('rating'); + + if(rater && control)//{// save a byte! + // add star to control if rater is available and the same control still exists + control.count++; + + //}// save a byte! + else{ + // create new control if first star or control element was removed/replaced + + // Initialize options for this raters + control = $.extend( + {}/* new object */, + options || {} /* current call options */, + ($.metadata? input.metadata(): ($.meta?input.data():null)) || {}, /* metadata options */ + { count:0, stars: [], inputs: [] } + ); + + // increment number of rating controls + control.serial = raters.count++; + + // create rating element + rater = $(''); + input.before(rater); + + // Mark element for initialization (once all stars are ready) + rater.addClass('rating-to-be-drawn'); + + // Accept readOnly setting from 'disabled' property + if(input.attr('disabled')) control.readOnly = true; + + // Create 'cancel' button + rater.append( + control.cancel = $('
' + control.cancelValue + '
') + .mouseover(function(){ + $(this).rating('drain'); + $(this).addClass('star-rating-hover'); + //$(this).rating('focus'); + }) + .mouseout(function(){ + $(this).rating('draw'); + $(this).removeClass('star-rating-hover'); + //$(this).rating('blur'); + }) + .click(function(){ + $(this).rating('select'); + }) + .data('rating', control) + ); + + }; // first element of group + + // insert rating star + var star = $('
' + this.value + '
'); + rater.append(star); + + // inherit attributes from input element + if(this.id) star.attr('id', this.id); + if(this.className) star.addClass(this.className); + + // Half-stars? + if(control.half) control.split = 2; + + // Prepare division control + if(typeof control.split=='number' && control.split>0){ + var stw = ($.fn.width ? star.width() : 0) || control.starWidth; + var spi = (control.count % control.split), spw = Math.floor(stw/control.split); + star + // restrict star's width and hide overflow (already in CSS) + .width(spw) + // move the star left by using a negative margin + // this is work-around to IE's stupid box model (position:relative doesn't work) + .find('a').css({ 'margin-left':'-'+ (spi*spw) +'px' }) + }; + + // readOnly? + if(control.readOnly)//{ //save a byte! + // Mark star as readOnly so user can customize display + star.addClass('star-rating-readonly'); + //} //save a byte! + else//{ //save a byte! + // Enable hover css effects + star.addClass('star-rating-live') + // Attach mouse events + .mouseover(function(){ + $(this).rating('fill'); + $(this).rating('focus'); + }) + .mouseout(function(){ + $(this).rating('draw'); + $(this).rating('blur'); + }) + .click(function(){ + $(this).rating('select'); + }) + ; + //}; //save a byte! + + // set current selection + if(this.checked) control.current = star; + + // hide input element + input.hide(); + + // backward compatibility, form element to plugin + input.change(function(){ + $(this).rating('select'); + }); + + // attach reference to star to input element and vice-versa + star.data('rating.input', input.data('rating.star', star)); + + // store control information in form (or body when form not available) + control.stars[control.stars.length] = star[0]; + control.inputs[control.inputs.length] = input[0]; + control.rater = raters[eid] = rater; + control.context = context; + + input.data('rating', control); + rater.data('rating', control); + star.data('rating', control); + context.data('rating', raters); + }); // each element + + // Initialize ratings (first draw) + $('.rating-to-be-drawn').rating('draw').removeClass('rating-to-be-drawn'); + + return this; // don't break the chain... + }; + + /*--------------------------------------------------------*/ + + /* + ### Core functionality and API ### + */ + $.extend($.fn.rating, { + // Used to append a unique serial number to internal control ID + // each time the plugin is invoked so same name controls can co-exist + calls: 0, + + focus: function(){ + var control = this.data('rating'); if(!control) return this; + if(!control.focus) return this; // quick fail if not required + // find data for event + var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null ); + // focus handler, as requested by focusdigital.co.uk + if(control.focus) control.focus.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]); + }, // $.fn.rating.focus + + blur: function(){ + var control = this.data('rating'); if(!control) return this; + if(!control.blur) return this; // quick fail if not required + // find data for event + var input = $(this).data('rating.input') || $( this.tagName=='INPUT' ? this : null ); + // blur handler, as requested by focusdigital.co.uk + if(control.blur) control.blur.apply(input[0], [input.val(), $('a', input.data('rating.star'))[0]]); + }, // $.fn.rating.blur + + fill: function(){ // fill to the current mouse position. + var control = this.data('rating'); if(!control) return this; + // do not execute when control is in read-only mode + if(control.readOnly) return; + // Reset all stars and highlight them up to this element + this.rating('drain'); + this.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-hover'); + },// $.fn.rating.fill + + drain: function() { // drain all the stars. + var control = this.data('rating'); if(!control) return this; + // do not execute when control is in read-only mode + if(control.readOnly) return; + // Reset all stars + control.rater.children().filter('.rater-'+ control.serial).removeClass('star-rating-on').removeClass('star-rating-hover'); + },// $.fn.rating.drain + + draw: function(){ // set value and stars to reflect current selection + var control = this.data('rating'); if(!control) return this; + // Clear all stars + this.rating('drain'); + // Set control value + if(control.current){ + control.current.data('rating.input').attr('checked','checked'); + control.current.prevAll().andSelf().filter('.rater-'+ control.serial).addClass('star-rating-on'); + } + else + $(control.inputs).removeAttr('checked'); + // Show/hide 'cancel' button + control.cancel[control.readOnly || control.required?'hide':'show'](); + // Add/remove read-only classes to remove hand pointer + this.siblings()[control.readOnly?'addClass':'removeClass']('star-rating-readonly'); + },// $.fn.rating.draw + + + + + + select: function(value,wantCallBack){ // select a value + + // ***** MODIFICATION ***** + // Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27 + // + // ***** LIST OF MODIFICATION ***** + // ***** added Parameter wantCallBack : false if you don't want a callback. true or undefined if you want postback to be performed at the end of this method' + // ***** recursive calls to this method were like : ... .rating('select') it's now like .rating('select',undefined,wantCallBack); (parameters are set.) + // ***** line which is calling callback + // ***** /LIST OF MODIFICATION ***** + + var control = this.data('rating'); if(!control) return this; + // do not execute when control is in read-only mode + if(control.readOnly) return; + // clear selection + control.current = null; + // programmatically (based on user input) + if(typeof value!='undefined'){ + // select by index (0 based) + if(typeof value=='number') + return $(control.stars[value]).rating('select',undefined,wantCallBack); + // select by literal value (must be passed as a string + if(typeof value=='string') + //return + $.each(control.stars, function(){ + if($(this).data('rating.input').val()==value) $(this).rating('select',undefined,wantCallBack); + }); + } + else + control.current = this[0].tagName=='INPUT' ? + this.data('rating.star') : + (this.is('.rater-'+ control.serial) ? this : null); + + // Update rating control state + this.data('rating', control); + // Update display + this.rating('draw'); + // find data for event + var input = $( control.current ? control.current.data('rating.input') : null ); + // click callback, as requested here: http://plugins.jquery.com/node/1655 + + // **** MODIFICATION ***** + // Thanks to faivre.thomas - http://code.google.com/p/jquery-star-rating-plugin/issues/detail?id=27 + // + //old line doing the callback : + //if(control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event + // + //new line doing the callback (if i want :) + if((wantCallBack ||wantCallBack == undefined) && control.callback) control.callback.apply(input[0], [input.val(), $('a', control.current)[0]]);// callback event + //to ensure retro-compatibility, wantCallBack must be considered as true by default + // **** /MODIFICATION ***** + + },// $.fn.rating.select + + + + + + readOnly: function(toggle, disable){ // make the control read-only (still submits value) + var control = this.data('rating'); if(!control) return this; + // setread-only status + control.readOnly = toggle || toggle==undefined ? true : false; + // enable/disable control value submission + if(disable) $(control.inputs).attr("disabled", "disabled"); + else $(control.inputs).removeAttr("disabled"); + // Update rating control state + this.data('rating', control); + // Update display + this.rating('draw'); + },// $.fn.rating.readOnly + + disable: function(){ // make read-only and never submit value + this.rating('readOnly', true, true); + },// $.fn.rating.disable + + enable: function(){ // make read/write and submit value + this.rating('readOnly', false, false); + }// $.fn.rating.select + + }); + + /*--------------------------------------------------------*/ + + /* + ### Default Settings ### + eg.: You can override default control like this: + $.fn.rating.options.cancel = 'Clear'; + */ + $.fn.rating.options = { //$.extend($.fn.rating, { options: { + cancel: 'Cancel Rating', // advisory title for the 'cancel' link + cancelValue: '', // value to submit when user click the 'cancel' link + split: 0, // split the star into how many parts? + + // Width of star image in case the plugin can't work it out. This can happen if + // the jQuery.dimensions plugin is not available OR the image is hidden at installation + starWidth: 16//, + + //NB.: These don't need to be pre-defined (can be undefined/null) so let's save some code! + //half: false, // just a shortcut to control.split = 2 + //required: false, // disables the 'cancel' button so user can only select one of the specified values + //readOnly: false, // disable rating plugin interaction/ values cannot be changed + //focus: function(){}, // executed when stars are focused + //blur: function(){}, // executed when stars are focused + //callback: function(){}, // executed when a star is clicked + }; //} }); + + /*--------------------------------------------------------*/ + + /* + ### Default implementation ### + The plugin will attach itself to file inputs + with the class 'multi' when the page loads + */ + $(function(){ + $('input[type=radio].star').rating(); + }); + + + +/*# AVOID COLLISIONS #*/ +})(jQuery); +/*# AVOID COLLISIONS #*/ diff --git a/framework/web/js/source/rating/jquery.rating.css b/framework/web/js/source/rating/jquery.rating.css index 90d8516c6..50cf2e2d2 100644 --- a/framework/web/js/source/rating/jquery.rating.css +++ b/framework/web/js/source/rating/jquery.rating.css @@ -1,14 +1,12 @@ /* jQuery.Rating Plugin CSS - http://www.fyneworks.com/jquery/star-rating/ */ -div.rating{cursor:pointer;margin:2em;clear:both;display:block} -div.rating:after{content:'.';display:block;height:0;width:0;clear:both;visibility:hidden} -div.cancel,div.star{float:left;width:17px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden} -div.cancel,div.cancel a{background:url('delete.gif') no-repeat 0 -16px} -div.star,div.star a{background:url('star.gif') no-repeat 0 0px} -div.cancel a,div.star a{display:block;width:16px;height:100%;background-position:0 0px;border:1 solid #FF0000} -div.star_on a{background-position:0 -16px!important} -div.star_hover a,div.star_live a:hover{background-position:0 -32px} +div.rating-cancel,div.star-rating{float:left;width:17px;height:15px;text-indent:-999em;cursor:pointer;display:block;background:transparent;overflow:hidden} +div.rating-cancel,div.rating-cancel a{background:url(delete.gif) no-repeat 0 -16px} +div.star-rating,div.star-rating a{background:url(star.gif) no-repeat 0 0px} +div.rating-cancel a,div.star-rating a{display:block;width:16px;height:100%;background-position:0 0px;border:0} +div.star-rating-on a{background-position:0 -16px!important} +div.star-rating-hover a{background-position:0 -32px} /* Read Only CSS */ -div.star_readonly a,div.star_readonly a:hover{cursor:default !important} +div.star-rating-readonly a{cursor:default !important} /* Partial Star CSS */ -div.star{background:transparent!important;overflow:hidden!important} +div.star-rating{background:transparent!important;overflow:hidden!important} /* END jQuery.Rating Plugin CSS */ \ No newline at end of file