jquery-caret-rails 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Changok Kim
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,24 @@
1
+ # Jquery::Caret::Rails
2
+
3
+ ### Installation
4
+
5
+ Add it to your `Gemfile`:
6
+ ```
7
+ gem 'jquery-caret-rails', '~> 1.0.0'
8
+ ```
9
+
10
+ ### Usage
11
+
12
+ You can add jquery-caret-rails to your `application.js` file using a require statement like this:
13
+
14
+ ```
15
+ //= require jquery-caret
16
+ ```
17
+
18
+ ### License
19
+
20
+ Licensed under the MIT license.
21
+
22
+ ### Authors
23
+ 1. This gme: Changok Kim [@okidokim](http://twitter.com/okidokim)
24
+ 2. jquery-caret: Luke Morton, it's [on github](https://github.com/DrPheltRight/jquery-caret)
@@ -0,0 +1,10 @@
1
+ require "jquery-caret-rails/version"
2
+
3
+ module Jquery
4
+ module Caret
5
+ module Rails
6
+ class Engine < ::Rails::Engine
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,7 @@
1
+ module Jquery
2
+ module Caret
3
+ module Rails
4
+ VERSION = "1.0.0"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,79 @@
1
+ // Set caret position easily in jQuery
2
+ // Written by and Copyright of Luke Morton, 2011
3
+ // Licensed under MIT
4
+ (function ($) {
5
+ // Behind the scenes method deals with browser
6
+ // idiosyncrasies and such
7
+ $.caretTo = function (el, index) {
8
+ if (el.createTextRange) {
9
+ var range = el.createTextRange();
10
+ range.move("character", index);
11
+ range.select();
12
+ } else if (el.selectionStart != null) {
13
+ el.focus();
14
+ el.setSelectionRange(index, index);
15
+ }
16
+ };
17
+
18
+ // Another behind the scenes that collects the
19
+ // current caret position for an element
20
+
21
+ // TODO: Get working with Opera
22
+ $.caretPos = function (el) {
23
+ if ("selection" in document) {
24
+ var range = el.createTextRange();
25
+ try {
26
+ range.setEndPoint("EndToStart", document.selection.createRange());
27
+ } catch (e) {
28
+ // Catch IE failure here, return 0 like
29
+ // other browsers
30
+ return 0;
31
+ }
32
+ return range.text.length;
33
+ } else if (el.selectionStart != null) {
34
+ return el.selectionStart;
35
+ }
36
+ };
37
+
38
+ // The following methods are queued under fx for more
39
+ // flexibility when combining with $.fn.delay() and
40
+ // jQuery effects.
41
+
42
+ // Set caret to a particular index
43
+ $.fn.caret = function (index, offset) {
44
+ if (typeof(index) === "undefined") {
45
+ return $.caretPos(this.get(0));
46
+ }
47
+
48
+ return this.queue(function (next) {
49
+ if (isNaN(index)) {
50
+ var i = $(this).val().indexOf(index);
51
+
52
+ if (offset === true) {
53
+ i += index.length;
54
+ } else if (typeof(offset) !== "undefined") {
55
+ i += offset;
56
+ }
57
+
58
+ $.caretTo(this, i);
59
+ } else {
60
+ $.caretTo(this, index);
61
+ }
62
+
63
+ next();
64
+ });
65
+ };
66
+
67
+ // Set caret to beginning of an element
68
+ $.fn.caretToStart = function () {
69
+ return this.caret(0);
70
+ };
71
+
72
+ // Set caret to the end of an element
73
+ $.fn.caretToEnd = function () {
74
+ return this.queue(function (next) {
75
+ $.caretTo(this, $(this).val().length);
76
+ next();
77
+ });
78
+ };
79
+ }(jQuery));
metadata ADDED
@@ -0,0 +1,79 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jquery-caret-rails
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 1
7
+ - 0
8
+ - 0
9
+ version: 1.0.0
10
+ platform: ruby
11
+ authors:
12
+ - Changok Kim, Luke Morton
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2013-02-26 00:00:00 -08:00
18
+ default_executable:
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - ~>
24
+ - !ruby/object:Gem::Version
25
+ segments:
26
+ - 3
27
+ - 1
28
+ version: "3.1"
29
+ prerelease: false
30
+ name: railties
31
+ requirement: *id001
32
+ type: :runtime
33
+ description: jquery-caret for the Rails asset pipeline
34
+ email:
35
+ - changok.daniel.kim@gmail.com
36
+ executables: []
37
+
38
+ extensions: []
39
+
40
+ extra_rdoc_files: []
41
+
42
+ files:
43
+ - lib/jquery-caret-rails/version.rb
44
+ - lib/jquery-caret-rails.rb
45
+ - vendor/assets/javascripts/jquery.caret.js
46
+ - LICENSE.txt
47
+ - README.md
48
+ has_rdoc: true
49
+ homepage: https://github.com/changok/jquery-caret-rails
50
+ licenses: []
51
+
52
+ post_install_message:
53
+ rdoc_options: []
54
+
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ segments:
62
+ - 0
63
+ version: "0"
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ segments:
69
+ - 0
70
+ version: "0"
71
+ requirements: []
72
+
73
+ rubyforge_project:
74
+ rubygems_version: 1.3.6
75
+ signing_key:
76
+ specification_version: 3
77
+ summary: jquery-caret for the Rails asset pipeline
78
+ test_files: []
79
+