Added the spin jquery plugin
Patch by: "Mario Ferraro" <fadinlight@gmail.com>
Reviewed by: to-be-reviewed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/app/jquery/jquery-spin-1.0.2.js Sat Mar 07 20:26:58 2009 +0000
@@ -0,0 +1,75 @@
+/**
+ * jquery.spin-button
+ * (c) 2008 Semooh (http://semooh.jp/)
+ *
+ * Dual licensed under the MIT (MIT-LICENSE.txt)
+ * and GPL (GPL-LICENSE.txt) licenses.
+ *
+ **/
+(function($){
+ $.fn.extend({
+ spin: function(opt){
+ return this.each(function(){
+ opt = $.extend({
+ imageBasePath: '/soc/content/images/',
+ spinBtnImage: 'spin-button.png',
+ spinUpImage: 'spin-up.png',
+ spinDownImage: 'spin-down.png',
+ interval: 1,
+ max: null,
+ min: null,
+ timeInterval: 500,
+ timeBlink: 200
+ }, opt || {});
+
+ var txt = $(this);
+
+ var spinBtnImage = opt.imageBasePath+opt.spinBtnImage;
+ var btnSpin = new Image();
+ btnSpin.src = spinBtnImage;
+ var spinUpImage = opt.imageBasePath+opt.spinUpImage;
+ var btnSpinUp = new Image();
+ btnSpinUp.src = spinUpImage;
+ var spinDownImage = opt.imageBasePath+opt.spinDownImage;
+ var btnSpinDown = new Image();
+ btnSpinDown.src = spinDownImage;
+
+ var btn = $(document.createElement('img'));
+ btn.attr('src', spinBtnImage);
+ btn.css({cursor: 'pointer', verticalAlign: 'bottom', padding: 0, margin: 0});
+ txt.after(btn);
+ txt.css({marginRight:0, paddingRight:0});
+
+ function spin(vector){
+ var val = txt.val();
+ if(!isNaN(val)){
+ val = parseFloat(val) + (vector*opt.interval);
+ if(opt.min!=null && val<opt.min) val=opt.min;
+ if(opt.min!=null && val>opt.max) val=opt.max;
+ if(val != txt.val()){
+ txt.val(val);
+ txt.change();
+ src = (vector > 0 ? spinUpImage : spinDownImage);
+ btn.attr('src', src);
+ if(opt.timeBlink<opt.timeInterval)
+ setTimeout(function(){btn.attr('src', spinBtnImage);}, opt.timeBlink);
+ }
+ }
+ }
+
+ btn.mousedown(function(e){
+ var pos = e.pageY - btn.offset().top;
+ var vector = (btn.height()/2 > pos ? 1 : -1);
+ (function(){
+ spin(vector);
+ var tk = setTimeout(arguments.callee, opt.timeInterval);
+ $(document).one('mouseup', function(){
+ clearTimeout(tk); btn.attr('src', spinBtnImage);
+ });
+ })();
+ return false;
+ });
+ });
+ }
+ });
+})(jQuery);
Binary file app/soc/content/images/spin-button.png has changed
Binary file app/soc/content/images/spin-down.png has changed
Binary file app/soc/content/images/spin-up.png has changed
--- a/app/soc/templates/soc/base.html Sat Mar 07 19:46:18 2009 +0000
+++ b/app/soc/templates/soc/base.html Sat Mar 07 20:26:58 2009 +0000
@@ -50,6 +50,9 @@
{% if uses_jq_purr %}
<script type='text/javascript' src="/jquery/jquery-purr.js"></script>
{% endif %}
+ {% if uses_jq_spin %}
+ <script type='text/javascript' src="/jquery/jquery-spin-1.0.2.js"></script>
+ {% endif %}
{% if uses_jq_bt %}
<script type='text/javascript' src="/soc/content/js/tips-081027.js"></script>
{% endif %}
--- a/app/soc/views/helper/params.py Sat Mar 07 19:46:18 2009 +0000
+++ b/app/soc/views/helper/params.py Sat Mar 07 20:26:58 2009 +0000
@@ -56,6 +56,7 @@
'jq_bgiframe',
'jq_bt',
'jq_purr',
+ 'jq_spin',
'jq_datetimepicker',
'jq_progressbar',
'jq_thickbox',
@@ -236,7 +237,7 @@
new_params['js_uses_list'] = ['jq', 'menu']
new_params['js_uses_show'] = ['jq', 'menu']
new_params['js_uses_edit'] = ['jq', 'menu', 'tinymce', 'jq_bt',
- 'jq_purr','jq_autocomplete']
+ 'jq_purr','jq_spin','jq_autocomplete']
new_params['error_public'] = 'soc/%(module_name)s/error.html' % params
new_params['error_export'] = new_params['error_public']