rails_qaptcha 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in rails_qaptcha.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,93 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rails_qaptcha (0.0.1)
5
+ rails (= 3.0.8)
6
+
7
+ GEM
8
+ remote: http://rubygems.org/
9
+ specs:
10
+ abstract (1.0.0)
11
+ actionmailer (3.0.8)
12
+ actionpack (= 3.0.8)
13
+ mail (~> 2.2.19)
14
+ actionpack (3.0.8)
15
+ activemodel (= 3.0.8)
16
+ activesupport (= 3.0.8)
17
+ builder (~> 2.1.2)
18
+ erubis (~> 2.6.6)
19
+ i18n (~> 0.5.0)
20
+ rack (~> 1.2.1)
21
+ rack-mount (~> 0.6.14)
22
+ rack-test (~> 0.5.7)
23
+ tzinfo (~> 0.3.23)
24
+ activemodel (3.0.8)
25
+ activesupport (= 3.0.8)
26
+ builder (~> 2.1.2)
27
+ i18n (~> 0.5.0)
28
+ activerecord (3.0.8)
29
+ activemodel (= 3.0.8)
30
+ activesupport (= 3.0.8)
31
+ arel (~> 2.0.10)
32
+ tzinfo (~> 0.3.23)
33
+ activeresource (3.0.8)
34
+ activemodel (= 3.0.8)
35
+ activesupport (= 3.0.8)
36
+ activesupport (3.0.8)
37
+ arel (2.0.10)
38
+ builder (2.1.2)
39
+ diff-lcs (1.1.2)
40
+ erubis (2.6.6)
41
+ abstract (>= 1.0.0)
42
+ i18n (0.5.0)
43
+ mail (2.2.19)
44
+ activesupport (>= 2.3.6)
45
+ i18n (>= 0.4.0)
46
+ mime-types (~> 1.16)
47
+ treetop (~> 1.4.8)
48
+ mime-types (1.16)
49
+ polyglot (0.3.1)
50
+ rack (1.2.3)
51
+ rack-mount (0.6.14)
52
+ rack (>= 1.0.0)
53
+ rack-test (0.5.7)
54
+ rack (>= 1.0)
55
+ rails (3.0.8)
56
+ actionmailer (= 3.0.8)
57
+ actionpack (= 3.0.8)
58
+ activerecord (= 3.0.8)
59
+ activeresource (= 3.0.8)
60
+ activesupport (= 3.0.8)
61
+ bundler (~> 1.0)
62
+ railties (= 3.0.8)
63
+ railties (3.0.8)
64
+ actionpack (= 3.0.8)
65
+ activesupport (= 3.0.8)
66
+ rake (>= 0.8.7)
67
+ thor (~> 0.14.4)
68
+ rake (0.9.2)
69
+ rspec (2.6.0)
70
+ rspec-core (~> 2.6.0)
71
+ rspec-expectations (~> 2.6.0)
72
+ rspec-mocks (~> 2.6.0)
73
+ rspec-core (2.6.4)
74
+ rspec-expectations (2.6.0)
75
+ diff-lcs (~> 1.1.2)
76
+ rspec-mocks (2.6.0)
77
+ rspec-rails (2.6.1)
78
+ actionpack (~> 3.0)
79
+ activesupport (~> 3.0)
80
+ railties (~> 3.0)
81
+ rspec (~> 2.6.0)
82
+ thor (0.14.6)
83
+ treetop (1.4.9)
84
+ polyglot (>= 0.3.1)
85
+ tzinfo (0.3.28)
86
+
87
+ PLATFORMS
88
+ ruby
89
+
90
+ DEPENDENCIES
91
+ rails_qaptcha!
92
+ rspec
93
+ rspec-rails
data/README.markdown ADDED
@@ -0,0 +1,32 @@
1
+ jQuery captcha system with jQuery & jQuery UI for Rails 3
2
+ =========================================================
3
+
4
+ __modify from: [QapTcha](http://www.myjqueryplugins.com/QapTcha "QapTcha")__
5
+
6
+ Support Env:
7
+ ------------
8
+ Rails3.0.8+/Ruby1.8.7+
9
+
10
+ Usage:
11
+ ------
12
+
13
+ 1. rails g rails_qaptcha:install
14
+ 2. in layout:
15
+ * = stylesheet_link_tag :qaptcha
16
+ * = javascript_include_tag :qaptcha
17
+ 3. in your haml page place the following div:
18
+
19
+ * #QapTcha
20
+
21
+ 4. in your application.js:
22
+
23
+ >$(document).ready(function(){
24
+ >
25
+ > $('#QapTcha').QapTcha({autoRevert:true});
26
+ >
27
+ > // or
28
+ >
29
+ > $('.QapTcha').QapTcha({autoRevert:true});
30
+ >});
31
+
32
+ ——If you want to control it in server side, you need to judge session[:iQapTcha]——
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,26 @@
1
+ #
2
+ # qaptchas_controller.rb
3
+ # rails_qaptcha
4
+ #
5
+ # Created by Zhang Alex on 2011-06-27.
6
+ # Copyright 2011 __blackanger.z@gmail.com__. All rights reserved.
7
+ #
8
+
9
+ class QaptchasController < ApplicationController
10
+
11
+ def check
12
+ iqaptcha = params[:iQapTcha]
13
+ if iqaptcha.blank?
14
+ session[:iQapTcha] = true
15
+ msg = "Form can be submited!"
16
+ else
17
+ session[:iQapTcha] = false
18
+ msg = "Form can not be submited!"
19
+ end
20
+ @result = {:check => session[:iQapTcha], :msg => msg}
21
+ respond_to do |format|
22
+ format.json { render :json => @result.to_json }
23
+ end
24
+ end #check
25
+
26
+ end
data/config/routes.rb ADDED
@@ -0,0 +1,9 @@
1
+ Rails.application.routes.draw do
2
+
3
+ resources :qaptchas do
4
+ collection do
5
+ post :check, :as => :check
6
+ end
7
+ end
8
+
9
+ end
@@ -0,0 +1,25 @@
1
+ require 'rails/generators'
2
+
3
+ # =================================
4
+ # = rails g rails_qaptcha:install =
5
+ # =================================
6
+
7
+ module RailsQaptcha
8
+ module Generators
9
+
10
+ class InstallGenerator < Rails::Generators::Base
11
+
12
+ source_root File.expand_path('../media', __FILE__)
13
+ desc "Copies media files to main project"
14
+ def copy_mongoid_yml_files
15
+ copy_file "../media/images/bg_QapTcha.png", "public/stylesheets/image/qaptcha/bg_QapTcha.png"
16
+ copy_file "../media/images/sprites.png", "public/stylesheets/image/qaptcha/sprites.png"
17
+ copy_file "../media/javascripts/jquery-ui.js", "public/javascripts/qaptcha/jquery-ui.js"
18
+ copy_file "../media/javascripts/jquery.ui.touch.js", "public/javascripts/qaptcha/jquery.ui.touch.js"
19
+ copy_file "../media/javascripts/QapTcha.jquery.js", "public/javascripts/qaptcha/QapTcha.jquery.js"
20
+ copy_file "../media/stylesheets/QapTcha.jquery.css", "public/stylesheets/qaptcha/QapTcha.jquery.css"
21
+ end
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,88 @@
1
+ /************************************************************************
2
+ *************************************************************************
3
+ @Name : QapTcha - jQuery Plugin
4
+ @Revison : 2.6
5
+ @Date : 26/01/2011
6
+ @Author: Surrel Mickael (www.myjqueryplugins.com - www.msconcept.fr)
7
+ @License : Open Source - MIT License : http://www.opensource.org/licenses/mit-license.php
8
+
9
+ **************************************************************************
10
+ *************************************************************************/
11
+ jQuery.QapTcha = {
12
+ build : function(options)
13
+ {
14
+ var defaults = {
15
+ txtLock : 'Locked : form can\'t be submited',
16
+ txtUnlock : 'Unlocked : form can be submited',
17
+ disabledSubmit : true,
18
+ autoRevert : false
19
+ };
20
+
21
+ if(this.length>0)
22
+ return jQuery(this).each(function(i) {
23
+ /** Vars **/
24
+ var
25
+ opts = $.extend(defaults, options),
26
+ $this = $(this),
27
+ form = $('form').has($this),
28
+ Clr = jQuery('<div>',{'class':'clr'}),
29
+ bgSlider = jQuery('<div>',{id:'bgSlider'}),
30
+ Slider = jQuery('<div>',{id:'Slider'}),
31
+ Icons = jQuery('<div>',{id:'Icons'}),
32
+ TxtStatus = jQuery('<div>',{id:'TxtStatus','class':'dropError',text:opts.txtLock}),
33
+ inputQapTcha = jQuery('<input>',{name:'iQapTcha',value:generatePass(),type:'hidden'});
34
+
35
+ /** Disabled submit button **/
36
+ if(opts.disabledSubmit) form.find('input[type=\'submit\']').attr('disabled','disabled');
37
+
38
+ /** Construct DOM **/
39
+ bgSlider.appendTo($this);
40
+ Icons.insertAfter(bgSlider);
41
+ Clr.insertAfter(Icons);
42
+ TxtStatus.insertAfter(Clr);
43
+ inputQapTcha.appendTo($this);
44
+ Slider.appendTo(bgSlider);
45
+ $this.show();
46
+
47
+ Slider.draggable({
48
+ revert: function(){
49
+ if(opts.autoRevert)
50
+ {
51
+ if(parseInt(Slider.css("left")) > 150) return false;
52
+ else return true;
53
+ }
54
+ },
55
+ containment: bgSlider,
56
+ axis:'x',
57
+ stop: function(event,ui){
58
+ if(ui.position.left > 150)
59
+ {
60
+ // set the SESSION iQaptcha in PHP file
61
+ $.post('qaptchas/check',
62
+ function(data) {
63
+ if(data['check'])
64
+ {
65
+ Slider.draggable('disable').css('cursor','default');
66
+ inputQapTcha.val("");
67
+ TxtStatus.text(opts.txtUnlock).addClass('dropSuccess').removeClass('dropError');
68
+ Icons.css('background-position', '-16px 0');
69
+ form.find('input[type=\'submit\']').removeAttr('disabled');
70
+ }
71
+ },'json');
72
+ }
73
+ }
74
+ });
75
+
76
+ function generatePass() {
77
+ var chars = 'azertyupqsdfghjkmwxcvbn23456789AZERTYUPQSDFGHJKMWXCVBN';
78
+ var pass = '';
79
+ for(i=0;i<10;i++){
80
+ var wpos = Math.round(Math.random()*chars.length);
81
+ pass += chars.substring(wpos,wpos+1);
82
+ }
83
+ return pass;
84
+ }
85
+
86
+ });
87
+ }
88
+ }; jQuery.fn.QapTcha = jQuery.QapTcha.build;
@@ -0,0 +1,116 @@
1
+ /*!
2
+ * jQuery UI 1.8.9
3
+ *
4
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
5
+ * Dual licensed under the MIT or GPL Version 2 licenses.
6
+ * http://jquery.org/license
7
+ *
8
+ * http://docs.jquery.com/UI
9
+ */
10
+ (function(c,j){function k(a){return!c(a).parents().andSelf().filter(function(){return c.curCSS(this,"visibility")==="hidden"||c.expr.filters.hidden(this)}).length}c.ui=c.ui||{};if(!c.ui.version){c.extend(c.ui,{version:"1.8.9",keyCode:{ALT:18,BACKSPACE:8,CAPS_LOCK:20,COMMA:188,COMMAND:91,COMMAND_LEFT:91,COMMAND_RIGHT:93,CONTROL:17,DELETE:46,DOWN:40,END:35,ENTER:13,ESCAPE:27,HOME:36,INSERT:45,LEFT:37,MENU:93,NUMPAD_ADD:107,NUMPAD_DECIMAL:110,NUMPAD_DIVIDE:111,NUMPAD_ENTER:108,NUMPAD_MULTIPLY:106,
11
+ NUMPAD_SUBTRACT:109,PAGE_DOWN:34,PAGE_UP:33,PERIOD:190,RIGHT:39,SHIFT:16,SPACE:32,TAB:9,UP:38,WINDOWS:91}});c.fn.extend({_focus:c.fn.focus,focus:function(a,b){return typeof a==="number"?this.each(function(){var d=this;setTimeout(function(){c(d).focus();b&&b.call(d)},a)}):this._focus.apply(this,arguments)},scrollParent:function(){var a;a=c.browser.msie&&/(static|relative)/.test(this.css("position"))||/absolute/.test(this.css("position"))?this.parents().filter(function(){return/(relative|absolute|fixed)/.test(c.curCSS(this,
12
+ "position",1))&&/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0):this.parents().filter(function(){return/(auto|scroll)/.test(c.curCSS(this,"overflow",1)+c.curCSS(this,"overflow-y",1)+c.curCSS(this,"overflow-x",1))}).eq(0);return/fixed/.test(this.css("position"))||!a.length?c(document):a},zIndex:function(a){if(a!==j)return this.css("zIndex",a);if(this.length){a=c(this[0]);for(var b;a.length&&a[0]!==document;){b=a.css("position");
13
+ if(b==="absolute"||b==="relative"||b==="fixed"){b=parseInt(a.css("zIndex"),10);if(!isNaN(b)&&b!==0)return b}a=a.parent()}}return 0},disableSelection:function(){return this.bind((c.support.selectstart?"selectstart":"mousedown")+".ui-disableSelection",function(a){a.preventDefault()})},enableSelection:function(){return this.unbind(".ui-disableSelection")}});c.each(["Width","Height"],function(a,b){function d(f,g,l,m){c.each(e,function(){g-=parseFloat(c.curCSS(f,"padding"+this,true))||0;if(l)g-=parseFloat(c.curCSS(f,
14
+ "border"+this+"Width",true))||0;if(m)g-=parseFloat(c.curCSS(f,"margin"+this,true))||0});return g}var e=b==="Width"?["Left","Right"]:["Top","Bottom"],h=b.toLowerCase(),i={innerWidth:c.fn.innerWidth,innerHeight:c.fn.innerHeight,outerWidth:c.fn.outerWidth,outerHeight:c.fn.outerHeight};c.fn["inner"+b]=function(f){if(f===j)return i["inner"+b].call(this);return this.each(function(){c(this).css(h,d(this,f)+"px")})};c.fn["outer"+b]=function(f,g){if(typeof f!=="number")return i["outer"+b].call(this,f);return this.each(function(){c(this).css(h,
15
+ d(this,f,true,g)+"px")})}});c.extend(c.expr[":"],{data:function(a,b,d){return!!c.data(a,d[3])},focusable:function(a){var b=a.nodeName.toLowerCase(),d=c.attr(a,"tabindex");if("area"===b){b=a.parentNode;d=b.name;if(!a.href||!d||b.nodeName.toLowerCase()!=="map")return false;a=c("img[usemap=#"+d+"]")[0];return!!a&&k(a)}return(/input|select|textarea|button|object/.test(b)?!a.disabled:"a"==b?a.href||!isNaN(d):!isNaN(d))&&k(a)},tabbable:function(a){var b=c.attr(a,"tabindex");return(isNaN(b)||b>=0)&&c(a).is(":focusable")}});
16
+ c(function(){var a=document.body,b=a.appendChild(b=document.createElement("div"));c.extend(b.style,{minHeight:"100px",height:"auto",padding:0,borderWidth:0});c.support.minHeight=b.offsetHeight===100;c.support.selectstart="onselectstart"in b;a.removeChild(b).style.display="none"});c.extend(c.ui,{plugin:{add:function(a,b,d){a=c.ui[a].prototype;for(var e in d){a.plugins[e]=a.plugins[e]||[];a.plugins[e].push([b,d[e]])}},call:function(a,b,d){if((b=a.plugins[b])&&a.element[0].parentNode)for(var e=0;e<b.length;e++)a.options[b[e][0]]&&
17
+ b[e][1].apply(a.element,d)}},contains:function(a,b){return document.compareDocumentPosition?a.compareDocumentPosition(b)&16:a!==b&&a.contains(b)},hasScroll:function(a,b){if(c(a).css("overflow")==="hidden")return false;b=b&&b==="left"?"scrollLeft":"scrollTop";var d=false;if(a[b]>0)return true;a[b]=1;d=a[b]>0;a[b]=0;return d},isOverAxis:function(a,b,d){return a>b&&a<b+d},isOver:function(a,b,d,e,h,i){return c.ui.isOverAxis(a,d,h)&&c.ui.isOverAxis(b,e,i)}})}})(jQuery);
18
+ ;/*!
19
+ * jQuery UI Widget 1.8.9
20
+ *
21
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
22
+ * Dual licensed under the MIT or GPL Version 2 licenses.
23
+ * http://jquery.org/license
24
+ *
25
+ * http://docs.jquery.com/UI/Widget
26
+ */
27
+ (function(b,j){if(b.cleanData){var k=b.cleanData;b.cleanData=function(a){for(var c=0,d;(d=a[c])!=null;c++)b(d).triggerHandler("remove");k(a)}}else{var l=b.fn.remove;b.fn.remove=function(a,c){return this.each(function(){if(!c)if(!a||b.filter(a,[this]).length)b("*",this).add([this]).each(function(){b(this).triggerHandler("remove")});return l.call(b(this),a,c)})}}b.widget=function(a,c,d){var e=a.split(".")[0],f;a=a.split(".")[1];f=e+"-"+a;if(!d){d=c;c=b.Widget}b.expr[":"][f]=function(h){return!!b.data(h,
28
+ a)};b[e]=b[e]||{};b[e][a]=function(h,g){arguments.length&&this._createWidget(h,g)};c=new c;c.options=b.extend(true,{},c.options);b[e][a].prototype=b.extend(true,c,{namespace:e,widgetName:a,widgetEventPrefix:b[e][a].prototype.widgetEventPrefix||a,widgetBaseClass:f},d);b.widget.bridge(a,b[e][a])};b.widget.bridge=function(a,c){b.fn[a]=function(d){var e=typeof d==="string",f=Array.prototype.slice.call(arguments,1),h=this;d=!e&&f.length?b.extend.apply(null,[true,d].concat(f)):d;if(e&&d.charAt(0)==="_")return h;
29
+ e?this.each(function(){var g=b.data(this,a),i=g&&b.isFunction(g[d])?g[d].apply(g,f):g;if(i!==g&&i!==j){h=i;return false}}):this.each(function(){var g=b.data(this,a);g?g.option(d||{})._init():b.data(this,a,new c(d,this))});return h}};b.Widget=function(a,c){arguments.length&&this._createWidget(a,c)};b.Widget.prototype={widgetName:"widget",widgetEventPrefix:"",options:{disabled:false},_createWidget:function(a,c){b.data(c,this.widgetName,this);this.element=b(c);this.options=b.extend(true,{},this.options,
30
+ this._getCreateOptions(),a);var d=this;this.element.bind("remove."+this.widgetName,function(){d.destroy()});this._create();this._trigger("create");this._init()},_getCreateOptions:function(){return b.metadata&&b.metadata.get(this.element[0])[this.widgetName]},_create:function(){},_init:function(){},destroy:function(){this.element.unbind("."+this.widgetName).removeData(this.widgetName);this.widget().unbind("."+this.widgetName).removeAttr("aria-disabled").removeClass(this.widgetBaseClass+"-disabled ui-state-disabled")},
31
+ widget:function(){return this.element},option:function(a,c){var d=a;if(arguments.length===0)return b.extend({},this.options);if(typeof a==="string"){if(c===j)return this.options[a];d={};d[a]=c}this._setOptions(d);return this},_setOptions:function(a){var c=this;b.each(a,function(d,e){c._setOption(d,e)});return this},_setOption:function(a,c){this.options[a]=c;if(a==="disabled")this.widget()[c?"addClass":"removeClass"](this.widgetBaseClass+"-disabled ui-state-disabled").attr("aria-disabled",c);return this},
32
+ enable:function(){return this._setOption("disabled",false)},disable:function(){return this._setOption("disabled",true)},_trigger:function(a,c,d){var e=this.options[a];c=b.Event(c);c.type=(a===this.widgetEventPrefix?a:this.widgetEventPrefix+a).toLowerCase();d=d||{};if(c.originalEvent){a=b.event.props.length;for(var f;a;){f=b.event.props[--a];c[f]=c.originalEvent[f]}}this.element.trigger(c,d);return!(b.isFunction(e)&&e.call(this.element[0],c,d)===false||c.isDefaultPrevented())}}})(jQuery);
33
+ ;/*!
34
+ * jQuery UI Mouse 1.8.9
35
+ *
36
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
37
+ * Dual licensed under the MIT or GPL Version 2 licenses.
38
+ * http://jquery.org/license
39
+ *
40
+ * http://docs.jquery.com/UI/Mouse
41
+ *
42
+ * Depends:
43
+ * jquery.ui.widget.js
44
+ */
45
+ (function(c){c.widget("ui.mouse",{options:{cancel:":input,option",distance:1,delay:0},_mouseInit:function(){var a=this;this.element.bind("mousedown."+this.widgetName,function(b){return a._mouseDown(b)}).bind("click."+this.widgetName,function(b){if(true===c.data(b.target,a.widgetName+".preventClickEvent")){c.removeData(b.target,a.widgetName+".preventClickEvent");b.stopImmediatePropagation();return false}});this.started=false},_mouseDestroy:function(){this.element.unbind("."+this.widgetName)},_mouseDown:function(a){a.originalEvent=
46
+ a.originalEvent||{};if(!a.originalEvent.mouseHandled){this._mouseStarted&&this._mouseUp(a);this._mouseDownEvent=a;var b=this,e=a.which==1,f=typeof this.options.cancel=="string"?c(a.target).parents().add(a.target).filter(this.options.cancel).length:false;if(!e||f||!this._mouseCapture(a))return true;this.mouseDelayMet=!this.options.delay;if(!this.mouseDelayMet)this._mouseDelayTimer=setTimeout(function(){b.mouseDelayMet=true},this.options.delay);if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a)){this._mouseStarted=
47
+ this._mouseStart(a)!==false;if(!this._mouseStarted){a.preventDefault();return true}}this._mouseMoveDelegate=function(d){return b._mouseMove(d)};this._mouseUpDelegate=function(d){return b._mouseUp(d)};c(document).bind("mousemove."+this.widgetName,this._mouseMoveDelegate).bind("mouseup."+this.widgetName,this._mouseUpDelegate);a.preventDefault();return a.originalEvent.mouseHandled=true}},_mouseMove:function(a){if(c.browser.msie&&!(document.documentMode>=9)&&!a.button)return this._mouseUp(a);if(this._mouseStarted){this._mouseDrag(a);
48
+ return a.preventDefault()}if(this._mouseDistanceMet(a)&&this._mouseDelayMet(a))(this._mouseStarted=this._mouseStart(this._mouseDownEvent,a)!==false)?this._mouseDrag(a):this._mouseUp(a);return!this._mouseStarted},_mouseUp:function(a){c(document).unbind("mousemove."+this.widgetName,this._mouseMoveDelegate).unbind("mouseup."+this.widgetName,this._mouseUpDelegate);if(this._mouseStarted){this._mouseStarted=false;a.target==this._mouseDownEvent.target&&c.data(a.target,this.widgetName+".preventClickEvent",
49
+ true);this._mouseStop(a)}return false},_mouseDistanceMet:function(a){return Math.max(Math.abs(this._mouseDownEvent.pageX-a.pageX),Math.abs(this._mouseDownEvent.pageY-a.pageY))>=this.options.distance},_mouseDelayMet:function(){return this.mouseDelayMet},_mouseStart:function(){},_mouseDrag:function(){},_mouseStop:function(){},_mouseCapture:function(){return true}})})(jQuery);
50
+ ;/*
51
+ * jQuery UI Position 1.8.9
52
+ *
53
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
54
+ * Dual licensed under the MIT or GPL Version 2 licenses.
55
+ * http://jquery.org/license
56
+ *
57
+ * http://docs.jquery.com/UI/Position
58
+ */
59
+ (function(c){c.ui=c.ui||{};var n=/left|center|right/,o=/top|center|bottom/,t=c.fn.position,u=c.fn.offset;c.fn.position=function(b){if(!b||!b.of)return t.apply(this,arguments);b=c.extend({},b);var a=c(b.of),d=a[0],g=(b.collision||"flip").split(" "),e=b.offset?b.offset.split(" "):[0,0],h,k,j;if(d.nodeType===9){h=a.width();k=a.height();j={top:0,left:0}}else if(d.setTimeout){h=a.width();k=a.height();j={top:a.scrollTop(),left:a.scrollLeft()}}else if(d.preventDefault){b.at="left top";h=k=0;j={top:b.of.pageY,
60
+ left:b.of.pageX}}else{h=a.outerWidth();k=a.outerHeight();j=a.offset()}c.each(["my","at"],function(){var f=(b[this]||"").split(" ");if(f.length===1)f=n.test(f[0])?f.concat(["center"]):o.test(f[0])?["center"].concat(f):["center","center"];f[0]=n.test(f[0])?f[0]:"center";f[1]=o.test(f[1])?f[1]:"center";b[this]=f});if(g.length===1)g[1]=g[0];e[0]=parseInt(e[0],10)||0;if(e.length===1)e[1]=e[0];e[1]=parseInt(e[1],10)||0;if(b.at[0]==="right")j.left+=h;else if(b.at[0]==="center")j.left+=h/2;if(b.at[1]==="bottom")j.top+=
61
+ k;else if(b.at[1]==="center")j.top+=k/2;j.left+=e[0];j.top+=e[1];return this.each(function(){var f=c(this),l=f.outerWidth(),m=f.outerHeight(),p=parseInt(c.curCSS(this,"marginLeft",true))||0,q=parseInt(c.curCSS(this,"marginTop",true))||0,v=l+p+(parseInt(c.curCSS(this,"marginRight",true))||0),w=m+q+(parseInt(c.curCSS(this,"marginBottom",true))||0),i=c.extend({},j),r;if(b.my[0]==="right")i.left-=l;else if(b.my[0]==="center")i.left-=l/2;if(b.my[1]==="bottom")i.top-=m;else if(b.my[1]==="center")i.top-=
62
+ m/2;i.left=Math.round(i.left);i.top=Math.round(i.top);r={left:i.left-p,top:i.top-q};c.each(["left","top"],function(s,x){c.ui.position[g[s]]&&c.ui.position[g[s]][x](i,{targetWidth:h,targetHeight:k,elemWidth:l,elemHeight:m,collisionPosition:r,collisionWidth:v,collisionHeight:w,offset:e,my:b.my,at:b.at})});c.fn.bgiframe&&f.bgiframe();f.offset(c.extend(i,{using:b.using}))})};c.ui.position={fit:{left:function(b,a){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();b.left=
63
+ d>0?b.left-d:Math.max(b.left-a.collisionPosition.left,b.left)},top:function(b,a){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();b.top=d>0?b.top-d:Math.max(b.top-a.collisionPosition.top,b.top)}},flip:{left:function(b,a){if(a.at[0]!=="center"){var d=c(window);d=a.collisionPosition.left+a.collisionWidth-d.width()-d.scrollLeft();var g=a.my[0]==="left"?-a.elemWidth:a.my[0]==="right"?a.elemWidth:0,e=a.at[0]==="left"?a.targetWidth:-a.targetWidth,h=-2*a.offset[0];b.left+=
64
+ a.collisionPosition.left<0?g+e+h:d>0?g+e+h:0}},top:function(b,a){if(a.at[1]!=="center"){var d=c(window);d=a.collisionPosition.top+a.collisionHeight-d.height()-d.scrollTop();var g=a.my[1]==="top"?-a.elemHeight:a.my[1]==="bottom"?a.elemHeight:0,e=a.at[1]==="top"?a.targetHeight:-a.targetHeight,h=-2*a.offset[1];b.top+=a.collisionPosition.top<0?g+e+h:d>0?g+e+h:0}}}};if(!c.offset.setOffset){c.offset.setOffset=function(b,a){if(/static/.test(c.curCSS(b,"position")))b.style.position="relative";var d=c(b),
65
+ g=d.offset(),e=parseInt(c.curCSS(b,"top",true),10)||0,h=parseInt(c.curCSS(b,"left",true),10)||0;g={top:a.top-g.top+e,left:a.left-g.left+h};"using"in a?a.using.call(b,g):d.css(g)};c.fn.offset=function(b){var a=this[0];if(!a||!a.ownerDocument)return null;if(b)return this.each(function(){c.offset.setOffset(this,b)});return u.call(this)}}})(jQuery);
66
+ ;/*
67
+ * jQuery UI Draggable 1.8.9
68
+ *
69
+ * Copyright 2011, AUTHORS.txt (http://jqueryui.com/about)
70
+ * Dual licensed under the MIT or GPL Version 2 licenses.
71
+ * http://jquery.org/license
72
+ *
73
+ * http://docs.jquery.com/UI/Draggables
74
+ *
75
+ * Depends:
76
+ * jquery.ui.core.js
77
+ * jquery.ui.mouse.js
78
+ * jquery.ui.widget.js
79
+ */
80
+ (function(d){d.widget("ui.draggable",d.ui.mouse,{widgetEventPrefix:"drag",options:{addClasses:true,appendTo:"parent",axis:false,connectToSortable:false,containment:false,cursor:"auto",cursorAt:false,grid:false,handle:false,helper:"original",iframeFix:false,opacity:false,refreshPositions:false,revert:false,revertDuration:500,scope:"default",scroll:true,scrollSensitivity:20,scrollSpeed:20,snap:false,snapMode:"both",snapTolerance:20,stack:false,zIndex:false},_create:function(){if(this.options.helper==
81
+ "original"&&!/^(?:r|a|f)/.test(this.element.css("position")))this.element[0].style.position="relative";this.options.addClasses&&this.element.addClass("ui-draggable");this.options.disabled&&this.element.addClass("ui-draggable-disabled");this._mouseInit()},destroy:function(){if(this.element.data("draggable")){this.element.removeData("draggable").unbind(".draggable").removeClass("ui-draggable ui-draggable-dragging ui-draggable-disabled");this._mouseDestroy();return this}},_mouseCapture:function(a){var b=
82
+ this.options;if(this.helper||b.disabled||d(a.target).is(".ui-resizable-handle"))return false;this.handle=this._getHandle(a);if(!this.handle)return false;return true},_mouseStart:function(a){var b=this.options;this.helper=this._createHelper(a);this._cacheHelperProportions();if(d.ui.ddmanager)d.ui.ddmanager.current=this;this._cacheMargins();this.cssPosition=this.helper.css("position");this.scrollParent=this.helper.scrollParent();this.offset=this.positionAbs=this.element.offset();this.offset={top:this.offset.top-
83
+ this.margins.top,left:this.offset.left-this.margins.left};d.extend(this.offset,{click:{left:a.pageX-this.offset.left,top:a.pageY-this.offset.top},parent:this._getParentOffset(),relative:this._getRelativeOffset()});this.originalPosition=this.position=this._generatePosition(a);this.originalPageX=a.pageX;this.originalPageY=a.pageY;b.cursorAt&&this._adjustOffsetFromHelper(b.cursorAt);b.containment&&this._setContainment();if(this._trigger("start",a)===false){this._clear();return false}this._cacheHelperProportions();
84
+ d.ui.ddmanager&&!b.dropBehaviour&&d.ui.ddmanager.prepareOffsets(this,a);this.helper.addClass("ui-draggable-dragging");this._mouseDrag(a,true);return true},_mouseDrag:function(a,b){this.position=this._generatePosition(a);this.positionAbs=this._convertPositionTo("absolute");if(!b){b=this._uiHash();if(this._trigger("drag",a,b)===false){this._mouseUp({});return false}this.position=b.position}if(!this.options.axis||this.options.axis!="y")this.helper[0].style.left=this.position.left+"px";if(!this.options.axis||
85
+ this.options.axis!="x")this.helper[0].style.top=this.position.top+"px";d.ui.ddmanager&&d.ui.ddmanager.drag(this,a);return false},_mouseStop:function(a){var b=false;if(d.ui.ddmanager&&!this.options.dropBehaviour)b=d.ui.ddmanager.drop(this,a);if(this.dropped){b=this.dropped;this.dropped=false}if((!this.element[0]||!this.element[0].parentNode)&&this.options.helper=="original")return false;if(this.options.revert=="invalid"&&!b||this.options.revert=="valid"&&b||this.options.revert===true||d.isFunction(this.options.revert)&&
86
+ this.options.revert.call(this.element,b)){var c=this;d(this.helper).animate(this.originalPosition,parseInt(this.options.revertDuration,10),function(){c._trigger("stop",a)!==false&&c._clear()})}else this._trigger("stop",a)!==false&&this._clear();return false},cancel:function(){this.helper.is(".ui-draggable-dragging")?this._mouseUp({}):this._clear();return this},_getHandle:function(a){var b=!this.options.handle||!d(this.options.handle,this.element).length?true:false;d(this.options.handle,this.element).find("*").andSelf().each(function(){if(this==
87
+ a.target)b=true});return b},_createHelper:function(a){var b=this.options;a=d.isFunction(b.helper)?d(b.helper.apply(this.element[0],[a])):b.helper=="clone"?this.element.clone():this.element;a.parents("body").length||a.appendTo(b.appendTo=="parent"?this.element[0].parentNode:b.appendTo);a[0]!=this.element[0]&&!/(fixed|absolute)/.test(a.css("position"))&&a.css("position","absolute");return a},_adjustOffsetFromHelper:function(a){if(typeof a=="string")a=a.split(" ");if(d.isArray(a))a={left:+a[0],top:+a[1]||
88
+ 0};if("left"in a)this.offset.click.left=a.left+this.margins.left;if("right"in a)this.offset.click.left=this.helperProportions.width-a.right+this.margins.left;if("top"in a)this.offset.click.top=a.top+this.margins.top;if("bottom"in a)this.offset.click.top=this.helperProportions.height-a.bottom+this.margins.top},_getParentOffset:function(){this.offsetParent=this.helper.offsetParent();var a=this.offsetParent.offset();if(this.cssPosition=="absolute"&&this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],
89
+ this.offsetParent[0])){a.left+=this.scrollParent.scrollLeft();a.top+=this.scrollParent.scrollTop()}if(this.offsetParent[0]==document.body||this.offsetParent[0].tagName&&this.offsetParent[0].tagName.toLowerCase()=="html"&&d.browser.msie)a={top:0,left:0};return{top:a.top+(parseInt(this.offsetParent.css("borderTopWidth"),10)||0),left:a.left+(parseInt(this.offsetParent.css("borderLeftWidth"),10)||0)}},_getRelativeOffset:function(){if(this.cssPosition=="relative"){var a=this.element.position();return{top:a.top-
90
+ (parseInt(this.helper.css("top"),10)||0)+this.scrollParent.scrollTop(),left:a.left-(parseInt(this.helper.css("left"),10)||0)+this.scrollParent.scrollLeft()}}else return{top:0,left:0}},_cacheMargins:function(){this.margins={left:parseInt(this.element.css("marginLeft"),10)||0,top:parseInt(this.element.css("marginTop"),10)||0}},_cacheHelperProportions:function(){this.helperProportions={width:this.helper.outerWidth(),height:this.helper.outerHeight()}},_setContainment:function(){var a=this.options;if(a.containment==
91
+ "parent")a.containment=this.helper[0].parentNode;if(a.containment=="document"||a.containment=="window")this.containment=[(a.containment=="document"?0:d(window).scrollLeft())-this.offset.relative.left-this.offset.parent.left,(a.containment=="document"?0:d(window).scrollTop())-this.offset.relative.top-this.offset.parent.top,(a.containment=="document"?0:d(window).scrollLeft())+d(a.containment=="document"?document:window).width()-this.helperProportions.width-this.margins.left,(a.containment=="document"?
92
+ 0:d(window).scrollTop())+(d(a.containment=="document"?document:window).height()||document.body.parentNode.scrollHeight)-this.helperProportions.height-this.margins.top];if(!/^(document|window|parent)$/.test(a.containment)&&a.containment.constructor!=Array){var b=d(a.containment)[0];if(b){a=d(a.containment).offset();var c=d(b).css("overflow")!="hidden";this.containment=[a.left+(parseInt(d(b).css("borderLeftWidth"),10)||0)+(parseInt(d(b).css("paddingLeft"),10)||0)-this.margins.left,a.top+(parseInt(d(b).css("borderTopWidth"),
93
+ 10)||0)+(parseInt(d(b).css("paddingTop"),10)||0)-this.margins.top,a.left+(c?Math.max(b.scrollWidth,b.offsetWidth):b.offsetWidth)-(parseInt(d(b).css("borderLeftWidth"),10)||0)-(parseInt(d(b).css("paddingRight"),10)||0)-this.helperProportions.width-this.margins.left,a.top+(c?Math.max(b.scrollHeight,b.offsetHeight):b.offsetHeight)-(parseInt(d(b).css("borderTopWidth"),10)||0)-(parseInt(d(b).css("paddingBottom"),10)||0)-this.helperProportions.height-this.margins.top]}}else if(a.containment.constructor==
94
+ Array)this.containment=a.containment},_convertPositionTo:function(a,b){if(!b)b=this.position;a=a=="absolute"?1:-1;var c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName);return{top:b.top+this.offset.relative.top*a+this.offset.parent.top*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollTop():
95
+ f?0:c.scrollTop())*a),left:b.left+this.offset.relative.left*a+this.offset.parent.left*a-(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:(this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())*a)}},_generatePosition:function(a){var b=this.options,c=this.cssPosition=="absolute"&&!(this.scrollParent[0]!=document&&d.ui.contains(this.scrollParent[0],this.offsetParent[0]))?this.offsetParent:this.scrollParent,f=/(html|body)/i.test(c[0].tagName),e=a.pageX,g=a.pageY;
96
+ if(this.originalPosition){if(this.containment){if(a.pageX-this.offset.click.left<this.containment[0])e=this.containment[0]+this.offset.click.left;if(a.pageY-this.offset.click.top<this.containment[1])g=this.containment[1]+this.offset.click.top;if(a.pageX-this.offset.click.left>this.containment[2])e=this.containment[2]+this.offset.click.left;if(a.pageY-this.offset.click.top>this.containment[3])g=this.containment[3]+this.offset.click.top}if(b.grid){g=this.originalPageY+Math.round((g-this.originalPageY)/
97
+ b.grid[1])*b.grid[1];g=this.containment?!(g-this.offset.click.top<this.containment[1]||g-this.offset.click.top>this.containment[3])?g:!(g-this.offset.click.top<this.containment[1])?g-b.grid[1]:g+b.grid[1]:g;e=this.originalPageX+Math.round((e-this.originalPageX)/b.grid[0])*b.grid[0];e=this.containment?!(e-this.offset.click.left<this.containment[0]||e-this.offset.click.left>this.containment[2])?e:!(e-this.offset.click.left<this.containment[0])?e-b.grid[0]:e+b.grid[0]:e}}return{top:g-this.offset.click.top-
98
+ this.offset.relative.top-this.offset.parent.top+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollTop():f?0:c.scrollTop()),left:e-this.offset.click.left-this.offset.relative.left-this.offset.parent.left+(d.browser.safari&&d.browser.version<526&&this.cssPosition=="fixed"?0:this.cssPosition=="fixed"?-this.scrollParent.scrollLeft():f?0:c.scrollLeft())}},_clear:function(){this.helper.removeClass("ui-draggable-dragging");this.helper[0]!=
99
+ this.element[0]&&!this.cancelHelperRemoval&&this.helper.remove();this.helper=null;this.cancelHelperRemoval=false},_trigger:function(a,b,c){c=c||this._uiHash();d.ui.plugin.call(this,a,[b,c]);if(a=="drag")this.positionAbs=this._convertPositionTo("absolute");return d.Widget.prototype._trigger.call(this,a,b,c)},plugins:{},_uiHash:function(){return{helper:this.helper,position:this.position,originalPosition:this.originalPosition,offset:this.positionAbs}}});d.extend(d.ui.draggable,{version:"1.8.9"});
100
+ d.ui.plugin.add("draggable","connectToSortable",{start:function(a,b){var c=d(this).data("draggable"),f=c.options,e=d.extend({},b,{item:c.element});c.sortables=[];d(f.connectToSortable).each(function(){var g=d.data(this,"sortable");if(g&&!g.options.disabled){c.sortables.push({instance:g,shouldRevert:g.options.revert});g._refreshItems();g._trigger("activate",a,e)}})},stop:function(a,b){var c=d(this).data("draggable"),f=d.extend({},b,{item:c.element});d.each(c.sortables,function(){if(this.instance.isOver){this.instance.isOver=
101
+ 0;c.cancelHelperRemoval=true;this.instance.cancelHelperRemoval=false;if(this.shouldRevert)this.instance.options.revert=true;this.instance._mouseStop(a);this.instance.options.helper=this.instance.options._helper;c.options.helper=="original"&&this.instance.currentItem.css({top:"auto",left:"auto"})}else{this.instance.cancelHelperRemoval=false;this.instance._trigger("deactivate",a,f)}})},drag:function(a,b){var c=d(this).data("draggable"),f=this;d.each(c.sortables,function(){this.instance.positionAbs=
102
+ c.positionAbs;this.instance.helperProportions=c.helperProportions;this.instance.offset.click=c.offset.click;if(this.instance._intersectsWith(this.instance.containerCache)){if(!this.instance.isOver){this.instance.isOver=1;this.instance.currentItem=d(f).clone().appendTo(this.instance.element).data("sortable-item",true);this.instance.options._helper=this.instance.options.helper;this.instance.options.helper=function(){return b.helper[0]};a.target=this.instance.currentItem[0];this.instance._mouseCapture(a,
103
+ true);this.instance._mouseStart(a,true,true);this.instance.offset.click.top=c.offset.click.top;this.instance.offset.click.left=c.offset.click.left;this.instance.offset.parent.left-=c.offset.parent.left-this.instance.offset.parent.left;this.instance.offset.parent.top-=c.offset.parent.top-this.instance.offset.parent.top;c._trigger("toSortable",a);c.dropped=this.instance.element;c.currentItem=c.element;this.instance.fromOutside=c}this.instance.currentItem&&this.instance._mouseDrag(a)}else if(this.instance.isOver){this.instance.isOver=
104
+ 0;this.instance.cancelHelperRemoval=true;this.instance.options.revert=false;this.instance._trigger("out",a,this.instance._uiHash(this.instance));this.instance._mouseStop(a,true);this.instance.options.helper=this.instance.options._helper;this.instance.currentItem.remove();this.instance.placeholder&&this.instance.placeholder.remove();c._trigger("fromSortable",a);c.dropped=false}})}});d.ui.plugin.add("draggable","cursor",{start:function(){var a=d("body"),b=d(this).data("draggable").options;if(a.css("cursor"))b._cursor=
105
+ a.css("cursor");a.css("cursor",b.cursor)},stop:function(){var a=d(this).data("draggable").options;a._cursor&&d("body").css("cursor",a._cursor)}});d.ui.plugin.add("draggable","iframeFix",{start:function(){var a=d(this).data("draggable").options;d(a.iframeFix===true?"iframe":a.iframeFix).each(function(){d('<div class="ui-draggable-iframeFix" style="background: #fff;"></div>').css({width:this.offsetWidth+"px",height:this.offsetHeight+"px",position:"absolute",opacity:"0.001",zIndex:1E3}).css(d(this).offset()).appendTo("body")})},
106
+ stop:function(){d("div.ui-draggable-iframeFix").each(function(){this.parentNode.removeChild(this)})}});d.ui.plugin.add("draggable","opacity",{start:function(a,b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("opacity"))b._opacity=a.css("opacity");a.css("opacity",b.opacity)},stop:function(a,b){a=d(this).data("draggable").options;a._opacity&&d(b.helper).css("opacity",a._opacity)}});d.ui.plugin.add("draggable","scroll",{start:function(){var a=d(this).data("draggable");if(a.scrollParent[0]!=
107
+ document&&a.scrollParent[0].tagName!="HTML")a.overflowOffset=a.scrollParent.offset()},drag:function(a){var b=d(this).data("draggable"),c=b.options,f=false;if(b.scrollParent[0]!=document&&b.scrollParent[0].tagName!="HTML"){if(!c.axis||c.axis!="x")if(b.overflowOffset.top+b.scrollParent[0].offsetHeight-a.pageY<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop+c.scrollSpeed;else if(a.pageY-b.overflowOffset.top<c.scrollSensitivity)b.scrollParent[0].scrollTop=f=b.scrollParent[0].scrollTop-
108
+ c.scrollSpeed;if(!c.axis||c.axis!="y")if(b.overflowOffset.left+b.scrollParent[0].offsetWidth-a.pageX<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft+c.scrollSpeed;else if(a.pageX-b.overflowOffset.left<c.scrollSensitivity)b.scrollParent[0].scrollLeft=f=b.scrollParent[0].scrollLeft-c.scrollSpeed}else{if(!c.axis||c.axis!="x")if(a.pageY-d(document).scrollTop()<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()-c.scrollSpeed);else if(d(window).height()-
109
+ (a.pageY-d(document).scrollTop())<c.scrollSensitivity)f=d(document).scrollTop(d(document).scrollTop()+c.scrollSpeed);if(!c.axis||c.axis!="y")if(a.pageX-d(document).scrollLeft()<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()-c.scrollSpeed);else if(d(window).width()-(a.pageX-d(document).scrollLeft())<c.scrollSensitivity)f=d(document).scrollLeft(d(document).scrollLeft()+c.scrollSpeed)}f!==false&&d.ui.ddmanager&&!c.dropBehaviour&&d.ui.ddmanager.prepareOffsets(b,a)}});d.ui.plugin.add("draggable",
110
+ "snap",{start:function(){var a=d(this).data("draggable"),b=a.options;a.snapElements=[];d(b.snap.constructor!=String?b.snap.items||":data(draggable)":b.snap).each(function(){var c=d(this),f=c.offset();this!=a.element[0]&&a.snapElements.push({item:this,width:c.outerWidth(),height:c.outerHeight(),top:f.top,left:f.left})})},drag:function(a,b){for(var c=d(this).data("draggable"),f=c.options,e=f.snapTolerance,g=b.offset.left,n=g+c.helperProportions.width,m=b.offset.top,o=m+c.helperProportions.height,h=
111
+ c.snapElements.length-1;h>=0;h--){var i=c.snapElements[h].left,k=i+c.snapElements[h].width,j=c.snapElements[h].top,l=j+c.snapElements[h].height;if(i-e<g&&g<k+e&&j-e<m&&m<l+e||i-e<g&&g<k+e&&j-e<o&&o<l+e||i-e<n&&n<k+e&&j-e<m&&m<l+e||i-e<n&&n<k+e&&j-e<o&&o<l+e){if(f.snapMode!="inner"){var p=Math.abs(j-o)<=e,q=Math.abs(l-m)<=e,r=Math.abs(i-n)<=e,s=Math.abs(k-g)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:j-c.helperProportions.height,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",
112
+ {top:l,left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:i-c.helperProportions.width}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:k}).left-c.margins.left}var t=p||q||r||s;if(f.snapMode!="outer"){p=Math.abs(j-m)<=e;q=Math.abs(l-o)<=e;r=Math.abs(i-g)<=e;s=Math.abs(k-n)<=e;if(p)b.position.top=c._convertPositionTo("relative",{top:j,left:0}).top-c.margins.top;if(q)b.position.top=c._convertPositionTo("relative",{top:l-c.helperProportions.height,
113
+ left:0}).top-c.margins.top;if(r)b.position.left=c._convertPositionTo("relative",{top:0,left:i}).left-c.margins.left;if(s)b.position.left=c._convertPositionTo("relative",{top:0,left:k-c.helperProportions.width}).left-c.margins.left}if(!c.snapElements[h].snapping&&(p||q||r||s||t))c.options.snap.snap&&c.options.snap.snap.call(c.element,a,d.extend(c._uiHash(),{snapItem:c.snapElements[h].item}));c.snapElements[h].snapping=p||q||r||s||t}else{c.snapElements[h].snapping&&c.options.snap.release&&c.options.snap.release.call(c.element,
114
+ a,d.extend(c._uiHash(),{snapItem:c.snapElements[h].item}));c.snapElements[h].snapping=false}}}});d.ui.plugin.add("draggable","stack",{start:function(){var a=d(this).data("draggable").options;a=d.makeArray(d(a.stack)).sort(function(c,f){return(parseInt(d(c).css("zIndex"),10)||0)-(parseInt(d(f).css("zIndex"),10)||0)});if(a.length){var b=parseInt(a[0].style.zIndex)||0;d(a).each(function(c){this.style.zIndex=b+c});this[0].style.zIndex=b+a.length}}});d.ui.plugin.add("draggable","zIndex",{start:function(a,
115
+ b){a=d(b.helper);b=d(this).data("draggable").options;if(a.css("zIndex"))b._zIndex=a.css("zIndex");a.css("zIndex",b.zIndex)},stop:function(a,b){a=d(this).data("draggable").options;a._zIndex&&d(b.helper).css("zIndex",a._zIndex)}})})(jQuery);
116
+ ;
@@ -0,0 +1,223 @@
1
+ /**
2
+ * jQuery.UI.iPad plugin
3
+ * Copyright (c) 2010 Stephen von Takach
4
+ * licensed under MIT.
5
+ * Date: 27/8/2010
6
+ *
7
+ * Project Home:
8
+ * http://code.google.com/p/jquery-ui-for-ipad-and-iphone/
9
+ */
10
+
11
+
12
+ $(function() {
13
+ //
14
+ // Extend jQuery feature detection
15
+ //
16
+ $.extend($.support, {
17
+ touch: "ontouchend" in document
18
+ });
19
+
20
+ //
21
+ // Hook up touch events
22
+ //
23
+ if ($.support.touch) {
24
+ document.addEventListener("touchstart", iPadTouchHandler, false);
25
+ document.addEventListener("touchmove", iPadTouchHandler, false);
26
+ document.addEventListener("touchend", iPadTouchHandler, false);
27
+ document.addEventListener("touchcancel", iPadTouchHandler, false);
28
+ }
29
+ });
30
+
31
+
32
+ var lastTap = null; // Holds last tapped element (so we can compare for double tap)
33
+ var tapValid = false; // Are we still in the .6 second window where a double tap can occur
34
+ var tapTimeout = null; // The timeout reference
35
+
36
+ function cancelTap() {
37
+ tapValid = false;
38
+ }
39
+
40
+
41
+ var rightClickPending = false; // Is a right click still feasible
42
+ var rightClickEvent = null; // the original event
43
+ var holdTimeout = null; // timeout reference
44
+ var cancelMouseUp = false; // prevents a click from occuring as we want the context menu
45
+
46
+
47
+ function cancelHold() {
48
+ if (rightClickPending) {
49
+ window.clearTimeout(holdTimeout);
50
+ rightClickPending = false;
51
+ rightClickEvent = null;
52
+ }
53
+ }
54
+
55
+ function startHold(event) {
56
+ if (rightClickPending)
57
+ return;
58
+
59
+ rightClickPending = true; // We could be performing a right click
60
+ rightClickEvent = (event.changedTouches)[0];
61
+ holdTimeout = window.setTimeout("doRightClick();", 800);
62
+ }
63
+
64
+
65
+ function doRightClick() {
66
+ rightClickPending = false;
67
+
68
+ //
69
+ // We need to mouse up (as we were down)
70
+ //
71
+ var first = rightClickEvent,
72
+ simulatedEvent = document.createEvent("MouseEvent");
73
+ simulatedEvent.initMouseEvent("mouseup", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
74
+ false, false, false, false, 0, null);
75
+ first.target.dispatchEvent(simulatedEvent);
76
+
77
+ //
78
+ // emulate a right click
79
+ //
80
+ simulatedEvent = document.createEvent("MouseEvent");
81
+ simulatedEvent.initMouseEvent("mousedown", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
82
+ false, false, false, false, 2, null);
83
+ first.target.dispatchEvent(simulatedEvent);
84
+
85
+ //
86
+ // Show a context menu
87
+ //
88
+ simulatedEvent = document.createEvent("MouseEvent");
89
+ simulatedEvent.initMouseEvent("contextmenu", true, true, window, 1, first.screenX + 50, first.screenY + 5, first.clientX + 50, first.clientY + 5,
90
+ false, false, false, false, 2, null);
91
+ first.target.dispatchEvent(simulatedEvent);
92
+
93
+
94
+ //
95
+ // Note:: I don't mouse up the right click here however feel free to add if required
96
+ //
97
+
98
+
99
+ cancelMouseUp = true;
100
+ rightClickEvent = null; // Release memory
101
+ }
102
+
103
+
104
+ //
105
+ // mouse over event then mouse down
106
+ //
107
+ function iPadTouchStart(event) {
108
+ var touches = event.changedTouches,
109
+ first = touches[0],
110
+ type = "mouseover",
111
+ simulatedEvent = document.createEvent("MouseEvent");
112
+ //
113
+ // Mouse over first - I have live events attached on mouse over
114
+ //
115
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
116
+ false, false, false, false, 0, null);
117
+ first.target.dispatchEvent(simulatedEvent);
118
+
119
+ type = "mousedown";
120
+ simulatedEvent = document.createEvent("MouseEvent");
121
+
122
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
123
+ false, false, false, false, 0, null);
124
+ first.target.dispatchEvent(simulatedEvent);
125
+
126
+
127
+ if (!tapValid) {
128
+ lastTap = first.target;
129
+ tapValid = true;
130
+ tapTimeout = window.setTimeout("cancelTap();", 600);
131
+ startHold(event);
132
+ }
133
+ else {
134
+ window.clearTimeout(tapTimeout);
135
+
136
+ //
137
+ // If a double tap is still a possibility and the elements are the same
138
+ // Then perform a double click
139
+ //
140
+ if (first.target == lastTap) {
141
+ lastTap = null;
142
+ tapValid = false;
143
+
144
+ type = "click";
145
+ simulatedEvent = document.createEvent("MouseEvent");
146
+
147
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
148
+ false, false, false, false, 0/*left*/, null);
149
+ first.target.dispatchEvent(simulatedEvent);
150
+
151
+ type = "dblclick";
152
+ simulatedEvent = document.createEvent("MouseEvent");
153
+
154
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
155
+ false, false, false, false, 0/*left*/, null);
156
+ first.target.dispatchEvent(simulatedEvent);
157
+ }
158
+ else {
159
+ lastTap = first.target;
160
+ tapValid = true;
161
+ tapTimeout = window.setTimeout("cancelTap();", 600);
162
+ startHold(event);
163
+ }
164
+ }
165
+ }
166
+
167
+ function iPadTouchHandler(event) {
168
+ var type = "",
169
+ button = 0; /*left*/
170
+
171
+ if (event.touches.length > 1)
172
+ return;
173
+
174
+ switch (event.type) {
175
+ case "touchstart":
176
+ if ($(event.changedTouches[0].target).is("select")) {
177
+ return;
178
+ }
179
+ iPadTouchStart(event); /*We need to trigger two events here to support one touch drag and drop*/
180
+ event.preventDefault();
181
+ return false;
182
+ break;
183
+
184
+ case "touchmove":
185
+ cancelHold();
186
+ type = "mousemove";
187
+ event.preventDefault();
188
+ break;
189
+
190
+ case "touchend":
191
+ if (cancelMouseUp) {
192
+ cancelMouseUp = false;
193
+ event.preventDefault();
194
+ return false;
195
+ }
196
+ cancelHold();
197
+ type = "mouseup";
198
+ break;
199
+
200
+ default:
201
+ return;
202
+ }
203
+
204
+ var touches = event.changedTouches,
205
+ first = touches[0],
206
+ simulatedEvent = document.createEvent("MouseEvent");
207
+
208
+ simulatedEvent.initMouseEvent(type, true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
209
+ false, false, false, false, button, null);
210
+
211
+ first.target.dispatchEvent(simulatedEvent);
212
+
213
+ if (type == "mouseup" && tapValid && first.target == lastTap) { // This actually emulates the ipads default behaviour (which we prevented)
214
+ simulatedEvent = document.createEvent("MouseEvent"); // This check avoids click being emulated on a double tap
215
+
216
+ simulatedEvent.initMouseEvent("click", true, true, window, 1, first.screenX, first.screenY, first.clientX, first.clientY,
217
+ false, false, false, false, button, null);
218
+
219
+ first.target.dispatchEvent(simulatedEvent);
220
+ }
221
+ }
222
+
223
+
@@ -0,0 +1,105 @@
1
+ /*****************/
2
+ /** QapTcha CSS **/
3
+ /*****************/
4
+ /* when QapTcha is id attr*/
5
+
6
+ #QapTcha {
7
+ padding:10px;
8
+ border:1px solid #F4F4F4;
9
+ background:url('../image/qaptcha/bg_QapTcha.png') repeat;
10
+ margin-top:10px;
11
+ }
12
+ #QapTcha .clr{clear:both}
13
+
14
+ #QapTcha #bgSlider {
15
+ width:202px;
16
+ height:22px;
17
+ background:transparent url('../image/qaptcha/sprites.png') no-repeat 0 -22px;
18
+ float:left
19
+ }
20
+
21
+ #QapTcha #Slider {
22
+ width:48px;
23
+ height:22px;
24
+ background:transparent url('../image/qaptcha/sprites.png') no-repeat -32px 0;
25
+ cursor:e-resize
26
+ }
27
+
28
+ #QapTcha #Icons {
29
+ float:left;
30
+ width:16px;
31
+ height:16px;
32
+ background:transparent url('../image/qaptcha/sprites.png') no-repeat 0 0;
33
+ margin-top:3px;
34
+ margin-left:10px;
35
+ }
36
+
37
+ #QapTcha #TxtStatus {
38
+ width:202px;
39
+ margin-top:7px;
40
+ text-align:center;
41
+ font-family:Verdana;
42
+ font-size:10px;
43
+ clear:both
44
+ }
45
+
46
+ /** States **/
47
+ #QapTcha .dropSuccess {
48
+ color:#568E2F
49
+ }
50
+ #QapTcha .dropError {
51
+ color:#bb2828
52
+ }
53
+
54
+ /*****************/
55
+ /** QapTcha CSS **/
56
+ /*****************/
57
+ /* when QapTcha is class attr*/
58
+
59
+ .QapTcha {
60
+ padding:10px;
61
+ border:1px solid #F4F4F4;
62
+ background:url('../image/qaptcha/bg_QapTcha.png') repeat;
63
+ margin-top:10px;
64
+ }
65
+ .QapTcha .clr{clear:both}
66
+
67
+ .QapTcha #bgSlider {
68
+ width:202px;
69
+ height:22px;
70
+ background:transparent url('../image/qaptcha/sprites.png') no-repeat 0 -22px;
71
+ float:left
72
+ }
73
+
74
+ .QapTcha #Slider {
75
+ width:48px;
76
+ height:22px;
77
+ background:transparent url('../image/qaptcha/sprites.png') no-repeat -32px 0;
78
+ cursor:e-resize
79
+ }
80
+
81
+ .QapTcha #Icons {
82
+ float:left;
83
+ width:16px;
84
+ height:16px;
85
+ background:transparent url('../image/qaptcha/sprites.png') no-repeat 0 0;
86
+ margin-top:3px;
87
+ margin-left:10px;
88
+ }
89
+
90
+ .QapTcha #TxtStatus {
91
+ width:202px;
92
+ margin-top:7px;
93
+ text-align:center;
94
+ font-family:Verdana;
95
+ font-size:10px;
96
+ clear:both
97
+ }
98
+
99
+ /** States **/
100
+ .QapTcha .dropSuccess {
101
+ color:#568E2F
102
+ }
103
+ .QapTcha .dropError {
104
+ color:#bb2828
105
+ }
@@ -0,0 +1,7 @@
1
+ require 'rails'
2
+ require "rails_qaptcha/version"
3
+ require "rails_qaptcha/engine"
4
+
5
+ module RailsQaptcha
6
+ # Your code goes here...
7
+ end
@@ -0,0 +1,16 @@
1
+ require 'rails'
2
+
3
+ module RailsQaptcha
4
+ class Engine < Rails::Engine
5
+
6
+ # =====================================
7
+ # = = javascript_include_tag :qaptcha =
8
+ # = = stylesheet_link_tag :qaptcha =
9
+ # =====================================
10
+ config.before_initialize do
11
+ config.action_view.javascript_expansions[:qaptcha] = %w(qaptcha/jquery-ui.js qaptcha/jquery.ui.touch.js qaptcha/QapTcha.jquery.js)
12
+ config.action_view.stylesheet_expansions[:qaptcha] = %w(qaptcha/QapTcha.jquery.css)
13
+ end
14
+
15
+ end
16
+ end
@@ -0,0 +1,3 @@
1
+ module RailsQaptcha
2
+ VERSION = "0.0.2"
3
+ end
File without changes
metadata ADDED
@@ -0,0 +1,128 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails_qaptcha
3
+ version: !ruby/object:Gem::Version
4
+ hash: 27
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 2
10
+ version: 0.0.2
11
+ platform: ruby
12
+ authors:
13
+ - AlexZhang
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2011-06-27 00:00:00 +08:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rails
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - "="
28
+ - !ruby/object:Gem::Version
29
+ hash: 23
30
+ segments:
31
+ - 3
32
+ - 0
33
+ - 8
34
+ version: 3.0.8
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ - !ruby/object:Gem::Dependency
38
+ name: rspec
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ hash: 3
46
+ segments:
47
+ - 0
48
+ version: "0"
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: rspec-rails
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 3
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ type: :development
64
+ version_requirements: *id003
65
+ description: jQuery captcha system with jQuery & jQuery UI for Rails 3
66
+ email:
67
+ - blackanger.z@gmail.com
68
+ executables: []
69
+
70
+ extensions: []
71
+
72
+ extra_rdoc_files:
73
+ - Gemfile.lock
74
+ - README.markdown
75
+ files:
76
+ - Gemfile
77
+ - Gemfile.lock
78
+ - Rakefile
79
+ - README.markdown
80
+ - app/controllers/qaptchas_controller.rb
81
+ - config/routes.rb
82
+ - lib/generators/rails_qaptcha/install_generator.rb
83
+ - lib/generators/rails_qaptcha/media/images/bg_QapTcha.png
84
+ - lib/generators/rails_qaptcha/media/images/sprites.png
85
+ - lib/generators/rails_qaptcha/media/javascripts/jquery-ui.js
86
+ - lib/generators/rails_qaptcha/media/javascripts/jquery.ui.touch.js
87
+ - lib/generators/rails_qaptcha/media/javascripts/QapTcha.jquery.js
88
+ - lib/generators/rails_qaptcha/media/stylesheets/QapTcha.jquery.css
89
+ - lib/rails_qaptcha/engine.rb
90
+ - lib/rails_qaptcha/version.rb
91
+ - lib/rails_qaptcha.rb
92
+ - spec/spec_helper.rb
93
+ has_rdoc: true
94
+ homepage: ""
95
+ licenses: []
96
+
97
+ post_install_message:
98
+ rdoc_options: []
99
+
100
+ require_paths:
101
+ - lib
102
+ required_ruby_version: !ruby/object:Gem::Requirement
103
+ none: false
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ none: false
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
120
+ requirements: []
121
+
122
+ rubyforge_project: rails_qaptcha
123
+ rubygems_version: 1.6.2
124
+ signing_key:
125
+ specification_version: 3
126
+ summary: A captcha system with jQuery & jQuery UI for Rails 3
127
+ test_files:
128
+ - spec/spec_helper.rb