From 61704d58b772941bf9cde392880cc8d48bc6559b Mon Sep 17 00:00:00 2001 From: Gena Date: Tue, 30 Jun 2015 23:56:18 +0600 Subject: [PATCH] auto --- batiskaf/templates/jinja2/base.jinja | 8 +- batiskaf/templates/jinja2/feedback.jinja | 81 + batiskaf/urls.py | 2 + main/admin.py | 6 +- main/forms.py | 12 + main/migrations/0008_feedback.py | 28 + main/migrations/0009_feedback_stars.py | 19 + main/models.py | 27 + main/views.py | 20 +- static/js/_.js | 7 + static/star-rating/_delete.gif | Bin 0 -> 752 bytes static/star-rating/delete.gif | Bin 0 -> 1461 bytes static/star-rating/documentation.html | 1260 +++ static/star-rating/jquery.MetaData.js | 118 + static/star-rating/jquery.form.js | 1127 +++ static/star-rating/jquery.js | 9605 ++++++++++++++++++++++ static/star-rating/jquery.rating.css | 12 + static/star-rating/jquery.rating.js | 376 + static/star-rating/jquery.rating.pack.js | 9 + static/star-rating/star.gif | Bin 0 -> 1802 bytes static/star-rating/star_.gif | Bin 0 -> 815 bytes tmp/eml/20150630-224849-4631101848.eml | 11 + tmp/eml/20150630-224931-4454810064.eml | 11 + tmp/eml/20150630-234252-4487710928.eml | 11 + 24 files changed, 12742 insertions(+), 8 deletions(-) create mode 100644 batiskaf/templates/jinja2/feedback.jinja create mode 100644 main/forms.py create mode 100644 main/migrations/0008_feedback.py create mode 100644 main/migrations/0009_feedback_stars.py create mode 100755 static/star-rating/_delete.gif create mode 100644 static/star-rating/delete.gif create mode 100755 static/star-rating/documentation.html create mode 100755 static/star-rating/jquery.MetaData.js create mode 100755 static/star-rating/jquery.form.js create mode 100755 static/star-rating/jquery.js create mode 100755 static/star-rating/jquery.rating.css create mode 100755 static/star-rating/jquery.rating.js create mode 100755 static/star-rating/jquery.rating.pack.js create mode 100644 static/star-rating/star.gif create mode 100755 static/star-rating/star_.gif create mode 100644 tmp/eml/20150630-224849-4631101848.eml create mode 100644 tmp/eml/20150630-224931-4454810064.eml create mode 100644 tmp/eml/20150630-234252-4487710928.eml diff --git a/batiskaf/templates/jinja2/base.jinja b/batiskaf/templates/jinja2/base.jinja index 280999d..d05cdb8 100644 --- a/batiskaf/templates/jinja2/base.jinja +++ b/batiskaf/templates/jinja2/base.jinja @@ -20,6 +20,7 @@ + {% block stylesheet %}{% endblock stylesheet %} @@ -35,8 +36,6 @@
- - @@ -53,9 +52,7 @@ src="/static/img/skype.png" alt="Написать в Skype" title="Написать в Skype" width="20" height="20"/>
-
-
@@ -71,7 +68,7 @@

Добро пожаловать в интернет-магазин Батискаф!

-

+ Отзывы о магазине Батискаф-Казахстан +


+
+ + + + + +
    +{% if object_list %} + + {% for comment in object_list %} + +
  • + +
    +

    + {% for i in range(1,6) %} + + {% endfor %} + + + {{ comment.name }} пишет: #

    +

    {{ comment.created.strftime('%d.%m.%Y %H:%M') }}

    +

    {{ comment.text|striptags }}

    + + +
    +
  • + + {% endfor %} +
+ {% else %} +
+ Пока нет ни одного отзыва! Вы можете стать первым! +
+ {% endif %} + +
+
+ +

+ Оставить отзыв:

