jquery-atwho-rails-1.3.2/0000755000076400007640000000000012546671734014337 5ustar pravipravijquery-atwho-rails-1.3.2/spec/0000755000076400007640000000000012546671734015271 5ustar pravipravijquery-atwho-rails-1.3.2/spec/spec_helper.rb0000644000076400007640000000111012546671734020100 0ustar pravipravi# Set up generator tests require 'rails' require 'rails/all' require 'rails/generators' class TestApp < Rails::Application config.root = File.dirname(__FILE__) end Rails.application = TestApp module Rails def self.root @root ||= File.expand_path("../../tmp/", __FILE__) end end Rails.application.config.root = Rails.root # Call configure to load the settings from # Rails.application.config.generators to Rails::Generators #Rails::Generators.configure! #Rails.application.config.assets.enabled = true require "generator_spec" require 'generators/atwho/install_generator' jquery-atwho-rails-1.3.2/spec/generators/0000755000076400007640000000000012546671734017442 5ustar pravipravijquery-atwho-rails-1.3.2/spec/generators/install_generator_spec.rb0000644000076400007640000000066412546671734024523 0ustar pravipravirequire 'spec_helper' describe Atwho::Generators::InstallGenerator do include GeneratorSpec::TestCase destination File.expand_path("../../../tmp/", __FILE__) before(:all) do prepare_destination run_generator end it "generate assets files" do if ::Rails.version < "3.1" assert_file "public/javascripts/jquery.atwho/jquery.atwho.js" assert_file "public/stylesheets/jquery.atwho.css" end end end jquery-atwho-rails-1.3.2/bower.json0000644000076400007640000000052512546671734016352 0ustar pravipravi{ "name": "jquery-atwho-rails", "version": "1.3.2", "homepage": "https://github.com/ichord/jquery-atwho-rails", "authors": [ "ichord " ], "license": "MIT", "ignore": [ "**/.*", "node_modules", "bower_components", "test", "tests" ], "dependencies": { "At.js": "~1.3.0" } } jquery-atwho-rails-1.3.2/LICENSE-MIT0000644000076400007640000000204712546671734015776 0ustar pravipraviCopyright (c) 2013 chord.luo@gmail.com Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. jquery-atwho-rails-1.3.2/changelog.md0000644000076400007640000000174512546671734016617 0ustar pravipravi The following date is in changelog file of At.js https://github.com/ichord/At.js/blob/master/CHANGELOG.md * sync at 2013-04-23 - At.js(c3845e5) #### 2013.4.15 - v0.2.4 * `data` setting will be used to load data either local or remote. If it's String as URL it will preload data from remote by launch a ajax request (every times At.js call `reg` to update settings) * remove default `remote_filter` from callbacks list. * add `get_data` and `save_data` function to contoller. They are used to get and save whole data for At.js * `save_data` will invoke `data_refactor` everytime * will filter local data which is set in `settings` first and if it get nothing then call `remote_filter` if it's exists in callbacks list that is set by user. * 2013.3.12 - v0.2.3 fix some bugs * 2013.3.1 - v0.2.2 fix some bugs. * 2013.1.24 updated to v0.2.0. * 2012.7.1 remove the mirror(copy) element of the textarea(inputor) which will disturb css style. increase timeout of displaying the result list view. jquery-atwho-rails-1.3.2/jquery-atwho-rails.gemspec0000644000076400007640000000167512546671734021464 0ustar pravipravi# -*- encoding: utf-8 -*- $:.push File.expand_path("../lib", __FILE__) require "jquery-atwho-rails/version" Gem::Specification.new do |s| s.name = "jquery-atwho-rails" s.version = Jquery::Atwho::Rails::VERSION s.authors = ["ichord"] s.email = ["chord.luo@gmail.com"] s.homepage = "http://ichord.github.com/jquery-atwho-rails" s.summary = %q{jquery plugin: @mentions} s.description = %q{This is a jQuery plugin that implement Github-like mentions.} s.rubyforge_project = "jquery-atwho-rails" s.files = `git ls-files`.split("\n") s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n") s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) } s.require_paths = ["lib"] # specify any dependencies here; for example: s.add_development_dependency "rspec" s.add_development_dependency "generator_spec" # s.add_runtime_dependency "rest-client" end jquery-atwho-rails-1.3.2/Appraisals0000644000076400007640000000006412546671734016361 0ustar pravipraviappraise "rails30" do gem "rails", "~> 3.0.0" end jquery-atwho-rails-1.3.2/README.md0000644000076400007640000000150712546671734015621 0ustar pravipravi### Usage --- Bind your textarea ```javascript $(function(){ data = ['tom','john']; $('textarea').atwho({at:"@", 'data':data}); }); ``` that's it, check it out! more details in [At.js Home Page](http://ichord.github.com/At.js/) ### Installation --- #### Rails 3.0.x Issue command line bellow: `rails generate atwho:install` then It will show in `public/[javascript|stylesheets]/` directory. #### Rails >= 3.1.x Add this gem in `Gemfile` like this: `gem jquery-atwho-rails` then add ` //= require jquery.atwho ` to `app/assets/javascripts/application.js` and add ` //=require jquery.atwho ` to `app/assets/stylesheets/applications.css` #### History Versions All in [At.js](https://github.com/ichord/At.js) project. ### Development --- #### Test generator Just issue `bundle` then `appraisal rails30 rspec` jquery-atwho-rails-1.3.2/Gemfile0000644000076400007640000000026612546671734015636 0ustar pravipraviif ENV['TRAVIS'] source 'https://rubygems.org' else source 'http://ruby.taobao.org' end # Specify your gem's dependencies in jquery-atwho-rails.gemspec gemspec gem 'appraisal' jquery-atwho-rails-1.3.2/metadata.yml0000644000076400007640000000444012546671734016644 0ustar pravipravi--- !ruby/object:Gem::Specification name: jquery-atwho-rails version: !ruby/object:Gem::Version version: 1.3.2 platform: ruby authors: - ichord autorequire: bindir: bin cert_chain: [] date: 2015-06-25 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: rspec requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: generator_spec requirement: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' description: |- This is a jQuery plugin that implement Github-like mentions. email: - chord.luo@gmail.com executables: [] extensions: [] extra_rdoc_files: [] files: - ".gitignore" - Appraisals - Gemfile - LICENSE-MIT - README.md - Rakefile - bower.json - changelog.md - gemfiles/rails30.gemfile - gemfiles/rails30.gemfile.lock - jquery-atwho-rails.gemspec - lib/assets/javascripts/jquery.atwho/index.js - lib/assets/javascripts/jquery.atwho/jquery.atwho.js - lib/assets/javascripts/jquery.atwho/jquery.caret.js - lib/assets/stylesheets/jquery.atwho.css - lib/generators/atwho/install_generator.rb - lib/jquery-atwho-rails.rb - lib/jquery-atwho-rails/version.rb - spec/generators/install_generator_spec.rb - spec/spec_helper.rb homepage: http://ichord.github.com/jquery-atwho-rails licenses: [] metadata: {} post_install_message: rdoc_options: [] require_paths: - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: jquery-atwho-rails rubygems_version: 2.4.8 signing_key: specification_version: 4 summary: 'jquery plugin: @mentions' test_files: - spec/generators/install_generator_spec.rb - spec/spec_helper.rb jquery-atwho-rails-1.3.2/lib/0000755000076400007640000000000012546671734015105 5ustar pravipravijquery-atwho-rails-1.3.2/lib/jquery-atwho-rails/0000755000076400007640000000000012546671734020654 5ustar pravipravijquery-atwho-rails-1.3.2/lib/jquery-atwho-rails/version.rb0000644000076400007640000000013012546671734022660 0ustar pravipravimodule Jquery module Atwho module Rails VERSION = '1.3.2' end end end jquery-atwho-rails-1.3.2/lib/assets/0000755000076400007640000000000012546671734016407 5ustar pravipravijquery-atwho-rails-1.3.2/lib/assets/stylesheets/0000755000076400007640000000000012546671734020763 5ustar pravipravijquery-atwho-rails-1.3.2/lib/assets/stylesheets/jquery.atwho.css0000644000076400007640000000157712546671734024147 0ustar pravipravi.atwho-view { position:absolute; top: 0; left: 0; display: none; margin-top: 18px; background: white; color: black; border: 1px solid #DDD; border-radius: 3px; box-shadow: 0 0 5px rgba(0,0,0,0.1); min-width: 120px; max-height: 200px; overflow: auto; z-index: 11110 !important; } .atwho-view .cur { background: #3366FF; color: white; } .atwho-view .cur small { color: white; } .atwho-view strong { color: #3366FF; } .atwho-view .cur strong { color: white; font:bold; } .atwho-view ul { /* width: 100px; */ list-style:none; padding:0; margin:auto; } .atwho-view ul li { display: block; padding: 5px 10px; border-bottom: 1px solid #DDD; cursor: pointer; /* border-top: 1px solid #C8C8C8; */ } .atwho-view small { font-size: smaller; color: #777; font-weight: normal; } jquery-atwho-rails-1.3.2/lib/assets/javascripts/0000755000076400007640000000000012546671734020740 5ustar pravipravijquery-atwho-rails-1.3.2/lib/assets/javascripts/jquery.atwho/0000755000076400007640000000000012546671734023400 5ustar pravipravijquery-atwho-rails-1.3.2/lib/assets/javascripts/jquery.atwho/index.js0000644000076400007640000000006612546671734025047 0ustar pravipravi//= require ./jquery.caret //= require ./jquery.atwho jquery-atwho-rails-1.3.2/lib/assets/javascripts/jquery.atwho/jquery.caret.js0000644000076400007640000002617712546671734026367 0ustar pravipravi(function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module. define(["jquery"], function ($) { return (root.returnExportsGlobal = factory($)); }); } else if (typeof exports === 'object') { // Node. Does not work with strict CommonJS, but // only CommonJS-like enviroments that support module.exports, // like Node. module.exports = factory(require("jquery")); } else { factory(jQuery); } }(this, function ($) { /* Implement Github like autocomplete mentions http://ichord.github.com/At.js Copyright (c) 2013 chord.luo@gmail.com Licensed under the MIT license. */ /* 本插件操作 textarea 或者 input 内的插入符 只实现了获得插入符在文本框中的位置,我设置 插入符的位置. */ "use strict"; var EditableCaret, InputCaret, Mirror, Utils, discoveryIframeOf, methods, oDocument, oFrame, oWindow, pluginName, setContextBy; pluginName = 'caret'; EditableCaret = (function() { function EditableCaret($inputor) { this.$inputor = $inputor; this.domInputor = this.$inputor[0]; } EditableCaret.prototype.setPos = function(pos) { return this.domInputor; }; EditableCaret.prototype.getIEPosition = function() { return this.getPosition(); }; EditableCaret.prototype.getPosition = function() { var inputor_offset, offset; offset = this.getOffset(); inputor_offset = this.$inputor.offset(); offset.left -= inputor_offset.left; offset.top -= inputor_offset.top; return offset; }; EditableCaret.prototype.getOldIEPos = function() { var preCaretTextRange, textRange; textRange = oDocument.selection.createRange(); preCaretTextRange = oDocument.body.createTextRange(); preCaretTextRange.moveToElementText(this.domInputor); preCaretTextRange.setEndPoint("EndToEnd", textRange); return preCaretTextRange.text.length; }; EditableCaret.prototype.getPos = function() { var clonedRange, pos, range; if (range = this.range()) { clonedRange = range.cloneRange(); clonedRange.selectNodeContents(this.domInputor); clonedRange.setEnd(range.endContainer, range.endOffset); pos = clonedRange.toString().length; clonedRange.detach(); return pos; } else if (oDocument.selection) { return this.getOldIEPos(); } }; EditableCaret.prototype.getOldIEOffset = function() { var range, rect; range = oDocument.selection.createRange().duplicate(); range.moveStart("character", -1); rect = range.getBoundingClientRect(); return { height: rect.bottom - rect.top, left: rect.left, top: rect.top }; }; EditableCaret.prototype.getOffset = function(pos) { var clonedRange, offset, range, rect, shadowCaret; if (oWindow.getSelection && (range = this.range())) { if (range.endOffset - 1 > 0 && range.endContainer === !this.domInputor) { clonedRange = range.cloneRange(); clonedRange.setStart(range.endContainer, range.endOffset - 1); clonedRange.setEnd(range.endContainer, range.endOffset); rect = clonedRange.getBoundingClientRect(); offset = { height: rect.height, left: rect.left + rect.width, top: rect.top }; clonedRange.detach(); } if (!offset || (offset != null ? offset.height : void 0) === 0) { clonedRange = range.cloneRange(); shadowCaret = $(oDocument.createTextNode("|")); clonedRange.insertNode(shadowCaret[0]); clonedRange.selectNode(shadowCaret[0]); rect = clonedRange.getBoundingClientRect(); offset = { height: rect.height, left: rect.left, top: rect.top }; shadowCaret.remove(); clonedRange.detach(); } } else if (oDocument.selection) { offset = this.getOldIEOffset(); } if (offset) { offset.top += $(oWindow).scrollTop(); offset.left += $(oWindow).scrollLeft(); } return offset; }; EditableCaret.prototype.range = function() { var sel; if (!oWindow.getSelection) { return; } sel = oWindow.getSelection(); if (sel.rangeCount > 0) { return sel.getRangeAt(0); } else { return null; } }; return EditableCaret; })(); InputCaret = (function() { function InputCaret($inputor) { this.$inputor = $inputor; this.domInputor = this.$inputor[0]; } InputCaret.prototype.getIEPos = function() { var endRange, inputor, len, normalizedValue, pos, range, textInputRange; inputor = this.domInputor; range = oDocument.selection.createRange(); pos = 0; if (range && range.parentElement() === inputor) { normalizedValue = inputor.value.replace(/\r\n/g, "\n"); len = normalizedValue.length; textInputRange = inputor.createTextRange(); textInputRange.moveToBookmark(range.getBookmark()); endRange = inputor.createTextRange(); endRange.collapse(false); if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) { pos = len; } else { pos = -textInputRange.moveStart("character", -len); } } return pos; }; InputCaret.prototype.getPos = function() { if (oDocument.selection) { return this.getIEPos(); } else { return this.domInputor.selectionStart; } }; InputCaret.prototype.setPos = function(pos) { var inputor, range; inputor = this.domInputor; if (oDocument.selection) { range = inputor.createTextRange(); range.move("character", pos); range.select(); } else if (inputor.setSelectionRange) { inputor.setSelectionRange(pos, pos); } return inputor; }; InputCaret.prototype.getIEOffset = function(pos) { var h, textRange, x, y; textRange = this.domInputor.createTextRange(); pos || (pos = this.getPos()); textRange.move('character', pos); x = textRange.boundingLeft; y = textRange.boundingTop; h = textRange.boundingHeight; return { left: x, top: y, height: h }; }; InputCaret.prototype.getOffset = function(pos) { var $inputor, offset, position; $inputor = this.$inputor; if (oDocument.selection) { offset = this.getIEOffset(pos); offset.top += $(oWindow).scrollTop() + $inputor.scrollTop(); offset.left += $(oWindow).scrollLeft() + $inputor.scrollLeft(); return offset; } else { offset = $inputor.offset(); position = this.getPosition(pos); return offset = { left: offset.left + position.left - $inputor.scrollLeft(), top: offset.top + position.top - $inputor.scrollTop(), height: position.height }; } }; InputCaret.prototype.getPosition = function(pos) { var $inputor, at_rect, end_range, format, html, mirror, start_range; $inputor = this.$inputor; format = function(value) { value = value.replace(/<|>|`|"|&/g, '?').replace(/\r\n|\r|\n/g, "
"); if (/firefox/i.test(navigator.userAgent)) { value = value.replace(/\s/g, ' '); } return value; }; if (pos === void 0) { pos = this.getPos(); } start_range = $inputor.val().slice(0, pos); end_range = $inputor.val().slice(pos); html = "" + format(start_range) + ""; html += "|"; html += "" + format(end_range) + ""; mirror = new Mirror($inputor); return at_rect = mirror.create(html).rect(); }; InputCaret.prototype.getIEPosition = function(pos) { var h, inputorOffset, offset, x, y; offset = this.getIEOffset(pos); inputorOffset = this.$inputor.offset(); x = offset.left - inputorOffset.left; y = offset.top - inputorOffset.top; h = offset.height; return { left: x, top: y, height: h }; }; return InputCaret; })(); Mirror = (function() { Mirror.prototype.css_attr = ["borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopStyle", "borderRightStyle", "borderBottomStyle", "borderLeftStyle", "borderTopWidth", "boxSizing", "fontFamily", "fontSize", "fontWeight", "height", "letterSpacing", "lineHeight", "marginBottom", "marginLeft", "marginRight", "marginTop", "outlineWidth", "overflow", "overflowX", "overflowY", "paddingBottom", "paddingLeft", "paddingRight", "paddingTop", "textAlign", "textOverflow", "textTransform", "whiteSpace", "wordBreak", "wordWrap"]; function Mirror($inputor) { this.$inputor = $inputor; } Mirror.prototype.mirrorCss = function() { var css, _this = this; css = { position: 'absolute', left: -9999, top: 0, zIndex: -20000 }; if (this.$inputor.prop('tagName') === 'TEXTAREA') { this.css_attr.push('width'); } $.each(this.css_attr, function(i, p) { return css[p] = _this.$inputor.css(p); }); return css; }; Mirror.prototype.create = function(html) { this.$mirror = $('
'); this.$mirror.css(this.mirrorCss()); this.$mirror.html(html); this.$inputor.after(this.$mirror); return this; }; Mirror.prototype.rect = function() { var $flag, pos, rect; $flag = this.$mirror.find("#caret"); pos = $flag.position(); rect = { left: pos.left, top: pos.top, height: $flag.height() }; this.$mirror.remove(); return rect; }; return Mirror; })(); Utils = { contentEditable: function($inputor) { return !!($inputor[0].contentEditable && $inputor[0].contentEditable === 'true'); } }; methods = { pos: function(pos) { if (pos || pos === 0) { return this.setPos(pos); } else { return this.getPos(); } }, position: function(pos) { if (oDocument.selection) { return this.getIEPosition(pos); } else { return this.getPosition(pos); } }, offset: function(pos) { var offset; offset = this.getOffset(pos); return offset; } }; oDocument = null; oWindow = null; oFrame = null; setContextBy = function(settings) { var iframe; if (iframe = settings != null ? settings.iframe : void 0) { oFrame = iframe; oWindow = iframe.contentWindow; return oDocument = iframe.contentDocument || oWindow.document; } else { oFrame = void 0; oWindow = window; return oDocument = document; } }; discoveryIframeOf = function($dom) { var error; oDocument = $dom[0].ownerDocument; oWindow = oDocument.defaultView || oDocument.parentWindow; try { return oFrame = oWindow.frameElement; } catch (_error) { error = _error; } }; $.fn.caret = function(method, value, settings) { var caret; if (methods[method]) { if ($.isPlainObject(value)) { setContextBy(value); value = void 0; } else { setContextBy(settings); } caret = Utils.contentEditable(this) ? new EditableCaret(this) : new InputCaret(this); return methods[method].apply(caret, [value]); } else { return $.error("Method " + method + " does not exist on jQuery.caret"); } }; $.fn.caret.EditableCaret = EditableCaret; $.fn.caret.InputCaret = InputCaret; $.fn.caret.Utils = Utils; $.fn.caret.apis = methods; })); jquery-atwho-rails-1.3.2/lib/assets/javascripts/jquery.atwho/jquery.atwho.js0000644000076400007640000007676112546671734026417 0ustar pravipravi/*! jquery.atwho - v1.3.2 %> * Copyright (c) 2015 chord.luo ; * homepage: http://ichord.github.com/At.js * Licensed MIT */ (function (root, factory) { if (typeof define === 'function' && define.amd) { // AMD. Register as an anonymous module unless amdModuleId is set define(["jquery"], function (a0) { return (factory(a0)); }); } else if (typeof exports === 'object') { // Node. Does not work with strict CommonJS, but // only CommonJS-like environments that support module.exports, // like Node. module.exports = factory(require("jquery")); } else { factory(jQuery); } }(this, function (jquery) { var $, Api, App, Controller, DEFAULT_CALLBACKS, EditableController, KEY_CODE, Model, TextareaController, View, slice = [].slice, extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, hasProp = {}.hasOwnProperty; $ = jquery; App = (function() { function App(inputor) { this.currentFlag = null; this.controllers = {}; this.aliasMaps = {}; this.$inputor = $(inputor); this.setupRootElement(); this.listen(); } App.prototype.createContainer = function(doc) { var ref; if ((ref = this.$el) != null) { ref.remove(); } return $(doc.body).append(this.$el = $("
")); }; App.prototype.setupRootElement = function(iframe, asRoot) { var error; if (asRoot == null) { asRoot = false; } if (iframe) { this.window = iframe.contentWindow; this.document = iframe.contentDocument || this.window.document; this.iframe = iframe; } else { this.document = this.$inputor[0].ownerDocument; this.window = this.document.defaultView || this.document.parentWindow; try { this.iframe = this.window.frameElement; } catch (_error) { error = _error; this.iframe = null; if ($.fn.atwho.debug) { throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n" + error); } } } return this.createContainer((this.iframeAsRoot = asRoot) ? this.document : document); }; App.prototype.controller = function(at) { var c, current, currentFlag, ref; if (this.aliasMaps[at]) { current = this.controllers[this.aliasMaps[at]]; } else { ref = this.controllers; for (currentFlag in ref) { c = ref[currentFlag]; if (currentFlag === at) { current = c; break; } } } if (current) { return current; } else { return this.controllers[this.currentFlag]; } }; App.prototype.setContextFor = function(at) { this.currentFlag = at; return this; }; App.prototype.reg = function(flag, setting) { var base, controller; controller = (base = this.controllers)[flag] || (base[flag] = this.$inputor.is('[contentEditable]') ? new EditableController(this, flag) : new TextareaController(this, flag)); if (setting.alias) { this.aliasMaps[setting.alias] = flag; } controller.init(setting); return this; }; App.prototype.listen = function() { return this.$inputor.on('compositionstart', (function(_this) { return function(e) { var ref; if ((ref = _this.controller()) != null) { ref.view.hide(); } return _this.isComposing = true; }; })(this)).on('compositionend', (function(_this) { return function(e) { return _this.isComposing = false; }; })(this)).on('keyup.atwhoInner', (function(_this) { return function(e) { return _this.onKeyup(e); }; })(this)).on('keydown.atwhoInner', (function(_this) { return function(e) { return _this.onKeydown(e); }; })(this)).on('blur.atwhoInner', (function(_this) { return function(e) { var c; if (c = _this.controller()) { c.expectedQueryCBId = null; return c.view.hide(e, c.getOpt("displayTimeout")); } }; })(this)).on('click.atwhoInner', (function(_this) { return function(e) { return _this.dispatch(e); }; })(this)).on('scroll.atwhoInner', (function(_this) { return function() { var lastScrollTop; lastScrollTop = _this.$inputor.scrollTop(); return function(e) { var currentScrollTop, ref; currentScrollTop = e.target.scrollTop; if (lastScrollTop !== currentScrollTop) { if ((ref = _this.controller()) != null) { ref.view.hide(e); } } lastScrollTop = currentScrollTop; return true; }; }; })(this)()); }; App.prototype.shutdown = function() { var _, c, ref; ref = this.controllers; for (_ in ref) { c = ref[_]; c.destroy(); delete this.controllers[_]; } this.$inputor.off('.atwhoInner'); return this.$el.remove(); }; App.prototype.dispatch = function(e) { var _, c, ref, results; ref = this.controllers; results = []; for (_ in ref) { c = ref[_]; results.push(c.lookUp(e)); } return results; }; App.prototype.onKeyup = function(e) { var ref; switch (e.keyCode) { case KEY_CODE.ESC: e.preventDefault(); if ((ref = this.controller()) != null) { ref.view.hide(); } break; case KEY_CODE.DOWN: case KEY_CODE.UP: case KEY_CODE.CTRL: $.noop(); break; case KEY_CODE.P: case KEY_CODE.N: if (!e.ctrlKey) { this.dispatch(e); } break; default: this.dispatch(e); } }; App.prototype.onKeydown = function(e) { var ref, view; view = (ref = this.controller()) != null ? ref.view : void 0; if (!(view && view.visible())) { return; } switch (e.keyCode) { case KEY_CODE.ESC: e.preventDefault(); view.hide(e); break; case KEY_CODE.UP: e.preventDefault(); view.prev(); break; case KEY_CODE.DOWN: e.preventDefault(); view.next(); break; case KEY_CODE.P: if (!e.ctrlKey) { return; } e.preventDefault(); view.prev(); break; case KEY_CODE.N: if (!e.ctrlKey) { return; } e.preventDefault(); view.next(); break; case KEY_CODE.TAB: case KEY_CODE.ENTER: case KEY_CODE.SPACE: if (!view.visible()) { return; } if (!this.controller().getOpt('spaceSelectsMatch') && e.keyCode === KEY_CODE.SPACE) { return; } if (!this.controller().getOpt('tabSelectsMatch') && e.keyCode === KEY_CODE.TAB) { return; } if (view.highlighted()) { e.preventDefault(); view.choose(e); } else { view.hide(e); } break; default: $.noop(); } }; return App; })(); Controller = (function() { Controller.prototype.uid = function() { return (Math.random().toString(16) + "000000000").substr(2, 8) + (new Date().getTime()); }; function Controller(app1, at1) { this.app = app1; this.at = at1; this.$inputor = this.app.$inputor; this.id = this.$inputor[0].id || this.uid(); this.expectedQueryCBId = null; this.setting = null; this.query = null; this.pos = 0; this.range = null; if ((this.$el = $("#atwho-ground-" + this.id, this.app.$el)).length === 0) { this.app.$el.append(this.$el = $("
")); } this.model = new Model(this); this.view = new View(this); } Controller.prototype.init = function(setting) { this.setting = $.extend({}, this.setting || $.fn.atwho["default"], setting); this.view.init(); return this.model.reload(this.setting.data); }; Controller.prototype.destroy = function() { this.trigger('beforeDestroy'); this.model.destroy(); this.view.destroy(); return this.$el.remove(); }; Controller.prototype.callDefault = function() { var args, error, funcName; funcName = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; try { return DEFAULT_CALLBACKS[funcName].apply(this, args); } catch (_error) { error = _error; return $.error(error + " Or maybe At.js doesn't have function " + funcName); } }; Controller.prototype.trigger = function(name, data) { var alias, eventName; if (data == null) { data = []; } data.push(this); alias = this.getOpt('alias'); eventName = alias ? name + "-" + alias + ".atwho" : name + ".atwho"; return this.$inputor.trigger(eventName, data); }; Controller.prototype.callbacks = function(funcName) { return this.getOpt("callbacks")[funcName] || DEFAULT_CALLBACKS[funcName]; }; Controller.prototype.getOpt = function(at, default_value) { var e; try { return this.setting[at]; } catch (_error) { e = _error; return null; } }; Controller.prototype.insertContentFor = function($li) { var data, tpl; tpl = this.getOpt('insertTpl'); data = $.extend({}, $li.data('item-data'), { 'atwho-at': this.at }); return this.callbacks("tplEval").call(this, tpl, data, "onInsert"); }; Controller.prototype.renderView = function(data) { var searchKey; searchKey = this.getOpt("searchKey"); data = this.callbacks("sorter").call(this, this.query.text, data.slice(0, 1001), searchKey); return this.view.render(data.slice(0, this.getOpt('limit'))); }; Controller.arrayToDefaultHash = function(data) { var i, item, len, results; if (!$.isArray(data)) { return data; } results = []; for (i = 0, len = data.length; i < len; i++) { item = data[i]; if ($.isPlainObject(item)) { results.push(item); } else { results.push({ name: item }); } } return results; }; Controller.prototype.lookUp = function(e) { var query, wait; query = this.catchQuery(e); if (!query) { this.expectedQueryCBId = null; return query; } this.app.setContextFor(this.at); if (wait = this.getOpt('delay')) { this._delayLookUp(query, wait); } else { this._lookUp(query); } return query; }; Controller.prototype._delayLookUp = function(query, wait) { var now, remaining; now = Date.now ? Date.now() : new Date().getTime(); this.previousCallTime || (this.previousCallTime = now); remaining = wait - (now - this.previousCallTime); if ((0 < remaining && remaining < wait)) { this.previousCallTime = now; this._stopDelayedCall(); return this.delayedCallTimeout = setTimeout((function(_this) { return function() { _this.previousCallTime = 0; _this.delayedCallTimeout = null; return _this._lookUp(query); }; })(this), wait); } else { this._stopDelayedCall(); if (this.previousCallTime !== now) { this.previousCallTime = 0; } return this._lookUp(query); } }; Controller.prototype._stopDelayedCall = function() { if (this.delayedCallTimeout) { clearTimeout(this.delayedCallTimeout); return this.delayedCallTimeout = null; } }; Controller.prototype._generateQueryCBId = function() { return {}; }; Controller.prototype._lookUp = function(query) { var _callback; _callback = function(queryCBId, data) { if (queryCBId !== this.expectedQueryCBId) { return; } if (data && data.length > 0) { return this.renderView(this.constructor.arrayToDefaultHash(data)); } else { return this.view.hide(); } }; this.expectedQueryCBId = this._generateQueryCBId(); return this.model.query(query.text, $.proxy(_callback, this, this.expectedQueryCBId)); }; return Controller; })(); TextareaController = (function(superClass) { extend(TextareaController, superClass); function TextareaController() { return TextareaController.__super__.constructor.apply(this, arguments); } TextareaController.prototype.catchQuery = function() { var caretPos, content, end, query, start, subtext; content = this.$inputor.val(); caretPos = this.$inputor.caret('pos', { iframe: this.app.iframe }); subtext = content.slice(0, caretPos); query = this.callbacks("matcher").call(this, this.at, subtext, this.getOpt('startWithSpace')); if (typeof query === "string" && query.length <= this.getOpt('maxLen', 20)) { start = caretPos - query.length; end = start + query.length; this.pos = start; query = { 'text': query, 'headPos': start, 'endPos': end }; this.trigger("matched", [this.at, query.text]); } else { query = null; this.view.hide(); } return this.query = query; }; TextareaController.prototype.rect = function() { var c, iframeOffset, scaleBottom; if (!(c = this.$inputor.caret('offset', this.pos - 1, { iframe: this.app.iframe }))) { return; } if (this.app.iframe && !this.app.iframeAsRoot) { iframeOffset = $(this.app.iframe).offset(); c.left += iframeOffset.left; c.top += iframeOffset.top; } scaleBottom = this.app.document.selection ? 0 : 2; return { left: c.left, top: c.top, bottom: c.top + c.height + scaleBottom }; }; TextareaController.prototype.insert = function(content, $li) { var $inputor, source, startStr, suffix, text; $inputor = this.$inputor; source = $inputor.val(); startStr = source.slice(0, Math.max(this.query.headPos - this.at.length, 0)); suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || " "; content += suffix; text = "" + startStr + content + (source.slice(this.query['endPos'] || 0)); $inputor.val(text); $inputor.caret('pos', startStr.length + content.length, { iframe: this.app.iframe }); if (!$inputor.is(':focus')) { $inputor.focus(); } return $inputor.change(); }; return TextareaController; })(Controller); EditableController = (function(superClass) { extend(EditableController, superClass); function EditableController() { return EditableController.__super__.constructor.apply(this, arguments); } EditableController.prototype._getRange = function() { var sel; sel = this.app.window.getSelection(); if (sel.rangeCount > 0) { return sel.getRangeAt(0); } }; EditableController.prototype._setRange = function(position, node, range) { if (range == null) { range = this._getRange(); } if (!range) { return; } node = $(node)[0]; if (position === 'after') { range.setEndAfter(node); range.setStartAfter(node); } else { range.setEndBefore(node); range.setStartBefore(node); } range.collapse(false); return this._clearRange(range); }; EditableController.prototype._clearRange = function(range) { var sel; if (range == null) { range = this._getRange(); } sel = this.app.window.getSelection(); if (this.ctrl_a_pressed == null) { sel.removeAllRanges(); return sel.addRange(range); } }; EditableController.prototype._movingEvent = function(e) { var ref; return e.type === 'click' || ((ref = e.which) === KEY_CODE.RIGHT || ref === KEY_CODE.LEFT || ref === KEY_CODE.UP || ref === KEY_CODE.DOWN); }; EditableController.prototype._unwrap = function(node) { var next; node = $(node).unwrap().get(0); if ((next = node.nextSibling) && next.nodeValue) { node.nodeValue += next.nodeValue; $(next).remove(); } return node; }; EditableController.prototype.catchQuery = function(e) { var $inserted, $query, _range, index, inserted, lastNode, matched, offset, query, range; if (this.app.isComposing) { return; } if (!(range = this._getRange())) { return; } if (e.which === KEY_CODE.CTRL) { this.ctrl_pressed = true; } else if (e.which === KEY_CODE.A) { if (this.ctrl_pressed == null) { this.ctrl_a_pressed = true; } } else { delete this.ctrl_a_pressed; delete this.ctrl_pressed; } if (e.which === KEY_CODE.ENTER) { ($query = $(range.startContainer).closest('.atwho-query')).contents().unwrap(); if ($query.is(':empty')) { $query.remove(); } ($query = $(".atwho-query", this.app.document)).text($query.text()).contents().last().unwrap(); this._clearRange(); return; } if (/firefox/i.test(navigator.userAgent)) { if ($(range.startContainer).is(this.$inputor)) { this._clearRange(); return; } if (e.which === KEY_CODE.BACKSPACE && range.startContainer.nodeType === document.ELEMENT_NODE && (offset = range.startOffset - 1) >= 0) { _range = range.cloneRange(); _range.setStart(range.startContainer, offset); if ($(_range.cloneContents()).contents().last().is('.atwho-inserted')) { inserted = $(range.startContainer).contents().get(offset); this._setRange('after', $(inserted).contents().last()); } } else if (e.which === KEY_CODE.LEFT && range.startContainer.nodeType === document.TEXT_NODE) { $inserted = $(range.startContainer.previousSibling); if ($inserted.is('.atwho-inserted') && range.startOffset === 0) { this._setRange('after', $inserted.contents().last()); } } } $(range.startContainer).closest('.atwho-inserted').addClass('atwho-query').siblings().removeClass('atwho-query'); if (($query = $(".atwho-query", this.app.document)).length > 0 && $query.is(':empty') && $query.text().length === 0) { $query.remove(); } if (!this._movingEvent(e)) { $query.removeClass('atwho-inserted'); } _range = range.cloneRange(); _range.setStart(range.startContainer, 0); matched = this.callbacks("matcher").call(this, this.at, _range.toString(), this.getOpt('startWithSpace')); if ($query.length === 0 && typeof matched === 'string' && (index = range.startOffset - this.at.length - matched.length) >= 0) { range.setStart(range.startContainer, index); $query = $('', this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass('atwho-query'); range.surroundContents($query.get(0)); lastNode = $query.contents().last().get(0); if (/firefox/i.test(navigator.userAgent)) { range.setStart(lastNode, lastNode.length); range.setEnd(lastNode, lastNode.length); this._clearRange(range); } else { this._setRange('after', lastNode, range); } } if (typeof matched === 'string' && matched.length <= this.getOpt('maxLen', 20)) { query = { text: matched, el: $query }; this.trigger("matched", [this.at, query.text]); return this.query = query; } else { this.view.hide(); this.query = { el: $query }; if ($query.text().indexOf(this.at) >= 0) { if (this._movingEvent(e) && $query.hasClass('atwho-inserted')) { $query.removeClass('atwho-query'); } else if (false !== this.callbacks('afterMatchFailed').call(this, this.at, $query)) { this._setRange("after", this._unwrap($query.text($query.text()).contents().first())); } } return null; } }; EditableController.prototype.rect = function() { var $iframe, iframeOffset, rect; rect = this.query.el.offset(); if (this.app.iframe && !this.app.iframeAsRoot) { iframeOffset = ($iframe = $(this.app.iframe)).offset(); rect.left += iframeOffset.left - this.$inputor.scrollLeft(); rect.top += iframeOffset.top - this.$inputor.scrollTop(); } rect.bottom = rect.top + this.query.el.height(); return rect; }; EditableController.prototype.insert = function(content, $li) { var range, suffix, suffixNode; suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0"; this.query.el.removeClass('atwho-query').addClass('atwho-inserted').html(content); if (range = this._getRange()) { range.setEndAfter(this.query.el[0]); range.collapse(false); range.insertNode(suffixNode = this.app.document.createTextNode(suffix)); this._setRange('after', suffixNode, range); } if (!this.$inputor.is(':focus')) { this.$inputor.focus(); } return this.$inputor.change(); }; return EditableController; })(Controller); Model = (function() { function Model(context) { this.context = context; this.at = this.context.at; this.storage = this.context.$inputor; } Model.prototype.destroy = function() { return this.storage.data(this.at, null); }; Model.prototype.saved = function() { return this.fetch() > 0; }; Model.prototype.query = function(query, callback) { var _remoteFilter, data, searchKey; data = this.fetch(); searchKey = this.context.getOpt("searchKey"); data = this.context.callbacks('filter').call(this.context, query, data, searchKey) || []; _remoteFilter = this.context.callbacks('remoteFilter'); if (data.length > 0 || (!_remoteFilter && data.length === 0)) { return callback(data); } else { return _remoteFilter.call(this.context, query, callback); } }; Model.prototype.fetch = function() { return this.storage.data(this.at) || []; }; Model.prototype.save = function(data) { return this.storage.data(this.at, this.context.callbacks("beforeSave").call(this.context, data || [])); }; Model.prototype.load = function(data) { if (!(this.saved() || !data)) { return this._load(data); } }; Model.prototype.reload = function(data) { return this._load(data); }; Model.prototype._load = function(data) { if (typeof data === "string") { return $.ajax(data, { dataType: "json" }).done((function(_this) { return function(data) { return _this.save(data); }; })(this)); } else { return this.save(data); } }; return Model; })(); View = (function() { function View(context) { this.context = context; this.$el = $("
    "); this.timeoutID = null; this.context.$el.append(this.$el); this.bindEvent(); } View.prototype.init = function() { var id; id = this.context.getOpt("alias") || this.context.at.charCodeAt(0); return this.$el.attr({ 'id': "at-view-" + id }); }; View.prototype.destroy = function() { return this.$el.remove(); }; View.prototype.bindEvent = function() { var $menu; $menu = this.$el.find('ul'); return $menu.on('mouseenter.atwho-view', 'li', function(e) { $menu.find('.cur').removeClass('cur'); return $(e.currentTarget).addClass('cur'); }).on('click.atwho-view', 'li', (function(_this) { return function(e) { $menu.find('.cur').removeClass('cur'); $(e.currentTarget).addClass('cur'); _this.choose(e); return e.preventDefault(); }; })(this)); }; View.prototype.visible = function() { return this.$el.is(":visible"); }; View.prototype.highlighted = function() { return this.$el.find(".cur").length > 0; }; View.prototype.choose = function(e) { var $li, content; if (($li = this.$el.find(".cur")).length) { content = this.context.insertContentFor($li); this.context.insert(this.context.callbacks("beforeInsert").call(this.context, content, $li), $li); this.context.trigger("inserted", [$li, e]); this.hide(e); } if (this.context.getOpt("hideWithoutSuffix")) { return this.stopShowing = true; } }; View.prototype.reposition = function(rect) { var _window, offset, overflowOffset, ref; _window = this.context.app.iframeAsRoot ? this.context.app.window : window; if (rect.bottom + this.$el.height() - $(_window).scrollTop() > $(_window).height()) { rect.bottom = rect.top - this.$el.height(); } if (rect.left > (overflowOffset = $(_window).width() - this.$el.width() - 5)) { rect.left = overflowOffset; } offset = { left: rect.left, top: rect.bottom }; if ((ref = this.context.callbacks("beforeReposition")) != null) { ref.call(this.context, offset); } this.$el.offset(offset); return this.context.trigger("reposition", [offset]); }; View.prototype.next = function() { var cur, next; cur = this.$el.find('.cur').removeClass('cur'); next = cur.next(); if (!next.length) { next = this.$el.find('li:first'); } next.addClass('cur'); return this.scrollTop(Math.max(0, cur.innerHeight() * (next.index() + 2) - this.$el.height())); }; View.prototype.prev = function() { var cur, prev; cur = this.$el.find('.cur').removeClass('cur'); prev = cur.prev(); if (!prev.length) { prev = this.$el.find('li:last'); } prev.addClass('cur'); return this.scrollTop(Math.max(0, cur.innerHeight() * (prev.index() + 2) - this.$el.height())); }; View.prototype.scrollTop = function(scrollTop) { var scrollDuration; scrollDuration = this.context.getOpt('scrollDuration'); if (scrollDuration) { return this.$el.animate({ scrollTop: scrollTop }, scrollDuration); } else { return this.$el.scrollTop(scrollTop); } }; View.prototype.show = function() { var rect; if (this.stopShowing) { this.stopShowing = false; return; } if (!this.visible()) { this.$el.show(); this.$el.scrollTop(0); this.context.trigger('shown'); } if (rect = this.context.rect()) { return this.reposition(rect); } }; View.prototype.hide = function(e, time) { var callback; if (!this.visible()) { return; } if (isNaN(time)) { this.$el.hide(); return this.context.trigger('hidden', [e]); } else { callback = (function(_this) { return function() { return _this.hide(); }; })(this); clearTimeout(this.timeoutID); return this.timeoutID = setTimeout(callback, time); } }; View.prototype.render = function(list) { var $li, $ul, i, item, len, li, tpl; if (!($.isArray(list) && list.length > 0)) { this.hide(); return; } this.$el.find('ul').empty(); $ul = this.$el.find('ul'); tpl = this.context.getOpt('displayTpl'); for (i = 0, len = list.length; i < len; i++) { item = list[i]; item = $.extend({}, item, { 'atwho-at': this.context.at }); li = this.context.callbacks("tplEval").call(this.context, tpl, item, "onDisplay"); $li = $(this.context.callbacks("highlighter").call(this.context, li, this.context.query.text)); $li.data("item-data", item); $ul.append($li); } this.show(); if (this.context.getOpt('highlightFirst')) { return $ul.find("li:first").addClass("cur"); } }; return View; })(); KEY_CODE = { DOWN: 40, UP: 38, ESC: 27, TAB: 9, ENTER: 13, CTRL: 17, A: 65, P: 80, N: 78, LEFT: 37, UP: 38, RIGHT: 39, DOWN: 40, BACKSPACE: 8, SPACE: 32 }; DEFAULT_CALLBACKS = { beforeSave: function(data) { return Controller.arrayToDefaultHash(data); }, matcher: function(flag, subtext, should_startWithSpace, acceptSpaceBar) { var _a, _y, match, regexp, space; flag = flag.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&"); if (should_startWithSpace) { flag = '(?:^|\\s)' + flag; } _a = decodeURI("%C3%80"); _y = decodeURI("%C3%BF"); space = acceptSpaceBar ? "\ " : ""; regexp = new RegExp(flag + "([A-Za-z" + _a + "-" + _y + "0-9_" + space + "\.\+\-]*)$|" + flag + "([^\\x00-\\xff]*)$", 'gi'); match = regexp.exec(subtext); if (match) { return match[2] || match[1]; } else { return null; } }, filter: function(query, data, searchKey) { var _results, i, item, len; _results = []; for (i = 0, len = data.length; i < len; i++) { item = data[i]; if (~new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase())) { _results.push(item); } } return _results; }, remoteFilter: null, sorter: function(query, items, searchKey) { var _results, i, item, len; if (!query) { return items; } _results = []; for (i = 0, len = items.length; i < len; i++) { item = items[i]; item.atwho_order = new String(item[searchKey]).toLowerCase().indexOf(query.toLowerCase()); if (item.atwho_order > -1) { _results.push(item); } } return _results.sort(function(a, b) { return a.atwho_order - b.atwho_order; }); }, tplEval: function(tpl, map) { var error, template; template = tpl; try { if (typeof tpl !== 'string') { template = tpl(map); } return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) { return map[key]; }); } catch (_error) { error = _error; return ""; } }, highlighter: function(li, query) { var regexp; if (!query) { return li; } regexp = new RegExp(">\\s*(\\w*?)(" + query.replace("+", "\\+") + ")(\\w*)\\s*<", 'ig'); return li.replace(regexp, function(str, $1, $2, $3) { return '> ' + $1 + '' + $2 + '' + $3 + ' <'; }); }, beforeInsert: function(value, $li) { return value; }, beforeReposition: function(offset) { return offset; }, afterMatchFailed: function(at, el) {} }; Api = { load: function(at, data) { var c; if (c = this.controller(at)) { return c.model.load(data); } }, isSelecting: function() { var ref; return (ref = this.controller()) != null ? ref.view.visible() : void 0; }, hide: function() { var ref; return (ref = this.controller()) != null ? ref.view.hide() : void 0; }, reposition: function() { var c; if (c = this.controller()) { return c.view.reposition(c.rect()); } }, setIframe: function(iframe, asRoot) { this.setupRootElement(iframe, asRoot); return null; }, run: function() { return this.dispatch(); }, destroy: function() { this.shutdown(); return this.$inputor.data('atwho', null); } }; $.fn.atwho = function(method) { var _args, result; _args = arguments; result = null; this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function() { var $this, app; if (!(app = ($this = $(this)).data("atwho"))) { $this.data('atwho', (app = new App(this))); } if (typeof method === 'object' || !method) { return app.reg(method.at, method); } else if (Api[method] && app) { return result = Api[method].apply(app, Array.prototype.slice.call(_args, 1)); } else { return $.error("Method " + method + " does not exist on jQuery.atwho"); } }); if (result != null) { return result; } else { return this; } }; $.fn.atwho["default"] = { at: void 0, alias: void 0, data: null, displayTpl: "
  • ${name}
  • ", insertTpl: "${atwho-at}${name}", callbacks: DEFAULT_CALLBACKS, searchKey: "name", suffix: void 0, hideWithoutSuffix: false, startWithSpace: true, highlightFirst: true, limit: 5, maxLen: 20, displayTimeout: 300, delay: null, spaceSelectsMatch: false, tabSelectsMatch: true, editableAtwhoQueryAttrs: {}, scrollDuration: 150 }; $.fn.atwho.debug = false; })); jquery-atwho-rails-1.3.2/lib/jquery-atwho-rails.rb0000644000076400007640000000025612546671734021204 0ustar pravipravirequire "jquery-atwho-rails/version" require "active_support" module Jquery module Atwho module Rails class Engine < ::Rails::Engine end end end end jquery-atwho-rails-1.3.2/lib/generators/0000755000076400007640000000000012546671734017256 5ustar pravipravijquery-atwho-rails-1.3.2/lib/generators/atwho/0000755000076400007640000000000012546671734020400 5ustar pravipravijquery-atwho-rails-1.3.2/lib/generators/atwho/install_generator.rb0000644000076400007640000000417112546671734024444 0ustar pravipravirequire 'rails' require 'jquery-atwho-rails/version' # Supply generator for Rails 3.0.x or if asset pipeline is not enabled if ::Rails.version < "3.1" || !::Rails.application.config.assets.enabled module Atwho module Generators class InstallGenerator < ::Rails::Generators::Base desc "This generator installs jquery.atwho.js #{Jquery::Atwho::Rails::VERSION}" source_root File.expand_path('../../../assets', __FILE__) def copy_js say_status("copying js", " jquery.atwho.js (#{Jquery::Atwho::Rails::VERSION})", :green) copy_file "javascripts/jquery.atwho/jquery.caret.js", "public/javascripts/jquery.atwho/jquery.caret.js" copy_file "javascripts/jquery.atwho/jquery.atwho.js", "public/javascripts/jquery.atwho/jquery.atwho.js" #copy_file "javascripts/jquery.atwho.min.js", "public/javascripts/jquery.atwho.min.js" end def copy_css say_status("copying css"," jquery.atwho.css",:green) copy_file "stylesheets/jquery.atwho.css", "public/stylesheets/jquery.atwho.css" #copy_file "stylesheets/jquery.atwho.min.css", "public/stylesheets/jquery.atwho.min.css" end end end end else module Atwho module Generators class InstallGenerator < ::Rails::Generators::Base desc "Just show instructions so people will know what to do when mistakenly using generator for Rails 3.1 apps" def do_nothing say_status("deprecated", "You are using Rails 3.1 with the asset pipeline enabled, so this generator is not needed.") say_status("", "The necessary files are already in your asset pipeline.") say_status("", "Just add `//= require jquery.atwho` to your app/assets/javascripts/application.js and app/assets/stylesheets/application.css") say_status("", "If you upgraded your app from Rails 3.0 and still have jquery.atwho.js in your javascripts, be sure to remove them.") say_status("", "If you do not want the asset pipeline enabled, you may turn it off in application.rb and re-run this generator.") # ok, nothing end end end end end jquery-atwho-rails-1.3.2/gemfiles/0000755000076400007640000000000012546671734016132 5ustar pravipravijquery-atwho-rails-1.3.2/gemfiles/rails30.gemfile0000644000076400007640000000021112546671734020733 0ustar pravipravi# This file was generated by Appraisal source "http://ruby.taobao.org" gem "appraisal" gem "rails", "~> 3.0.0" gemspec :path => "../" jquery-atwho-rails-1.3.2/gemfiles/rails30.gemfile.lock0000644000076400007640000000446112546671734021675 0ustar pravipraviPATH remote: ../ specs: jquery-atwho-rails (0.4.11) GEM remote: http://ruby.taobao.org/ specs: abstract (1.0.0) actionmailer (3.0.20) actionpack (= 3.0.20) mail (~> 2.2.19) actionpack (3.0.20) activemodel (= 3.0.20) activesupport (= 3.0.20) builder (~> 2.1.2) erubis (~> 2.6.6) i18n (~> 0.5.0) rack (~> 1.2.5) rack-mount (~> 0.6.14) rack-test (~> 0.5.7) tzinfo (~> 0.3.23) activemodel (3.0.20) activesupport (= 3.0.20) builder (~> 2.1.2) i18n (~> 0.5.0) activerecord (3.0.20) activemodel (= 3.0.20) activesupport (= 3.0.20) arel (~> 2.0.10) tzinfo (~> 0.3.23) activeresource (3.0.20) activemodel (= 3.0.20) activesupport (= 3.0.20) activesupport (3.0.20) appraisal (1.0.0) bundler rake thor (>= 0.14.0) arel (2.0.10) builder (2.1.2) diff-lcs (1.2.5) erubis (2.6.6) abstract (>= 1.0.0) generator_spec (0.9.2) activesupport (>= 3.0.0) railties (>= 3.0.0) i18n (0.5.4) json (1.8.1) mail (2.2.20) activesupport (>= 2.3.6) i18n (>= 0.4.0) mime-types (~> 1.16) treetop (~> 1.4.8) mime-types (1.25.1) polyglot (0.3.5) rack (1.2.8) rack-mount (0.6.14) rack (>= 1.0.0) rack-test (0.5.7) rack (>= 1.0) rails (3.0.20) actionmailer (= 3.0.20) actionpack (= 3.0.20) activerecord (= 3.0.20) activeresource (= 3.0.20) activesupport (= 3.0.20) bundler (~> 1.0) railties (= 3.0.20) railties (3.0.20) actionpack (= 3.0.20) activesupport (= 3.0.20) rake (>= 0.8.7) rdoc (~> 3.4) thor (~> 0.14.4) rake (10.3.2) rdoc (3.12.2) json (~> 1.4) rspec (3.0.0) rspec-core (~> 3.0.0) rspec-expectations (~> 3.0.0) rspec-mocks (~> 3.0.0) rspec-core (3.0.4) rspec-support (~> 3.0.0) rspec-expectations (3.0.4) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.0.0) rspec-mocks (3.0.4) rspec-support (~> 3.0.0) rspec-support (3.0.4) thor (0.14.6) treetop (1.4.15) polyglot polyglot (>= 0.3.1) tzinfo (0.3.41) PLATFORMS ruby DEPENDENCIES appraisal generator_spec jquery-atwho-rails! rails (~> 3.0.0) rspec jquery-atwho-rails-1.3.2/Rakefile0000644000076400007640000000120712546671734016004 0ustar pravipravirequire 'rubygems' require 'bundler/setup' require "bundler/gem_tasks" bower_dir = "bower_components/" desc "sync from At.js" task :sync do puts "* bower install..." puts %x{bower install} end desc "copy assets" task refresh: :sync do puts " * Copying..." source_dir = "bower_components/At.js/dist" dist_dir = "lib/assets" js_dist_dir = "#{dist_dir}/javascripts/jquery.atwho/" FileUtils.copy "#{bower_dir}/Caret.js/dist/jquery.caret.js", js_dist_dir FileUtils.copy "#{source_dir}/js/jquery.atwho.js", js_dist_dir FileUtils.copy "#{source_dir}/css/jquery.atwho.css", "#{dist_dir}/stylesheets/" puts `ls -R #{dist_dir}` end jquery-atwho-rails-1.3.2/.gitignore0000644000076400007640000000010712546671734016325 0ustar pravipravi*.gem .bundle Gemfile.lock pkg/* *.swp tmp/* build/* bower_components/