+ +
+
+ {{ form|bootstrap }} +
+ +
+
+
+
+ + +
+ +{% endblock %} + diff --git a/batiskaf/urls.py b/batiskaf/urls.py index 83f2d81..b691a51 100644 --- a/batiskaf/urls.py +++ b/batiskaf/urls.py @@ -70,6 +70,8 @@ urlpatterns = patterns( (r'^robots\.txt$', lambda r: HttpResponse("User-agent: *\nDisallow: \nHost: batiskaf-kz.kz\nSitemap: http://batiskaf-kz.kz/sitemap.xml", content_type="text/plain")), url(r'^size/$', 'main.views.size_index', name='size_index'), + url(r'^feedback/$', 'main.views.feedback', + name='feedback'), url(r'^size/beuchat/$', 'main.views.size_beuchat', name='size_beuchat'), url(r'^size/omer-sporasub/$', 'main.views.size_omer_sporasub', diff --git a/main/admin.py b/main/admin.py index 915bd1f..907981f 100644 --- a/main/admin.py +++ b/main/admin.py @@ -1,7 +1,11 @@ from django.contrib import admin -from .models import Banner +from .models import Banner, Feedback class BannerAdmin(admin.ModelAdmin): list_display = ('title', 'link', 'is_active') +class FeedbackAdmin(admin.ModelAdmin): + list_display = ('created', 'name', 'email', 'text', 'stars') + admin.site.register(Banner, BannerAdmin) +admin.site.register(Feedback, FeedbackAdmin) diff --git a/main/forms.py b/main/forms.py new file mode 100644 index 0000000..b1735f3 --- /dev/null +++ b/main/forms.py @@ -0,0 +1,12 @@ +from django import forms +from django.forms.widgets import RadioChoiceInput +from main.models import Feedback, STARS_CHOICES + + +class FeedbackForm(forms.ModelForm): + stars = forms.IntegerField(widget=forms.RadioSelect(choices=STARS_CHOICES), label='Оценка') + + class Meta: + model = Feedback + fields = ['stars', 'name', 'email', 'text', ] + # widgets = {'stars': forms.RadioSelect(hidden=True)} \ No newline at end of file diff --git a/main/migrations/0008_feedback.py b/main/migrations/0008_feedback.py new file mode 100644 index 0000000..60d5645 --- /dev/null +++ b/main/migrations/0008_feedback.py @@ -0,0 +1,28 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0007_banner'), + ] + + operations = [ + migrations.CreateModel( + name='Feedback', + fields=[ + ('id', models.AutoField(primary_key=True, verbose_name='ID', serialize=False, auto_created=True)), + ('created', models.DateTimeField(auto_now_add=True, verbose_name='Дата и время')), + ('name', models.CharField(max_length=45, verbose_name='Имя')), + ('email', models.EmailField(max_length=254, verbose_name='Email (не будет опубликован)')), + ('text', models.TextField(verbose_name='Комментарий')), + ], + options={ + 'verbose_name': 'отзыв', + 'verbose_name_plural': 'отзывы', + }, + ), + ] diff --git a/main/migrations/0009_feedback_stars.py b/main/migrations/0009_feedback_stars.py new file mode 100644 index 0000000..4da0026 --- /dev/null +++ b/main/migrations/0009_feedback_stars.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0008_feedback'), + ] + + operations = [ + migrations.AddField( + model_name='feedback', + name='stars', + field=models.IntegerField(default=5, verbose_name='Оценка', choices=[(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)]), + ), + ] diff --git a/main/models.py b/main/models.py index 39a9c76..d2c4292 100644 --- a/main/models.py +++ b/main/models.py @@ -1,10 +1,12 @@ from django.db import models + def photo_filename(instance, filename): from slugify import slugify_filename return 'photo_uploads/' + slugify_filename(filename) + class Banner(models.Model): title = models.CharField( 'Альтернативный текст', max_length=256, blank=False, null=False) @@ -15,3 +17,28 @@ class Banner(models.Model): def __str__(self): return self.title + + +STARS_CHOICES = ( + (1, 1), + (2, 2), + (3, 3), + (4, 4), + (5, 5) +) + + +class Feedback(models.Model): + created = models.DateTimeField('Дата и время', auto_now_add=True, editable=False) + name = models.CharField('Имя', max_length=45, null=False, blank=False) + email = models.EmailField('Email (не будет опубликован)', null=False, blank=False) + text = models.TextField('Комментарий', null=False, blank=False) + stars = models.IntegerField('Оценка', default=5, choices=STARS_CHOICES) + # news = models.ForeignKey(News, related_name='comments') + + class Meta: + verbose_name = 'отзыв' + verbose_name_plural = 'отзывы' + + def __str__(self): + return '{}: {}'.format(self.name, self.text) diff --git a/main/views.py b/main/views.py index 8609674..c417146 100644 --- a/main/views.py +++ b/main/views.py @@ -1,6 +1,9 @@ +from django.contrib import messages +from django.core.mail import mail_managers from django.http import JsonResponse -from django.shortcuts import render -from main.models import Banner +from django.shortcuts import render, redirect +from main.forms import FeedbackForm +from main.models import Banner, Feedback from store.models import Product, Category, ProductVariation @@ -63,3 +66,16 @@ def temp_count_update(request, article): except Exception as e: retval['error_code'] = e return JsonResponse(retval) + +def feedback(request): + form = FeedbackForm(request.POST or None) + if form.is_valid(): + form.save() + messages.success(request, 'Ваш отзыв успешно опубликован. Спасибо!') + mail_managers('Оставили отзыв', 'Смотреть в админке') + return redirect('/feedback/') + + return render(request, 'feedback.jinja', dict( + object_list=Feedback.objects.order_by('-pk'), + form=form + )) \ No newline at end of file diff --git a/static/js/_.js b/static/js/_.js index fb9f41d..d050d8e 100644 --- a/static/js/_.js +++ b/static/js/_.js @@ -335,6 +335,13 @@ $(document).ready(function () { //form-group has-error return false; }) + $('input[name=stars]').each(function(){ + var star = $(this); + star.parent('label').replaceWith(star); + }) + $('input[name=stars]').rating(); + $('.star-rating-control').append('

'); + $('.star').rating(); }) ; \ No newline at end of file diff --git a/static/star-rating/_delete.gif b/static/star-rating/_delete.gif new file mode 100755 index 0000000000000000000000000000000000000000..43c6ca8763d79bde87bcf437e497af00c8be562d GIT binary patch literal 752 zcmZ?wbhEHb6kt$bc*el6GthYN-n}zt&b)vB{*)i+-#|NQy$ zABXln&Q1FL`t{#CH*SY|{oJwc*Qz;h;)0))7aYq9ewP~fc2e)_P3vAY)$9wl{IzJp zy{ydlr;a^HiGHwZ{*SH8FZkJhE{gei`OM?;ir*_{?@ji478&@mD*tSH_`A&5@6Vqe z@G<&xeCOwiq-WvY-eS5f?;vgCP8#IHGBw=+^cY}xvy zx8c*8mDl2ff1W;kCeZrNm9vlQYJg5Caki?(^G9DBs4DA0KlA4-ZT3fl8 z8F_gb*}2-1v>0WWwY1oIg_&Emc-aM+Wn|bpRc1GF^$N-etzA1qr9X*XNNWw_j-BjG zGEKc(x)1gUF{(82E@ad^eMXp9hUxg0Q)f<}lVRDncBb&%dq*yAR+(|l-D@bZwvw%g)cL7VG z)An_f*+XqOetkIP*eg{wS7K(+qJ{-x0ue3?v&y~1d1To>MqD_2keNGNE=Pc|!BJ7b fV_(F^#N=Z_Jo9)pKRPly^YODPxtByW{by(X|N7P1wQK(ysQ+)S`_IRE`t<4lMq2*`*#5tH{eS(M z|Hj%t#s7I({{sOF!_1j8fiwfnfZ~7d2;Tq&m&B4pAZ=q`QIMFNom!%hl$xHIXRGvn z_kJaX%oJOta8q9c-vZ~}1OnC3`ysn+mIn+=ATHl0=1y+?>2( zs|s7C#FYG`R4X7GB&@Hb09I0xZL8!6l28EI>6~Abs$i;TrkiYFXrf?lsb^?vW^QS& zqhJK&>l;|;8yV;tSX!AHTNxNBK!Fm_wxX0Ys~{IQs9ivwtx`rwNr9EVetCJhUb(Se zeo?xG?WUP)qwZeFo6%mkOz;^d;tf|AVqJOz-6iAnjTCALaH zmqNUdTL3pUuUHT49lhlIT>Xl~0)0b01CWo>*T>t-)5G1()y3J#(ZSx%*2db((!$)#)Wq1x z&_G{LS4Ue*Q$t-%RYh4zQ9)i#Rz_M%QbJrzR76-vP=KG0mxr5+lY^a&m4%s!k%2++ zCku#V&;gY}pi+;4ZNq^H1s*zL+{}lQ5+y`>6dM>^)^ahpI+R8q<>C&07xqCQ>d2$U zfTm|sEu5>;{pJS?A8Os>x7_MlZnRKZV`!Ele`0Qmb5vtoFJBVh1Q!oBPEKF{fVuPL zyK=Gc2ng`7a0M_*$gf?;&gjaxZp*rjPLk|fx3UX5iR|9Z;v{`=E02@R+M1HJGEM@g v&&aKnbrL_eMSTCwb%zxNcir6Uy!qyKXDQL$qAy$)3CqX`uUIh8k--`OhnoF~ literal 0 HcmV?d00001 diff --git a/static/star-rating/documentation.html b/static/star-rating/documentation.html new file mode 100755 index 0000000..4399cae --- /dev/null +++ b/static/star-rating/documentation.html @@ -0,0 +1,1260 @@ + + + + jQuery Star Rating Plugin v4.11 (2013-03-14) + + + + + + + + + + + + + +
+ +
+ +
+
+ + + + + + + + + + + + + +
+

What is this?

+

+ The Star Rating Plugin is a plugin + for the jQuery Javascript library that creates a non-obstrusive + star rating control based on a set of radio input boxes. +

+ +

What does it do?

+
    +
  • + It turns a collection of radio boxes into a neat star-rating control. +
  • +
  • + It creates the interface based on standard form elements, which means the + basic functionality will still be available even if Javascript is disabled. +
  • +
  • + NEW (18-Feb-2013): + Compatible with jQuery 1.3+ and the latest 1.9! +
  • +
+ +

How do I use it?

+

+ Just add the star class to your radio boxes +

+ + + + + + +
+
<input name="star1" type="radio" class="star"/>
+<input name="star1" type="radio" class="star"/>
+<input name="star1" type="radio" class="star"/>
+<input name="star1" type="radio" class="star"/>
+<input name="star1" type="radio" class="star"/>
+
» + + + + + +
+ +

+ Use the checked property to specify the initial/default value of the control +

+ + + + + + +
+
<input name="star2" type="radio" class="star"/>
+<input name="star2" type="radio" class="star"/>
+<input name="star2" type="radio" class="star" checked="checked"/>
+<input name="star2" type="radio" class="star"/>
+<input name="star2" type="radio" class="star"/>
+
» + + + + + +
+ +

+ Use the disabled property to use a control for display purposes only +

+ + + + + + +
+
<input name="star3" type="radio" class="star" disabled="disabled"/>
+<input name="star3" type="radio" class="star" disabled="disabled"/>
+<input name="star3" type="radio" class="star" disabled="disabled" checked="checked"/>
+<input name="star3" type="radio" class="star" disabled="disabled"/>
+<input name="star3" type="radio" class="star" disabled="disabled"/>
+
» + + + + + +
+ +

What about split stars and 'half ratings'???

+

+ Use metadata plugin to pass advanced settings to the plugin via the class property. +

+ + + + + + +
+
<input name="adv1" type="radio" class="star {split:4}"/>
+<input name="adv1" type="radio" class="star {split:4}"/>
+<input name="adv1" type="radio" class="star {split:4}"/>
+<input name="adv1" type="radio" class="star {split:4}"/>
+<input name="adv1" type="radio" class="star {split:4}" checked="checked"/>
+<input name="adv1" type="radio" class="star {split:4}"/>
+<input name="adv1" type="radio" class="star {split:4}"/>
+<input name="adv1" type="radio" class="star {split:4}"/>
+
» + + + + + + + + +
+ +

+ Use custom selector +

+ + + + + + +
+ +
$(function(){ // wait for document to load
+ $('input.wow').rating();
+});
+
<input name="adv2" type="radio" class="wow {split:4}"/>
+<input name="adv2" type="radio" class="wow {split:4}"/>
+<input name="adv2" type="radio" class="wow {split:4}"/>
+<input name="adv2" type="radio" class="wow {split:4}"/>
+<input name="adv2" type="radio" class="wow {split:4}" checked="checked"/>
+<input name="adv2" type="radio" class="wow {split:4}"/>
+<input name="adv2" type="radio" class="wow {split:4}"/>
+<input name="adv2" type="radio" class="wow {split:4}"/>
+
» + + + + + + + + +
+ + +

Make sure to upload these changes on to your server, this would be a great plugin for your blogs and review sites

+ +
+ +
+

Test Suite

+ + + +
 
+
+Test 1 - A blank form + + + + + +
+ + + + + +
+
+ Rating 1: + (N/M/Y) + + + +
+
+
+ Rating 2: + (10 - 50) + + + + + +
+
+
+ Rating 3: + (1 - 7) + + + + + + + +
+
+
+ Rating 4: + (1 - 5) + + + + + +
+
+
+ Rating 5: + (1 - 5, required) + + + + + +
+
+
+ Rating 6 (readonly): + (1 - 5) + + + + + +
+
+
  +   + Test results:

+
+ Results will be displayed here +
+
+
+ +
 
 
+ +
+Test 2 - With defaults ('checked') + + + + + +
+ + + + + +
+
+ Rating 1: + (N/M/Y, default M) +
+
+ + + +
+
+ Rating 2: + (10 - 50, default 30) +
+
+ + + + + +
+
+ Rating 3: + (1 - 7, default 4) +
+
+ + + + + + + +
+
+
+ Rating 4: + (1 - 5, default 1) +
+
+ + + + + +
+
+ Rating 5: + (1 - 5, default 5, required) +
+
+ + + + + +
+
+ Rating 6 (readonly): + (1 - 5, default 3) +
+
+ + + + + +
+
+
  +   + Test results:

+
+ Results will be displayed here +
+
+
+ +
 
 
+ +
+ +Test 3-A - With callback + + + + + +
+
+ Rating 1: + (1 - 3, default 2) + + + +
+
+
$('.auto-submit-star').rating({
+  callback: function(value, link){
+    alert(value);
+  }
+});
+
+
  +   + Test results:

+
+ Results will be displayed here +
+
+
+ +
 
 
+ + +
+Test 3-B - With hover effects + + + + + +
+
+ Rating 1: + (1 - 3, default 2) +
+ + + + + + Hover tips will appear in here +
+
+
+
$('.hover-star').rating({
+  focus: function(value, link){
+    var tip = $('#hover-test');
+    tip[0].data = tip[0].data || tip.html();
+    tip.html(link.title || 'value: '+value);
+  },
+  blur: function(value, link){
+    var tip = $('#hover-test');
+    $('#hover-test').html(tip[0].data || '');
+  }
+});
+
+
  +   + Test results:

+
+ Results will be displayed here +
+
+
+ +
 
 
+ +
+Test 4 - Half Stars and Split Stars + + + + + +
+ + + + + +
+
+ Rating 1: + (N/M/Y/?) +
<input class="star {half:true}"
+ + + + +
+
+
+ Rating 2: + (10 - 60) +
<input class="star {split:3}"
+ + + + + + +
+
+
+ Rating 3: + (0-5.0, default 3.5) +
<input class="star {split:2}"
+ + + + + + + + + + +
+
+
+ Rating 4: + (1-6, default 5) +
<input class="star {split:2}"
+ + + + + + +
+
+
+ Rating 5: + (1-20, default 11, required) +
<input class="star {split:4}"
+ + + + + + + + + + + + + + + + + + + + +
+
+
+ Rating 6 (readonly): + (1-20, default 13) +
<input class="star {split:4}"
+ + + + + + + + + + + + + + + + + + + + +
+
+
  +   + Test results:

+
+ Results will be displayed here +
+
+
+
+ +
+

API

+

NEW to v3

+ +

API methods can be invoked this this:

+
$(selector).rating(
+ 'method', // method name
+ [] // method arguments (not required)
+);
+ +


+ +

$().rating('select', index / value)

+

+ Use this method to set the value (and display) of the star rating control + via javascript. It accepts the index of the star you want to select (0 based) + or its value (which must be passed as a string. +

+

+ Example: (values A/B/C/D/E) +

+
+ + + + + + + +
+ By index: + + + + + + eg.: $('input').rating('select',3) +
+ By value: + + + + + + eg.: $('input').rating('select','C') +
+ +


+ +

$().rating('readOnly', true / false)

+

+ Use this method to set the value (and display) of the star rating control + via javascript. It accepts the index of the star you want to select (0 based) + or its value (which must be passed as a string. +

+

+ Example: (values 1,2,3...10) +

+
+ + + + + + + + + + + + +
+ + eg.: $('input').rating('readOnly',true) +
+ + eg.: $('input').rating('readOnly',false) or simply $('input').rating('readOnly'); +
+ +


+ +

$().rating('disable') / $().rating('enable')

+

+ These methods bahve almost exactly as the readOnly method, however + they also control whether or not the select value is submitted with + the form. +

+

+ Example: (values 1,2,3...10) +

+
+ + + + + + + + + + + + +
+ + eg.: $('input').rating('disable') +
+ + eg.: $('input').rating('enable'); +
+
+ +
+

Database Integration

+

+ I'm sorry to say that for the time being, it is up to you + to create the server-side code that will + process the form submission, store it somewhere (like a database) and do stuff with it - + such as displaying averages and stop users from voting more than once. +

+

+ However, here are a few alternatives if you don't feel + like getting down and dirty with some good old coding: +
http://www.yvoschaap.com/index.php/weblog/css_star_rater_ajax_version/ +
+
and +
part 1: http://www.komodomedia.com/blog/2005/08/creating-a-star-rater-using-css/ +
part 2: http://slim.climaxdesigns.com/tutorial.php?section=slim&id=2 +
part 3: http://slim.climaxdesigns.com/tutorial.php?section=slim&id=3 +
part 4: http://slim.climaxdesigns.com/tutorial.php?section=slim&id=9 +

+
+ +
+

Background Information

+

As far as I know, this is how it goes...

+
    +
  • It all started with Will Stuckey's jQuery Star Rating Super Interface!
  • +
  • The original then became the inspiration for Ritesh Agrawal's Simple Star Rating System, + which allows for a GMail like star/un-star toggle.
  • +
  • This was followed by several spin-offs... (one of which is the Half-star rating plugin)
  • +
  • Then someone at PHPLetter.com modified the plugin to overcome the issues - then plugin was now based on standard form elements, meaning + the interface would still work with Javascript disabled making it beautifully downgradable.
  • +
  • Then I came along and noticed a fundamental flaw with the latter: there could only + be one star rating control per page. The rest of the story is what you will see below...
  • +
  • (12-Mar-08): Then Keith Wood added some very nice functionality to the plugin: + option to disable the cancel button, option to make the plugin readOnly and ability to accept any value (other than whole numbers)
  • +
  • (20-Mar-08): Now supports half-star, third-star, quater-star, etc... Not additional code required. No additional images required.
  • +
  • (31-Mar-08): Two new events, hover/blur (arguments: [value, linkElement])
  • +
  • NEW (18-Feb-2013): Compatible with jQuery 1.6, 1.7, 1.8 and 1.9!
  • +
+
+ +
+

Download

+

+ This project (and all related files) can also be accessed via its + Google Code Project Page. +

+ + + + + + + + + + + + + + + + + +
Full Package: + + + v4.11 + star-rating.zip + +
+
+ Stay up-to-date! + + Major updates will be announced on + Twitter: + @fyneworks + +
+
Core Files: + These are the individual required files (already included in the zip package above) + +
jQuery: + jquery-1.9.1.min.js (see jQuery.com) +
+ +

Related Downloads

+ + + + + +
Related: + Metadata plugin - Used to retrieve inline configuration from class variable +
+ Form plugin - Used to submit forms via ajax +
+ +

SVN Repository

+

+ If you're a major geek or if you really really want to stay up-to-date with + with future updates of this plugin, go ahead and plug yourself to the + SVN Repository + on the official + Google Code Project Page. +

+ + + + + + + + + +
SVN Checkout: + + SVN Checkout Instructions +
Browse Online: + + Browse Source +
+ +

Alternative Download - From this website

+

+ Just in case it's the end of the world and the Google Code site becomes unavailable, + the project files can also be downloaded from this site. +
+ However, please note that this site is updated periodically whereas the Google Code + project is kept up-to-date almost instantaneously. If you'd like the very latest + version of this plugin + you are advised to use the links above and download the files from Google Code + - this will ensure the files you download have the very latest features and bug fixes. +

+ + + + + + + + + + + + + + + + + +
Full Package: + + v4.11 + star-rating.zip +
+
+ Stay up-to-date! + + Major updates will be announced on + Twitter: + @fyneworks + +
+
Core Files: + These are the individual required files (already included in the zip package above) + +
jQuery: + jquery-1.9.1.min.js (see jQuery.com) +
+ +
+ +
+ +

Support

+

+ Quick Support Links: Help me! + | Report a bug + | Suggest new feature + +

+

+ Support for this plugin is available through the jQuery Mailing List. + This is a very active list to which many jQuery developers and users subscribe. +
+ Access to the jQuery Mailing List is also available through + Nabble Forums + and the + jQuery Google Group. +

+

+ WARNING: + Support will not be provided via the jQuery Plugins + website. + If you need help, please direct your questions to the + jQuery Mailing List + or + report an issue + on the official + Google Code Project Page. +

+ +

Official Links

+ + +

Credits

+ +

+ If we've missed anyone (anyone!) please contact us (info at fyneworks.com) and we'll make sure + to give credit where credit is due. +

+
+ + + + + + + + + + + + + + +
+

What's the catch?

+

+ There's no catch. Use it, abuse it - even take it + apart and modify it if you know what you're doing. You don't have to, + but if you're feeling generous you can link back to this website (instructions below). +

+ +

Attribute this work

+
+ + + + + + + + + +
Attribution link:© Fyneworks.com
HTML Code: + +
+
+

License Info

+
+ + + + + + + + +
+ Star Rating Plugin + by Fyneworks.com + is licensed, + as jQuery is, + under the + MIT License. + Creative Commons License
+ +
+
+
+
+ + + + + +
+

Multiple File Upload Plugin

+

+ + Provides a non-obstrusive way of selecting multiple files for upload. + Supports validation and form plugins. +

+ +

Star-Rating Plugin

+

+ + Creates a non-obstrusive star-rating control from any set of radio boxes. + Features include half/partial stars and an API for programmatic control. + Supports the validation plugin. +

+ +

XML to JSON

+

+ + Convert XML to JSON and read data from XML files/RSS feeds with ease. +

+ +
+ +

CKEditor Plugin

+

+ jQuery plugin for non-obstrusive integration of textareas with CKEditor. +

+ +

FCKEditor Plugin

+

+ jQuery plugin for non-obstrusive integration of textareas with FCKEditor. +
+ OLD! It is recommended you upgrade to CKEditor (above). +

+ +

Codepress Plugin

+

+ jQuery plugin for non-obstrusive integration of textareas with Codepress. +

+
+
+
+
+
+
+
+ + + + diff --git a/static/star-rating/jquery.MetaData.js b/static/star-rating/jquery.MetaData.js new file mode 100755 index 0000000..b416718 --- /dev/null +++ b/static/star-rating/jquery.MetaData.js @@ -0,0 +1,118 @@ +/* + * Metadata - jQuery plugin for parsing metadata from elements + * + * Copyright (c) 2006 John Resig, Yehuda Katz, Jrn Zaefferer, Paul McLanahan + * + * Licensed under http://en.wikipedia.org/wiki/MIT_License + * + * + */ + +/** + * 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: + * + * attr: Inside an attribute. The name parameter indicates *which* attribute. + * + * class: Inside the class attribute, wrapped in curly braces: { } + * + * elem: Inside a child element (e.g. a script tag). The + * name parameter indicates *which* element. + * + * The metadata for an element is loaded the first time the element is accessed via jQuery. + * + * As a result, you can define the metadata type, use $(expr) to load the metadata into the elements + * matched by expr, then redefine the metadata type and run another $(expr) for other elements. + * + * @name $.metadata.setType + * + * @example

This is a p

+ * @before $.metadata.setType("class") + * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" + * @desc Reads metadata from the class attribute + * + * @example

This is a p

+ * @before $.metadata.setType("attr", "data") + * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" + * @desc Reads metadata from a "data" attribute + * + * @example

This is a p

+ * @before $.metadata.setType("elem", "script") + * @after $("#one").metadata().item_id == 1; $("#one").metadata().item_label == "Label" + * @desc Reads metadata from a nested script element + * + * @param String type The encoding type + * @param String name The name of the attribute to be used to get metadata (optional) + * @cat Plugins/Metadata + * @descr Sets the type of encoding to be used when loading metadata for the first time + * @type undefined + * @see metadata() + */ + +(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; + } + } +}); + +/** + * Returns the metadata object for the first member of the jQuery object. + * + * @name metadata + * @descr Returns element's metadata object + * @param Object opts An object contianing settings to override the defaults + * @type jQuery + * @cat Plugins/Metadata + */ +$.fn.metadata = function( opts ){ + return $.metadata.get( this[0], opts ); +}; + +})(jQuery); \ No newline at end of file diff --git a/static/star-rating/jquery.form.js b/static/star-rating/jquery.form.js new file mode 100755 index 0000000..64f9216 --- /dev/null +++ b/static/star-rating/jquery.form.js @@ -0,0 +1,1127 @@ +/*! + * jQuery Form Plugin + * version: 3.27.0-2013.02.06 + * @requires jQuery v1.5 or later + * + * Examples and documentation at: http://malsup.com/jquery/form/ + * Project repository: https://github.com/malsup/form + * Dual licensed under the MIT and GPL licenses: + * http://malsup.github.com/mit-license.txt + * http://malsup.github.com/gpl-license-v2.txt + */ +/*global ActiveXObject alert */ +;(function($) { +"use strict"; + +/* + Usage Note: + ----------- + Do not use both ajaxSubmit and ajaxForm on the same form. These + functions are mutually exclusive. Use ajaxSubmit if you want + to bind your own submit handler to the form. For example, + + $(document).ready(function() { + $('#myForm').on('submit', function(e) { + e.preventDefault(); // <-- important + $(this).ajaxSubmit({ + target: '#output' + }); + }); + }); + + Use ajaxForm when you want the plugin to manage all the event binding + for you. For example, + + $(document).ready(function() { + $('#myForm').ajaxForm({ + target: '#output' + }); + }); + + You can also use ajaxForm with delegation (requires jQuery v1.7+), so the + form does not have to exist when you invoke ajaxForm: + + $('#myForm').ajaxForm({ + delegation: true, + target: '#output' + }); + + When using ajaxForm, the ajaxSubmit function will be invoked for you + at the appropriate time. +*/ + +/** + * Feature detection + */ +var feature = {}; +feature.fileapi = $("").get(0).files !== undefined; +feature.formdata = window.FormData !== undefined; + +/** + * ajaxSubmit() provides a mechanism for immediately submitting + * an HTML form using AJAX. + */ +$.fn.ajaxSubmit = function(options) { + /*jshint scripturl:true */ + + // fast fail if nothing selected (http://dev.jquery.com/ticket/2752) + if (!this.length) { + log('ajaxSubmit: skipping submit process - no element selected'); + return this; + } + + var method, action, url, $form = this; + + if (typeof options == 'function') { + options = { success: options }; + } + + method = this.attr('method'); + action = this.attr('action'); + url = (typeof action === 'string') ? $.trim(action) : ''; + url = url || window.location.href || ''; + if (url) { + // clean url (don't include hash vaue) + url = (url.match(/^([^#]+)/)||[])[1]; + } + + options = $.extend(true, { + url: url, + success: $.ajaxSettings.success, + type: method || 'GET', + iframeSrc: /^https/i.test(window.location.href || '') ? 'javascript:false' : 'about:blank' + }, options); + + // hook for manipulating the form data before it is extracted; + // convenient for use with rich editors like tinyMCE or FCKEditor + var veto = {}; + this.trigger('form-pre-serialize', [this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-pre-serialize trigger'); + return this; + } + + // provide opportunity to alter form data before it is serialized + if (options.beforeSerialize && options.beforeSerialize(this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSerialize callback'); + return this; + } + + var traditional = options.traditional; + if ( traditional === undefined ) { + traditional = $.ajaxSettings.traditional; + } + + var elements = []; + var qx, a = this.formToArray(options.semantic, elements); + if (options.data) { + options.extraData = options.data; + qx = $.param(options.data, traditional); + } + + // give pre-submit callback an opportunity to abort the submit + if (options.beforeSubmit && options.beforeSubmit(a, this, options) === false) { + log('ajaxSubmit: submit aborted via beforeSubmit callback'); + return this; + } + + // fire vetoable 'validate' event + this.trigger('form-submit-validate', [a, this, options, veto]); + if (veto.veto) { + log('ajaxSubmit: submit vetoed via form-submit-validate trigger'); + return this; + } + + var q = $.param(a, traditional); + if (qx) { + q = ( q ? (q + '&' + qx) : qx ); + } + if (options.type.toUpperCase() == 'GET') { + options.url += (options.url.indexOf('?') >= 0 ? '&' : '?') + q; + options.data = null; // data is null for 'get' + } + else { + options.data = q; // data is the query string for 'post' + } + + var callbacks = []; + if (options.resetForm) { + callbacks.push(function() { $form.resetForm(); }); + } + if (options.clearForm) { + callbacks.push(function() { $form.clearForm(options.includeHidden); }); + } + + // perform a load on the target only if dataType is not provided + if (!options.dataType && options.target) { + var oldSuccess = options.success || function(){}; + callbacks.push(function(data) { + var fn = options.replaceTarget ? 'replaceWith' : 'html'; + $(options.target)[fn](data).each(oldSuccess, arguments); + }); + } + else if (options.success) { + callbacks.push(options.success); + } + + options.success = function(data, status, xhr) { // jQuery 1.4+ passes xhr as 3rd arg + var context = options.context || this ; // jQuery 1.4+ supports scope context + for (var i=0, max=callbacks.length; i < max; i++) { + callbacks[i].apply(context, [data, status, xhr || $form, $form]); + } + }; + + // are there files to upload? + + // [value] (issue #113), also see comment: + // https://github.com/malsup/form/commit/588306aedba1de01388032d5f42a60159eea9228#commitcomment-2180219 + var fileInputs = $('input[type=file]:enabled[value!=""]', this); + + var hasFileInputs = fileInputs.length > 0; + var mp = 'multipart/form-data'; + var multipart = ($form.attr('enctype') == mp || $form.attr('encoding') == mp); + + var fileAPI = feature.fileapi && feature.formdata; + log("fileAPI :" + fileAPI); + var shouldUseFrame = (hasFileInputs || multipart) && !fileAPI; + + var jqxhr; + + // options.iframe allows user to force iframe mode + // 06-NOV-09: now defaulting to iframe mode if file input is detected + if (options.iframe !== false && (options.iframe || shouldUseFrame)) { + // hack to fix Safari hang (thanks to Tim Molendijk for this) + // see: http://groups.google.com/group/jquery-dev/browse_thread/thread/36395b7ab510dd5d + if (options.closeKeepAlive) { + $.get(options.closeKeepAlive, function() { + jqxhr = fileUploadIframe(a); + }); + } + else { + jqxhr = fileUploadIframe(a); + } + } + else if ((hasFileInputs || multipart) && fileAPI) { + jqxhr = fileUploadXhr(a); + } + else { + jqxhr = $.ajax(options); + } + + $form.removeData('jqxhr').data('jqxhr', jqxhr); + + // clear element array + for (var k=0; k < elements.length; k++) + elements[k] = null; + + // fire 'notify' event + this.trigger('form-submit-notify', [this, options]); + return this; + + // utility fn for deep serialization + function deepSerialize(extraData){ + var serialized = $.param(extraData).split('&'); + var len = serialized.length; + var result = []; + var i, part; + for (i=0; i < len; i++) { + // #252; undo param space replacement + serialized[i] = serialized[i].replace(/\+/g,' '); + part = serialized[i].split('='); + // #278; use array instead of object storage, favoring array serializations + result.push([decodeURIComponent(part[0]), decodeURIComponent(part[1])]); + } + return result; + } + + // XMLHttpRequest Level 2 file uploads (big hat tip to francois2metz) + function fileUploadXhr(a) { + var formdata = new FormData(); + + for (var i=0; i < a.length; i++) { + formdata.append(a[i].name, a[i].value); + } + + if (options.extraData) { + var serializedData = deepSerialize(options.extraData); + for (i=0; i < serializedData.length; i++) + if (serializedData[i]) + formdata.append(serializedData[i][0], serializedData[i][1]); + } + + options.data = null; + + var s = $.extend(true, {}, $.ajaxSettings, options, { + contentType: false, + processData: false, + cache: false, + type: method || 'POST' + }); + + if (options.uploadProgress) { + // workaround because jqXHR does not expose upload property + s.xhr = function() { + var xhr = jQuery.ajaxSettings.xhr(); + if (xhr.upload) { + xhr.upload.addEventListener('progress', function(event) { + var percent = 0; + var position = event.loaded || event.position; /*event.position is deprecated*/ + var total = event.total; + if (event.lengthComputable) { + percent = Math.ceil(position / total * 100); + } + options.uploadProgress(event, position, total, percent); + }, false); + } + return xhr; + }; + } + + s.data = null; + var beforeSend = s.beforeSend; + s.beforeSend = function(xhr, o) { + o.data = formdata; + if(beforeSend) + beforeSend.call(this, xhr, o); + }; + return $.ajax(s); + } + + // private function for handling file uploads (hat tip to YAHOO!) + function fileUploadIframe(a) { + var form = $form[0], el, i, s, g, id, $io, io, xhr, sub, n, timedOut, timeoutHandle; + var useProp = !!$.fn.prop; + var deferred = $.Deferred(); + + if (a) { + // ensure that every serialized input is still enabled + for (i=0; i < elements.length; i++) { + el = $(elements[i]); + if ( useProp ) + el.prop('disabled', false); + else + el.removeAttr('disabled'); + } + } + + s = $.extend(true, {}, $.ajaxSettings, options); + s.context = s.context || s; + id = 'jqFormIO' + (new Date().getTime()); + if (s.iframeTarget) { + $io = $(s.iframeTarget); + n = $io.attr('name'); + if (!n) + $io.attr('name', id); + else + id = n; + } + else { + $io = $('