From 93ac901f12db7e774c7bc5dcc741686d105d97b9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Sep 13 2016 11:07:11 +0000 Subject: Fix atwho This fixes @ and # by bringing back the right version of jquery.carret as well as updating jquery.atwho to 1.5.1 --- diff --git a/pagure/static/atwho/jquery.atwho-1.4.1.css b/pagure/static/atwho/jquery.atwho-1.4.1.css deleted file mode 100644 index a073908..0000000 --- a/pagure/static/atwho/jquery.atwho-1.4.1.css +++ /dev/null @@ -1,49 +0,0 @@ -.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; -} diff --git a/pagure/static/atwho/jquery.atwho-1.4.1.js b/pagure/static/atwho/jquery.atwho-1.4.1.js deleted file mode 100644 index 7f53f12..0000000 --- a/pagure/static/atwho/jquery.atwho-1.4.1.js +++ /dev/null @@ -1,1158 +0,0 @@ -/*! jquery.atwho - v1.4.0 %> -* 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(); - } - _this.isComposing = true; - return null; - }; - })(this)).on('compositionend', (function(_this) { - return function(e) { - _this.isComposing = false; - return null; - }; - })(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: - case KEY_CODE.ENTER: - $.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; - if (e && e.type === 'click' && !this.getOpt('lookUpOnClick')) { - return; - } - if (this.getOpt('suspendOnComposing') && this.app.isComposing) { - return; - } - 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, isString, 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')); - isString = typeof query === 'string'; - if (isString && query.length < this.getOpt('minLen', 0)) { - return; - } - if (isString && 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, isString, lastNode, matched, offset, query, query_content, range; - if (!(range = this._getRange())) { - return; - } - if (!range.collapsed) { - return; - } - 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'); - } - if ($query.length > 0) { - switch (e.which) { - case KEY_CODE.LEFT: - this._setRange('before', $query.get(0), range); - $query.removeClass('atwho-query'); - return; - case KEY_CODE.RIGHT: - this._setRange('after', $query.get(0).nextSibling, range); - $query.removeClass('atwho-query'); - return; - } - } - if ($query.length > 0 && (query_content = $query.attr('data-atwho-at-query'))) { - $query.empty().html(query_content).attr('data-atwho-at-query', null); - this._setRange('after', $query.get(0), range); - } - _range = range.cloneRange(); - _range.setStart(range.startContainer, 0); - matched = this.callbacks("matcher").call(this, this.at, _range.toString(), this.getOpt('startWithSpace')); - isString = typeof matched === 'string'; - if ($query.length === 0 && isString && (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 (isString && matched.length < this.getOpt('minLen', 0)) { - return; - } - if (isString && 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 data, range, suffix, suffixNode; - suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0"; - data = $li.data('item-data'); - this.query.el.removeClass('atwho-query').addClass('atwho-inserted').html(content).attr('data-atwho-at-query', "" + data['atwho-at'] + this.query.text); - if (range = this._getRange()) { - range.setEndAfter(this.query.el[0]); - range.collapse(false); - range.insertNode(suffixNode = this.app.document.createTextNode("\u200D" + 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._stopDelayedCall(); - 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, - minLen: 0, - displayTimeout: 300, - delay: null, - spaceSelectsMatch: false, - tabSelectsMatch: true, - editableAtwhoQueryAttrs: {}, - scrollDuration: 150, - suspendOnComposing: true, - lookUpOnClick: true -}; - -$.fn.atwho.debug = false; - - -})); diff --git a/pagure/static/atwho/jquery.atwho-1.4.1.min.css b/pagure/static/atwho/jquery.atwho-1.4.1.min.css deleted file mode 100644 index 075983d..0000000 --- a/pagure/static/atwho/jquery.atwho-1.4.1.min.css +++ /dev/null @@ -1 +0,0 @@ -.atwho-view{position:absolute;top:0;left:0;display:none;margin-top:18px;background:#fff;color:#000;border:1px solid #DDD;border-radius:3px;box-shadow:0 0 5px rgba(0,0,0,.1);min-width:120px;max-height:200px;overflow:auto;z-index:11110!important}.atwho-view .cur{background:#36F;color:#fff}.atwho-view .cur small{color:#fff}.atwho-view strong{color:#36F}.atwho-view .cur strong{color:#fff;font:700}.atwho-view ul{list-style:none;padding:0;margin:auto}.atwho-view ul li{display:block;padding:5px 10px;border-bottom:1px solid #DDD;cursor:pointer}.atwho-view small{font-size:smaller;color:#777;font-weight:400} \ No newline at end of file diff --git a/pagure/static/atwho/jquery.atwho-1.4.1.min.js b/pagure/static/atwho/jquery.atwho-1.4.1.min.js deleted file mode 100644 index 3488732..0000000 --- a/pagure/static/atwho/jquery.atwho-1.4.1.min.js +++ /dev/null @@ -1 +0,0 @@ -!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(a){return b(a)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){var b,c,d,e,f,g,h,i,j,k,l=[].slice,m=function(a,b){function c(){this.constructor=a}for(var d in b)n.call(b,d)&&(a[d]=b[d]);return c.prototype=b.prototype,a.prototype=new c,a.__super__=b.prototype,a},n={}.hasOwnProperty;b=a,d=function(){function a(a){this.currentFlag=null,this.controllers={},this.aliasMaps={},this.$inputor=b(a),this.setupRootElement(),this.listen()}return a.prototype.createContainer=function(a){var c;return null!=(c=this.$el)&&c.remove(),b(a.body).append(this.$el=b("
    "))},a.prototype.setupRootElement=function(a,c){var d;if(null==c&&(c=!1),a)this.window=a.contentWindow,this.document=a.contentDocument||this.window.document,this.iframe=a;else{this.document=this.$inputor[0].ownerDocument,this.window=this.document.defaultView||this.document.parentWindow;try{this.iframe=this.window.frameElement}catch(e){if(d=e,this.iframe=null,b.fn.atwho.debug)throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n"+d)}}return this.createContainer((this.iframeAsRoot=c)?this.document:document)},a.prototype.controller=function(a){var b,c,d,e;if(this.aliasMaps[a])c=this.controllers[this.aliasMaps[a]];else{e=this.controllers;for(d in e)if(b=e[d],d===a){c=b;break}}return c?c:this.controllers[this.currentFlag]},a.prototype.setContextFor=function(a){return this.currentFlag=a,this},a.prototype.reg=function(a,b){var c,d;return d=(c=this.controllers)[a]||(c[a]=this.$inputor.is("[contentEditable]")?new g(this,a):new j(this,a)),b.alias&&(this.aliasMaps[b.alias]=a),d.init(b),this},a.prototype.listen=function(){return this.$inputor.on("compositionstart",function(a){return function(b){var c;return null!=(c=a.controller())&&c.view.hide(),a.isComposing=!0,null}}(this)).on("compositionend",function(a){return function(b){return a.isComposing=!1,null}}(this)).on("keyup.atwhoInner",function(a){return function(b){return a.onKeyup(b)}}(this)).on("keydown.atwhoInner",function(a){return function(b){return a.onKeydown(b)}}(this)).on("blur.atwhoInner",function(a){return function(b){var c;return(c=a.controller())?(c.expectedQueryCBId=null,c.view.hide(b,c.getOpt("displayTimeout"))):void 0}}(this)).on("click.atwhoInner",function(a){return function(b){return a.dispatch(b)}}(this)).on("scroll.atwhoInner",function(a){return function(){var b;return b=a.$inputor.scrollTop(),function(c){var d,e;return d=c.target.scrollTop,b!==d&&null!=(e=a.controller())&&e.view.hide(c),b=d,!0}}}(this)())},a.prototype.shutdown=function(){var a,b,c;c=this.controllers;for(a in c)b=c[a],b.destroy(),delete this.controllers[a];return this.$inputor.off(".atwhoInner"),this.$el.remove()},a.prototype.dispatch=function(a){var b,c,d,e;d=this.controllers,e=[];for(b in d)c=d[b],e.push(c.lookUp(a));return e},a.prototype.onKeyup=function(a){var c;switch(a.keyCode){case h.ESC:a.preventDefault(),null!=(c=this.controller())&&c.view.hide();break;case h.DOWN:case h.UP:case h.CTRL:case h.ENTER:b.noop();break;case h.P:case h.N:a.ctrlKey||this.dispatch(a);break;default:this.dispatch(a)}},a.prototype.onKeydown=function(a){var c,d;if(d=null!=(c=this.controller())?c.view:void 0,d&&d.visible())switch(a.keyCode){case h.ESC:a.preventDefault(),d.hide(a);break;case h.UP:a.preventDefault(),d.prev();break;case h.DOWN:a.preventDefault(),d.next();break;case h.P:if(!a.ctrlKey)return;a.preventDefault(),d.prev();break;case h.N:if(!a.ctrlKey)return;a.preventDefault(),d.next();break;case h.TAB:case h.ENTER:case h.SPACE:if(!d.visible())return;if(!this.controller().getOpt("spaceSelectsMatch")&&a.keyCode===h.SPACE)return;if(!this.controller().getOpt("tabSelectsMatch")&&a.keyCode===h.TAB)return;d.highlighted()?(a.preventDefault(),d.choose(a)):d.hide(a);break;default:b.noop()}},a}(),e=function(){function a(a,c){this.app=a,this.at=c,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,0===(this.$el=b("#atwho-ground-"+this.id,this.app.$el)).length&&this.app.$el.append(this.$el=b("
    ")),this.model=new i(this),this.view=new k(this)}return a.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},a.prototype.init=function(a){return this.setting=b.extend({},this.setting||b.fn.atwho["default"],a),this.view.init(),this.model.reload(this.setting.data)},a.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},a.prototype.callDefault=function(){var a,c,d;d=arguments[0],a=2<=arguments.length?l.call(arguments,1):[];try{return f[d].apply(this,a)}catch(e){return c=e,b.error(c+" Or maybe At.js doesn't have function "+d)}},a.prototype.trigger=function(a,b){var c,d;return null==b&&(b=[]),b.push(this),c=this.getOpt("alias"),d=c?a+"-"+c+".atwho":a+".atwho",this.$inputor.trigger(d,b)},a.prototype.callbacks=function(a){return this.getOpt("callbacks")[a]||f[a]},a.prototype.getOpt=function(a,b){var c;try{return this.setting[a]}catch(d){return c=d,null}},a.prototype.insertContentFor=function(a){var c,d;return d=this.getOpt("insertTpl"),c=b.extend({},a.data("item-data"),{"atwho-at":this.at}),this.callbacks("tplEval").call(this,d,c,"onInsert")},a.prototype.renderView=function(a){var b;return b=this.getOpt("searchKey"),a=this.callbacks("sorter").call(this,this.query.text,a.slice(0,1001),b),this.view.render(a.slice(0,this.getOpt("limit")))},a.arrayToDefaultHash=function(a){var c,d,e,f;if(!b.isArray(a))return a;for(f=[],c=0,e=a.length;e>c;c++)d=a[c],b.isPlainObject(d)?f.push(d):f.push({name:d});return f},a.prototype.lookUp=function(a){var b,c;if((!a||"click"!==a.type||this.getOpt("lookUpOnClick"))&&(!this.getOpt("suspendOnComposing")||!this.app.isComposing))return(b=this.catchQuery(a))?(this.app.setContextFor(this.at),(c=this.getOpt("delay"))?this._delayLookUp(b,c):this._lookUp(b),b):(this.expectedQueryCBId=null,b)},a.prototype._delayLookUp=function(a,b){var c,d;return c=Date.now?Date.now():(new Date).getTime(),this.previousCallTime||(this.previousCallTime=c),d=b-(c-this.previousCallTime),d>0&&b>d?(this.previousCallTime=c,this._stopDelayedCall(),this.delayedCallTimeout=setTimeout(function(b){return function(){return b.previousCallTime=0,b.delayedCallTimeout=null,b._lookUp(a)}}(this),b)):(this._stopDelayedCall(),this.previousCallTime!==c&&(this.previousCallTime=0),this._lookUp(a))},a.prototype._stopDelayedCall=function(){return this.delayedCallTimeout?(clearTimeout(this.delayedCallTimeout),this.delayedCallTimeout=null):void 0},a.prototype._generateQueryCBId=function(){return{}},a.prototype._lookUp=function(a){var c;return c=function(a,b){return a===this.expectedQueryCBId?b&&b.length>0?this.renderView(this.constructor.arrayToDefaultHash(b)):this.view.hide():void 0},this.expectedQueryCBId=this._generateQueryCBId(),this.model.query(a.text,b.proxy(c,this,this.expectedQueryCBId))},a}(),j=function(a){function c(){return c.__super__.constructor.apply(this,arguments)}return m(c,a),c.prototype.catchQuery=function(){var a,b,c,d,e,f,g;return b=this.$inputor.val(),a=this.$inputor.caret("pos",{iframe:this.app.iframe}),g=b.slice(0,a),e=this.callbacks("matcher").call(this,this.at,g,this.getOpt("startWithSpace")),d="string"==typeof e,d&&e.length0?a.getRangeAt(0):void 0},c.prototype._setRange=function(a,c,d){return null==d&&(d=this._getRange()),d?(c=b(c)[0],"after"===a?(d.setEndAfter(c),d.setStartAfter(c)):(d.setEndBefore(c),d.setStartBefore(c)),d.collapse(!1),this._clearRange(d)):void 0},c.prototype._clearRange=function(a){var b;return null==a&&(a=this._getRange()),b=this.app.window.getSelection(),null==this.ctrl_a_pressed?(b.removeAllRanges(),b.addRange(a)):void 0},c.prototype._movingEvent=function(a){var b;return"click"===a.type||(b=a.which)===h.RIGHT||b===h.LEFT||b===h.UP||b===h.DOWN},c.prototype._unwrap=function(a){var c;return a=b(a).unwrap().get(0),(c=a.nextSibling)&&c.nodeValue&&(a.nodeValue+=c.nodeValue,b(c).remove()),a},c.prototype.catchQuery=function(a){var c,d,e,f,g,i,j,k,l,m,n,o;if((o=this._getRange())&&o.collapsed){if(a.which===h.ENTER)return(d=b(o.startContainer).closest(".atwho-query")).contents().unwrap(),d.is(":empty")&&d.remove(),(d=b(".atwho-query",this.app.document)).text(d.text()).contents().last().unwrap(),void this._clearRange();if(/firefox/i.test(navigator.userAgent)){if(b(o.startContainer).is(this.$inputor))return void this._clearRange();a.which===h.BACKSPACE&&o.startContainer.nodeType===document.ELEMENT_NODE&&(l=o.startOffset-1)>=0?(e=o.cloneRange(),e.setStart(o.startContainer,l),b(e.cloneContents()).contents().last().is(".atwho-inserted")&&(g=b(o.startContainer).contents().get(l),this._setRange("after",b(g).contents().last()))):a.which===h.LEFT&&o.startContainer.nodeType===document.TEXT_NODE&&(c=b(o.startContainer.previousSibling),c.is(".atwho-inserted")&&0===o.startOffset&&this._setRange("after",c.contents().last()))}if(b(o.startContainer).closest(".atwho-inserted").addClass("atwho-query").siblings().removeClass("atwho-query"),(d=b(".atwho-query",this.app.document)).length>0&&d.is(":empty")&&0===d.text().length&&d.remove(),this._movingEvent(a)||d.removeClass("atwho-inserted"),d.length>0)switch(a.which){case h.LEFT:return this._setRange("before",d.get(0),o),void d.removeClass("atwho-query");case h.RIGHT:return this._setRange("after",d.get(0).nextSibling,o),void d.removeClass("atwho-query")}if(d.length>0&&(n=d.attr("data-atwho-at-query"))&&(d.empty().html(n).attr("data-atwho-at-query",null),this._setRange("after",d.get(0),o)),e=o.cloneRange(),e.setStart(o.startContainer,0),k=this.callbacks("matcher").call(this,this.at,e.toString(),this.getOpt("startWithSpace")),i="string"==typeof k,0===d.length&&i&&(f=o.startOffset-this.at.length-k.length)>=0&&(o.setStart(o.startContainer,f),d=b("",this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass("atwho-query"),o.surroundContents(d.get(0)),j=d.contents().last().get(0),/firefox/i.test(navigator.userAgent)?(o.setStart(j,j.length),o.setEnd(j,j.length),this._clearRange(o)):this._setRange("after",j,o)),!(i&&k.length=0&&(this._movingEvent(a)&&d.hasClass("atwho-inserted")?d.removeClass("atwho-query"):!1!==this.callbacks("afterMatchFailed").call(this,this.at,d)&&this._setRange("after",this._unwrap(d.text(d.text()).contents().first()))),null)}},c.prototype.rect=function(){var a,c,d;return d=this.query.el.offset(),this.app.iframe&&!this.app.iframeAsRoot&&(c=(a=b(this.app.iframe)).offset(),d.left+=c.left-this.$inputor.scrollLeft(),d.top+=c.top-this.$inputor.scrollTop()),d.bottom=d.top+this.query.el.height(),d},c.prototype.insert=function(a,b){var c,d,e,f;return e=""===(e=this.getOpt("suffix"))?e:e||" ",c=b.data("item-data"),this.query.el.removeClass("atwho-query").addClass("atwho-inserted").html(a).attr("data-atwho-at-query",""+c["atwho-at"]+this.query.text),(d=this._getRange())&&(d.setEndAfter(this.query.el[0]),d.collapse(!1),d.insertNode(f=this.app.document.createTextNode("‍"+e)),this._setRange("after",f,d)),this.$inputor.is(":focus")||this.$inputor.focus(),this.$inputor.change()},c}(e),i=function(){function a(a){this.context=a,this.at=this.context.at,this.storage=this.context.$inputor}return a.prototype.destroy=function(){return this.storage.data(this.at,null)},a.prototype.saved=function(){return this.fetch()>0},a.prototype.query=function(a,b){var c,d,e;return d=this.fetch(),e=this.context.getOpt("searchKey"),d=this.context.callbacks("filter").call(this.context,a,d,e)||[],c=this.context.callbacks("remoteFilter"),d.length>0||!c&&0===d.length?b(d):c.call(this.context,a,b)},a.prototype.fetch=function(){return this.storage.data(this.at)||[]},a.prototype.save=function(a){return this.storage.data(this.at,this.context.callbacks("beforeSave").call(this.context,a||[]))},a.prototype.load=function(a){return!this.saved()&&a?this._load(a):void 0},a.prototype.reload=function(a){return this._load(a)},a.prototype._load=function(a){return"string"==typeof a?b.ajax(a,{dataType:"json"}).done(function(a){return function(b){return a.save(b)}}(this)):this.save(a)},a}(),k=function(){function a(a){this.context=a,this.$el=b("
      "),this.timeoutID=null,this.context.$el.append(this.$el),this.bindEvent()}return a.prototype.init=function(){var a;return a=this.context.getOpt("alias")||this.context.at.charCodeAt(0),this.$el.attr({id:"at-view-"+a})},a.prototype.destroy=function(){return this.$el.remove()},a.prototype.bindEvent=function(){var a;return a=this.$el.find("ul"),a.on("mouseenter.atwho-view","li",function(c){return a.find(".cur").removeClass("cur"),b(c.currentTarget).addClass("cur")}).on("click.atwho-view","li",function(c){return function(d){return a.find(".cur").removeClass("cur"),b(d.currentTarget).addClass("cur"),c.choose(d),d.preventDefault()}}(this))},a.prototype.visible=function(){return this.$el.is(":visible")},a.prototype.highlighted=function(){return this.$el.find(".cur").length>0},a.prototype.choose=function(a){var b,c;return(b=this.$el.find(".cur")).length&&(c=this.context.insertContentFor(b),this.context._stopDelayedCall(),this.context.insert(this.context.callbacks("beforeInsert").call(this.context,c,b),b),this.context.trigger("inserted",[b,a]),this.hide(a)),this.context.getOpt("hideWithoutSuffix")?this.stopShowing=!0:void 0},a.prototype.reposition=function(a){var c,d,e,f;return c=this.context.app.iframeAsRoot?this.context.app.window:window,a.bottom+this.$el.height()-b(c).scrollTop()>b(c).height()&&(a.bottom=a.top-this.$el.height()),a.left>(e=b(c).width()-this.$el.width()-5)&&(a.left=e),d={left:a.left,top:a.bottom},null!=(f=this.context.callbacks("beforeReposition"))&&f.call(this.context,d),this.$el.offset(d),this.context.trigger("reposition",[d])},a.prototype.next=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.next(),b.length||(b=this.$el.find("li:first")),b.addClass("cur"),this.scrollTop(Math.max(0,a.innerHeight()*(b.index()+2)-this.$el.height()))},a.prototype.prev=function(){var a,b;return a=this.$el.find(".cur").removeClass("cur"),b=a.prev(),b.length||(b=this.$el.find("li:last")),b.addClass("cur"),this.scrollTop(Math.max(0,a.innerHeight()*(b.index()+2)-this.$el.height()))},a.prototype.scrollTop=function(a){var b;return b=this.context.getOpt("scrollDuration"),b?this.$el.animate({scrollTop:a},b):this.$el.scrollTop(a)},a.prototype.show=function(){var a;return this.stopShowing?void(this.stopShowing=!1):(this.visible()||(this.$el.show(),this.$el.scrollTop(0),this.context.trigger("shown")),(a=this.context.rect())?this.reposition(a):void 0)},a.prototype.hide=function(a,b){var c;if(this.visible())return isNaN(b)?(this.$el.hide(),this.context.trigger("hidden",[a])):(c=function(a){return function(){return a.hide()}}(this),clearTimeout(this.timeoutID),this.timeoutID=setTimeout(c,b))},a.prototype.render=function(a){var c,d,e,f,g,h,i;if(!(b.isArray(a)&&a.length>0))return void this.hide();for(this.$el.find("ul").empty(),d=this.$el.find("ul"),i=this.context.getOpt("displayTpl"),e=0,g=a.length;g>e;e++)f=a[e],f=b.extend({},f,{"atwho-at":this.context.at}),h=this.context.callbacks("tplEval").call(this.context,i,f,"onDisplay"),c=b(this.context.callbacks("highlighter").call(this.context,h,this.context.query.text)),c.data("item-data",f),d.append(c);return this.show(),this.context.getOpt("highlightFirst")?d.find("li:first").addClass("cur"):void 0},a}(),h={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},f={beforeSave:function(a){return e.arrayToDefaultHash(a)},matcher:function(a,b,c,d){var e,f,g,h,i;return a=a.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),c&&(a="(?:^|\\s)"+a),e=decodeURI("%C3%80"),f=decodeURI("%C3%BF"),i=d?" ":"",h=new RegExp(a+"([A-Za-z"+e+"-"+f+"0-9_"+i+"'.+-]*)$|"+a+"([^\\x00-\\xff]*)$","gi"),g=h.exec(b),g?g[2]||g[1]:null},filter:function(a,b,c){var d,e,f,g;for(d=[],e=0,g=b.length;g>e;e++)f=b[e],~new String(f[c]).toLowerCase().indexOf(a.toLowerCase())&&d.push(f);return d},remoteFilter:null,sorter:function(a,b,c){var d,e,f,g;if(!a)return b;for(d=[],e=0,g=b.length;g>e;e++)f=b[e],f.atwho_order=new String(f[c]).toLowerCase().indexOf(a.toLowerCase()),f.atwho_order>-1&&d.push(f);return d.sort(function(a,b){return a.atwho_order-b.atwho_order})},tplEval:function(a,b){var c,d;d=a;try{return"string"!=typeof a&&(d=a(b)),d.replace(/\$\{([^\}]*)\}/g,function(a,c,d){return b[c]})}catch(e){return c=e,""}},highlighter:function(a,b){var c;return b?(c=new RegExp(">\\s*(\\w*?)("+b.replace("+","\\+")+")(\\w*)\\s*<","ig"),a.replace(c,function(a,b,c,d){return"> "+b+""+c+""+d+" <"})):a},beforeInsert:function(a,b){return a},beforeReposition:function(a){return a},afterMatchFailed:function(a,b){}},c={load:function(a,b){var c;return(c=this.controller(a))?c.model.load(b):void 0},isSelecting:function(){var a;return!!(null!=(a=this.controller())?a.view.visible():void 0)},hide:function(){var a;return null!=(a=this.controller())?a.view.hide():void 0},reposition:function(){var a;return(a=this.controller())?a.view.reposition(a.rect()):void 0},setIframe:function(a,b){return this.setupRootElement(a,b),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},b.fn.atwho=function(a){var e,f;return e=arguments,f=null,this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function(){var g,h;return(h=(g=b(this)).data("atwho"))||g.data("atwho",h=new d(this)),"object"!=typeof a&&a?c[a]&&h?f=c[a].apply(h,Array.prototype.slice.call(e,1)):b.error("Method "+a+" does not exist on jQuery.atwho"):h.reg(a.at,a)}),null!=f?f:this},b.fn.atwho["default"]={at:void 0,alias:void 0,data:null,displayTpl:"
    • ${name}
    • ",insertTpl:"${atwho-at}${name}",callbacks:f,searchKey:"name",suffix:void 0,hideWithoutSuffix:!1,startWithSpace:!0,highlightFirst:!0,limit:5,maxLen:20,minLen:0,displayTimeout:300,delay:null,spaceSelectsMatch:!1,tabSelectsMatch:!0,editableAtwhoQueryAttrs:{},scrollDuration:150,suspendOnComposing:!0,lookUpOnClick:!0},b.fn.atwho.debug=!1}); \ No newline at end of file diff --git a/pagure/static/atwho/jquery.atwho-1.5.1.css b/pagure/static/atwho/jquery.atwho-1.5.1.css new file mode 100644 index 0000000..dad94ed --- /dev/null +++ b/pagure/static/atwho/jquery.atwho-1.5.1.css @@ -0,0 +1,72 @@ +.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; + z-index: 11110 !important; +} + +.atwho-view .atwho-header { + padding: 5px; + margin: 5px; + cursor: pointer; + border-bottom: solid 1px #eaeff1; + color: #6f8092; + font-size: 11px; + font-weight: bold; +} + +.atwho-view .atwho-header .small { + color: #6f8092; + float: right; + padding-top: 2px; + margin-right: -5px; + font-size: 12px; + font-weight: normal; +} + +.atwho-view .atwho-header:hover { + cursor: default; +} + +.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; + max-height: 200px; + overflow-y: 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; +} diff --git a/pagure/static/atwho/jquery.atwho-1.5.1.js b/pagure/static/atwho/jquery.atwho-1.5.1.js new file mode 100644 index 0000000..0d295eb --- /dev/null +++ b/pagure/static/atwho/jquery.atwho-1.5.1.js @@ -0,0 +1,1202 @@ +/** + * at.js - 1.5.1 + * Copyright (c) 2016 chord.luo ; + * Homepage: http://ichord.github.com/At.js + * License: 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 ($) { +var DEFAULT_CALLBACKS, KEY_CODE; + +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, error1, template; + template = tpl; + try { + if (typeof tpl !== 'string') { + template = tpl(map); + } + return template.replace(/\$\{([^\}]*)\}/g, function(tag, key, pos) { + return map[key]; + }); + } catch (error1) { + error = error1; + 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, e) { + return value; + }, + beforeReposition: function(offset) { + return offset; + }, + afterMatchFailed: function(at, el) {} +}; + +var App; + +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, error1; + 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 (error1) { + error = error1; + 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(); + } + _this.isComposing = true; + return null; + }; + })(this)).on('compositionend', (function(_this) { + return function(e) { + _this.isComposing = false; + setTimeout(function(e) { + return _this.dispatch(e); + }); + return null; + }; + })(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: + case KEY_CODE.ENTER: + $.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; + +})(); + +var Controller, + slice = [].slice; + +Controller = (function() { + Controller.prototype.uid = function() { + return (Math.random().toString(16) + "000000000").substr(2, 8) + (new Date().getTime()); + }; + + function Controller(app, at1) { + this.app = app; + 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, error1, funcName; + funcName = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : []; + try { + return DEFAULT_CALLBACKS[funcName].apply(this, args); + } catch (error1) { + error = error1; + 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, error1; + try { + return this.setting[at]; + } catch (error1) { + e = error1; + 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; + if (e && e.type === 'click' && !this.getOpt('lookUpOnClick')) { + return; + } + if (this.getOpt('suspendOnComposing') && this.app.isComposing) { + return; + } + 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; + +})(); + +var TextareaController, + 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; + +TextareaController = (function(superClass) { + extend(TextareaController, superClass); + + function TextareaController() { + return TextareaController.__super__.constructor.apply(this, arguments); + } + + TextareaController.prototype.catchQuery = function() { + var caretPos, content, end, isString, 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'), this.getOpt("acceptSpaceBar")); + isString = typeof query === 'string'; + if (isString && query.length < this.getOpt('minLen', 0)) { + return; + } + if (isString && 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); + +var EditableController, + 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; + +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, isString, lastNode, matched, offset, query, query_content, range; + if (!(range = this._getRange())) { + return; + } + if (!range.collapsed) { + return; + } + 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'); + } + if ($query.length > 0) { + switch (e.which) { + case KEY_CODE.LEFT: + this._setRange('before', $query.get(0), range); + $query.removeClass('atwho-query'); + return; + case KEY_CODE.RIGHT: + this._setRange('after', $query.get(0).nextSibling, range); + $query.removeClass('atwho-query'); + return; + } + } + if ($query.length > 0 && (query_content = $query.attr('data-atwho-at-query'))) { + $query.empty().html(query_content).attr('data-atwho-at-query', null); + this._setRange('after', $query.get(0), range); + } + _range = range.cloneRange(); + _range.setStart(range.startContainer, 0); + matched = this.callbacks("matcher").call(this, this.at, _range.toString(), this.getOpt('startWithSpace'), this.getOpt("acceptSpaceBar")); + isString = typeof matched === 'string'; + if ($query.length === 0 && isString && (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 (isString && matched.length < this.getOpt('minLen', 0)) { + return; + } + if (isString && 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 data, range, suffix, suffixNode; + if (!this.$inputor.is(':focus')) { + this.$inputor.focus(); + } + suffix = (suffix = this.getOpt('suffix')) === "" ? suffix : suffix || "\u00A0"; + data = $li.data('item-data'); + this.query.el.removeClass('atwho-query').addClass('atwho-inserted').html(content).attr('data-atwho-at-query', "" + data['atwho-at'] + this.query.text); + if (range = this._getRange()) { + range.setEndAfter(this.query.el[0]); + range.collapse(false); + range.insertNode(suffixNode = this.app.document.createTextNode("\u200D" + suffix)); + this._setRange('after', suffixNode, range); + } + if (!this.$inputor.is(':focus')) { + this.$inputor.focus(); + } + return this.$inputor.change(); + }; + + return EditableController; + +})(Controller); + +var Model; + +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; + +})(); + +var View; + +View = (function() { + function View(context) { + this.context = context; + this.$el = $("
        "); + this.$elUl = this.$el.children(); + this.timeoutID = null; + this.context.$el.append(this.$el); + this.bindEvent(); + } + + View.prototype.init = function() { + var header_tpl, id; + id = this.context.getOpt("alias") || this.context.at.charCodeAt(0); + header_tpl = this.context.getOpt("headerTpl"); + if (header_tpl && this.$el.children().length === 1) { + this.$el.prepend(header_tpl); + } + return this.$el.attr({ + 'id': "at-view-" + id + }); + }; + + View.prototype.destroy = function() { + return this.$el.remove(); + }; + + View.prototype.bindEvent = function() { + var $menu, lastCoordX, lastCoordY; + $menu = this.$el.find('ul'); + lastCoordX = 0; + lastCoordY = 0; + return $menu.on('mousemove.atwho-view', 'li', (function(_this) { + return function(e) { + var $cur; + if (lastCoordX === e.clientX && lastCoordY === e.clientY) { + return; + } + lastCoordX = e.clientX; + lastCoordY = e.clientY; + $cur = $(e.currentTarget); + if ($cur.hasClass('cur')) { + return; + } + $menu.find('.cur').removeClass('cur'); + return $cur.addClass('cur'); + }; + })(this)).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._stopDelayedCall(); + this.context.insert(this.context.callbacks("beforeInsert").call(this.context, content, $li, e), $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, nextEl, offset; + cur = this.$el.find('.cur').removeClass('cur'); + next = cur.next(); + if (!next.length) { + next = this.$el.find('li:first'); + } + next.addClass('cur'); + nextEl = next[0]; + offset = nextEl.offsetTop + nextEl.offsetHeight + (nextEl.nextSibling ? nextEl.nextSibling.offsetHeight : 0); + return this.scrollTop(Math.max(0, offset - this.$el.height())); + }; + + View.prototype.prev = function() { + var cur, offset, prev, prevEl; + cur = this.$el.find('.cur').removeClass('cur'); + prev = cur.prev(); + if (!prev.length) { + prev = this.$el.find('li:last'); + } + prev.addClass('cur'); + prevEl = prev[0]; + offset = prevEl.offsetTop + prevEl.offsetHeight + (prevEl.nextSibling ? prevEl.nextSibling.offsetHeight : 0); + return this.scrollTop(Math.max(0, offset - this.$el.height())); + }; + + View.prototype.scrollTop = function(scrollTop) { + var scrollDuration; + scrollDuration = this.context.getOpt('scrollDuration'); + if (scrollDuration) { + return this.$elUl.animate({ + scrollTop: scrollTop + }, scrollDuration); + } else { + return this.$elUl.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; + +})(); + +var Api; + +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}", + headerTpl: null, + callbacks: DEFAULT_CALLBACKS, + searchKey: "name", + suffix: void 0, + hideWithoutSuffix: false, + startWithSpace: true, + acceptSpaceBar: false, + highlightFirst: true, + limit: 5, + maxLen: 20, + minLen: 0, + displayTimeout: 300, + delay: null, + spaceSelectsMatch: false, + tabSelectsMatch: true, + editableAtwhoQueryAttrs: {}, + scrollDuration: 150, + suspendOnComposing: true, + lookUpOnClick: true +}; + +$.fn.atwho.debug = false; + +})); diff --git a/pagure/static/atwho/jquery.atwho-1.5.1.min.css b/pagure/static/atwho/jquery.atwho-1.5.1.min.css new file mode 100644 index 0000000..f770dc7 --- /dev/null +++ b/pagure/static/atwho/jquery.atwho-1.5.1.min.css @@ -0,0 +1 @@ +.atwho-view{position:absolute;top:0;left:0;display:none;margin-top:18px;background:#fff;color:#000;border:1px solid #DDD;border-radius:3px;box-shadow:0 0 5px rgba(0,0,0,.1);min-width:120px;z-index:11110!important}.atwho-view .atwho-header{padding:5px;margin:5px;cursor:pointer;border-bottom:solid 1px #eaeff1;color:#6f8092;font-size:11px;font-weight:700}.atwho-view .atwho-header .small{color:#6f8092;float:right;padding-top:2px;margin-right:-5px;font-size:12px;font-weight:400}.atwho-view .atwho-header:hover{cursor:default}.atwho-view .cur{background:#36F;color:#fff}.atwho-view .cur small{color:#fff}.atwho-view strong{color:#36F}.atwho-view .cur strong{color:#fff;font:700}.atwho-view ul{list-style:none;padding:0;margin:auto;max-height:200px;overflow-y:auto}.atwho-view ul li{display:block;padding:5px 10px;border-bottom:1px solid #DDD;cursor:pointer}.atwho-view small{font-size:smaller;color:#777;font-weight:400} \ No newline at end of file diff --git a/pagure/static/atwho/jquery.atwho-1.5.1.min.js b/pagure/static/atwho/jquery.atwho-1.5.1.min.js new file mode 100644 index 0000000..71e9a10 --- /dev/null +++ b/pagure/static/atwho/jquery.atwho-1.5.1.min.js @@ -0,0 +1 @@ +!function(t,e){"function"==typeof define&&define.amd?define(["jquery"],function(t){return e(t)}):"object"==typeof exports?module.exports=e(require("jquery")):e(jQuery)}(this,function(t){var e,i;i={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},e={beforeSave:function(t){return r.arrayToDefaultHash(t)},matcher:function(t,e,i,n){var r,o,s,a,h;return t=t.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,"\\$&"),i&&(t="(?:^|\\s)"+t),r=decodeURI("%C3%80"),o=decodeURI("%C3%BF"),h=n?" ":"",a=new RegExp(t+"([A-Za-z"+r+"-"+o+"0-9_"+h+"'.+-]*)$|"+t+"([^\\x00-\\xff]*)$","gi"),s=a.exec(e),s?s[2]||s[1]:null},filter:function(t,e,i){var n,r,o,s;for(n=[],r=0,s=e.length;s>r;r++)o=e[r],~new String(o[i]).toLowerCase().indexOf(t.toLowerCase())&&n.push(o);return n},remoteFilter:null,sorter:function(t,e,i){var n,r,o,s;if(!t)return e;for(n=[],r=0,s=e.length;s>r;r++)o=e[r],o.atwho_order=new String(o[i]).toLowerCase().indexOf(t.toLowerCase()),o.atwho_order>-1&&n.push(o);return n.sort(function(t,e){return t.atwho_order-e.atwho_order})},tplEval:function(t,e){var i,n,r;r=t;try{return"string"!=typeof t&&(r=t(e)),r.replace(/\$\{([^\}]*)\}/g,function(t,i,n){return e[i]})}catch(n){return i=n,""}},highlighter:function(t,e){var i;return e?(i=new RegExp(">\\s*(\\w*?)("+e.replace("+","\\+")+")(\\w*)\\s*<","ig"),t.replace(i,function(t,e,i,n){return"> "+e+""+i+""+n+" <"})):t},beforeInsert:function(t,e,i){return t},beforeReposition:function(t){return t},afterMatchFailed:function(t,e){}};var n;n=function(){function e(e){this.currentFlag=null,this.controllers={},this.aliasMaps={},this.$inputor=t(e),this.setupRootElement(),this.listen()}return e.prototype.createContainer=function(e){var i;return null!=(i=this.$el)&&i.remove(),t(e.body).append(this.$el=t("
        "))},e.prototype.setupRootElement=function(e,i){var n,r;if(null==i&&(i=!1),e)this.window=e.contentWindow,this.document=e.contentDocument||this.window.document,this.iframe=e;else{this.document=this.$inputor[0].ownerDocument,this.window=this.document.defaultView||this.document.parentWindow;try{this.iframe=this.window.frameElement}catch(r){if(n=r,this.iframe=null,t.fn.atwho.debug)throw new Error("iframe auto-discovery is failed.\nPlease use `setIframe` to set the target iframe manually.\n"+n)}}return this.createContainer((this.iframeAsRoot=i)?this.document:document)},e.prototype.controller=function(t){var e,i,n,r;if(this.aliasMaps[t])i=this.controllers[this.aliasMaps[t]];else{r=this.controllers;for(n in r)if(e=r[n],n===t){i=e;break}}return i?i:this.controllers[this.currentFlag]},e.prototype.setContextFor=function(t){return this.currentFlag=t,this},e.prototype.reg=function(t,e){var i,n;return n=(i=this.controllers)[t]||(i[t]=this.$inputor.is("[contentEditable]")?new l(this,t):new s(this,t)),e.alias&&(this.aliasMaps[e.alias]=t),n.init(e),this},e.prototype.listen=function(){return this.$inputor.on("compositionstart",function(t){return function(e){var i;return null!=(i=t.controller())&&i.view.hide(),t.isComposing=!0,null}}(this)).on("compositionend",function(t){return function(e){return t.isComposing=!1,setTimeout(function(e){return t.dispatch(e)}),null}}(this)).on("keyup.atwhoInner",function(t){return function(e){return t.onKeyup(e)}}(this)).on("keydown.atwhoInner",function(t){return function(e){return t.onKeydown(e)}}(this)).on("blur.atwhoInner",function(t){return function(e){var i;return(i=t.controller())?(i.expectedQueryCBId=null,i.view.hide(e,i.getOpt("displayTimeout"))):void 0}}(this)).on("click.atwhoInner",function(t){return function(e){return t.dispatch(e)}}(this)).on("scroll.atwhoInner",function(t){return function(){var e;return e=t.$inputor.scrollTop(),function(i){var n,r;return n=i.target.scrollTop,e!==n&&null!=(r=t.controller())&&r.view.hide(i),e=n,!0}}}(this)())},e.prototype.shutdown=function(){var t,e,i;i=this.controllers;for(t in i)e=i[t],e.destroy(),delete this.controllers[t];return this.$inputor.off(".atwhoInner"),this.$el.remove()},e.prototype.dispatch=function(t){var e,i,n,r;n=this.controllers,r=[];for(e in n)i=n[e],r.push(i.lookUp(t));return r},e.prototype.onKeyup=function(e){var n;switch(e.keyCode){case i.ESC:e.preventDefault(),null!=(n=this.controller())&&n.view.hide();break;case i.DOWN:case i.UP:case i.CTRL:case i.ENTER:t.noop();break;case i.P:case i.N:e.ctrlKey||this.dispatch(e);break;default:this.dispatch(e)}},e.prototype.onKeydown=function(e){var n,r;if(r=null!=(n=this.controller())?n.view:void 0,r&&r.visible())switch(e.keyCode){case i.ESC:e.preventDefault(),r.hide(e);break;case i.UP:e.preventDefault(),r.prev();break;case i.DOWN:e.preventDefault(),r.next();break;case i.P:if(!e.ctrlKey)return;e.preventDefault(),r.prev();break;case i.N:if(!e.ctrlKey)return;e.preventDefault(),r.next();break;case i.TAB:case i.ENTER:case i.SPACE:if(!r.visible())return;if(!this.controller().getOpt("spaceSelectsMatch")&&e.keyCode===i.SPACE)return;if(!this.controller().getOpt("tabSelectsMatch")&&e.keyCode===i.TAB)return;r.highlighted()?(e.preventDefault(),r.choose(e)):r.hide(e);break;default:t.noop()}},e}();var r,o=[].slice;r=function(){function i(e,i){this.app=e,this.at=i,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,0===(this.$el=t("#atwho-ground-"+this.id,this.app.$el)).length&&this.app.$el.append(this.$el=t("
        ")),this.model=new u(this),this.view=new c(this)}return i.prototype.uid=function(){return(Math.random().toString(16)+"000000000").substr(2,8)+(new Date).getTime()},i.prototype.init=function(e){return this.setting=t.extend({},this.setting||t.fn.atwho["default"],e),this.view.init(),this.model.reload(this.setting.data)},i.prototype.destroy=function(){return this.trigger("beforeDestroy"),this.model.destroy(),this.view.destroy(),this.$el.remove()},i.prototype.callDefault=function(){var i,n,r,s;s=arguments[0],i=2<=arguments.length?o.call(arguments,1):[];try{return e[s].apply(this,i)}catch(r){return n=r,t.error(n+" Or maybe At.js doesn't have function "+s)}},i.prototype.trigger=function(t,e){var i,n;return null==e&&(e=[]),e.push(this),i=this.getOpt("alias"),n=i?t+"-"+i+".atwho":t+".atwho",this.$inputor.trigger(n,e)},i.prototype.callbacks=function(t){return this.getOpt("callbacks")[t]||e[t]},i.prototype.getOpt=function(t,e){var i,n;try{return this.setting[t]}catch(n){return i=n,null}},i.prototype.insertContentFor=function(e){var i,n;return n=this.getOpt("insertTpl"),i=t.extend({},e.data("item-data"),{"atwho-at":this.at}),this.callbacks("tplEval").call(this,n,i,"onInsert")},i.prototype.renderView=function(t){var e;return e=this.getOpt("searchKey"),t=this.callbacks("sorter").call(this,this.query.text,t.slice(0,1001),e),this.view.render(t.slice(0,this.getOpt("limit")))},i.arrayToDefaultHash=function(e){var i,n,r,o;if(!t.isArray(e))return e;for(o=[],i=0,r=e.length;r>i;i++)n=e[i],t.isPlainObject(n)?o.push(n):o.push({name:n});return o},i.prototype.lookUp=function(t){var e,i;if((!t||"click"!==t.type||this.getOpt("lookUpOnClick"))&&(!this.getOpt("suspendOnComposing")||!this.app.isComposing))return(e=this.catchQuery(t))?(this.app.setContextFor(this.at),(i=this.getOpt("delay"))?this._delayLookUp(e,i):this._lookUp(e),e):(this.expectedQueryCBId=null,e)},i.prototype._delayLookUp=function(t,e){var i,n;return i=Date.now?Date.now():(new Date).getTime(),this.previousCallTime||(this.previousCallTime=i),n=e-(i-this.previousCallTime),n>0&&e>n?(this.previousCallTime=i,this._stopDelayedCall(),this.delayedCallTimeout=setTimeout(function(e){return function(){return e.previousCallTime=0,e.delayedCallTimeout=null,e._lookUp(t)}}(this),e)):(this._stopDelayedCall(),this.previousCallTime!==i&&(this.previousCallTime=0),this._lookUp(t))},i.prototype._stopDelayedCall=function(){return this.delayedCallTimeout?(clearTimeout(this.delayedCallTimeout),this.delayedCallTimeout=null):void 0},i.prototype._generateQueryCBId=function(){return{}},i.prototype._lookUp=function(e){var i;return i=function(t,e){return t===this.expectedQueryCBId?e&&e.length>0?this.renderView(this.constructor.arrayToDefaultHash(e)):this.view.hide():void 0},this.expectedQueryCBId=this._generateQueryCBId(),this.model.query(e.text,t.proxy(i,this,this.expectedQueryCBId))},i}();var s,a=function(t,e){function i(){this.constructor=t}for(var n in e)h.call(e,n)&&(t[n]=e[n]);return i.prototype=e.prototype,t.prototype=new i,t.__super__=e.prototype,t},h={}.hasOwnProperty;s=function(e){function i(){return i.__super__.constructor.apply(this,arguments)}return a(i,e),i.prototype.catchQuery=function(){var t,e,i,n,r,o,s;return e=this.$inputor.val(),t=this.$inputor.caret("pos",{iframe:this.app.iframe}),s=e.slice(0,t),r=this.callbacks("matcher").call(this,this.at,s,this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar")),n="string"==typeof r,n&&r.length0?t.getRangeAt(0):void 0},n.prototype._setRange=function(e,i,n){return null==n&&(n=this._getRange()),n?(i=t(i)[0],"after"===e?(n.setEndAfter(i),n.setStartAfter(i)):(n.setEndBefore(i),n.setStartBefore(i)),n.collapse(!1),this._clearRange(n)):void 0},n.prototype._clearRange=function(t){var e;return null==t&&(t=this._getRange()),e=this.app.window.getSelection(),null==this.ctrl_a_pressed?(e.removeAllRanges(),e.addRange(t)):void 0},n.prototype._movingEvent=function(t){var e;return"click"===t.type||(e=t.which)===i.RIGHT||e===i.LEFT||e===i.UP||e===i.DOWN},n.prototype._unwrap=function(e){var i;return e=t(e).unwrap().get(0),(i=e.nextSibling)&&i.nodeValue&&(e.nodeValue+=i.nodeValue,t(i).remove()),e},n.prototype.catchQuery=function(e){var n,r,o,s,a,h,l,u,c,p,f,d;if((d=this._getRange())&&d.collapsed){if(e.which===i.ENTER)return(r=t(d.startContainer).closest(".atwho-query")).contents().unwrap(),r.is(":empty")&&r.remove(),(r=t(".atwho-query",this.app.document)).text(r.text()).contents().last().unwrap(),void this._clearRange();if(/firefox/i.test(navigator.userAgent)){if(t(d.startContainer).is(this.$inputor))return void this._clearRange();e.which===i.BACKSPACE&&d.startContainer.nodeType===document.ELEMENT_NODE&&(c=d.startOffset-1)>=0?(o=d.cloneRange(),o.setStart(d.startContainer,c),t(o.cloneContents()).contents().last().is(".atwho-inserted")&&(a=t(d.startContainer).contents().get(c),this._setRange("after",t(a).contents().last()))):e.which===i.LEFT&&d.startContainer.nodeType===document.TEXT_NODE&&(n=t(d.startContainer.previousSibling),n.is(".atwho-inserted")&&0===d.startOffset&&this._setRange("after",n.contents().last()))}if(t(d.startContainer).closest(".atwho-inserted").addClass("atwho-query").siblings().removeClass("atwho-query"),(r=t(".atwho-query",this.app.document)).length>0&&r.is(":empty")&&0===r.text().length&&r.remove(),this._movingEvent(e)||r.removeClass("atwho-inserted"),r.length>0)switch(e.which){case i.LEFT:return this._setRange("before",r.get(0),d),void r.removeClass("atwho-query");case i.RIGHT:return this._setRange("after",r.get(0).nextSibling,d),void r.removeClass("atwho-query")}if(r.length>0&&(f=r.attr("data-atwho-at-query"))&&(r.empty().html(f).attr("data-atwho-at-query",null),this._setRange("after",r.get(0),d)),o=d.cloneRange(),o.setStart(d.startContainer,0),u=this.callbacks("matcher").call(this,this.at,o.toString(),this.getOpt("startWithSpace"),this.getOpt("acceptSpaceBar")),h="string"==typeof u,0===r.length&&h&&(s=d.startOffset-this.at.length-u.length)>=0&&(d.setStart(d.startContainer,s),r=t("",this.app.document).attr(this.getOpt("editableAtwhoQueryAttrs")).addClass("atwho-query"),d.surroundContents(r.get(0)),l=r.contents().last().get(0),/firefox/i.test(navigator.userAgent)?(d.setStart(l,l.length),d.setEnd(l,l.length),this._clearRange(d)):this._setRange("after",l,d)),!(h&&u.length=0&&(this._movingEvent(e)&&r.hasClass("atwho-inserted")?r.removeClass("atwho-query"):!1!==this.callbacks("afterMatchFailed").call(this,this.at,r)&&this._setRange("after",this._unwrap(r.text(r.text()).contents().first()))),null)}},n.prototype.rect=function(){var e,i,n;return n=this.query.el.offset(),this.app.iframe&&!this.app.iframeAsRoot&&(i=(e=t(this.app.iframe)).offset(),n.left+=i.left-this.$inputor.scrollLeft(),n.top+=i.top-this.$inputor.scrollTop()),n.bottom=n.top+this.query.el.height(),n},n.prototype.insert=function(t,e){var i,n,r,o;return this.$inputor.is(":focus")||this.$inputor.focus(),r=""===(r=this.getOpt("suffix"))?r:r||" ",i=e.data("item-data"),this.query.el.removeClass("atwho-query").addClass("atwho-inserted").html(t).attr("data-atwho-at-query",""+i["atwho-at"]+this.query.text),(n=this._getRange())&&(n.setEndAfter(this.query.el[0]),n.collapse(!1),n.insertNode(o=this.app.document.createTextNode("‍"+r)),this._setRange("after",o,n)),this.$inputor.is(":focus")||this.$inputor.focus(),this.$inputor.change()},n}(r);var u;u=function(){function e(t){this.context=t,this.at=this.context.at,this.storage=this.context.$inputor}return e.prototype.destroy=function(){return this.storage.data(this.at,null)},e.prototype.saved=function(){return this.fetch()>0},e.prototype.query=function(t,e){var i,n,r;return n=this.fetch(),r=this.context.getOpt("searchKey"),n=this.context.callbacks("filter").call(this.context,t,n,r)||[],i=this.context.callbacks("remoteFilter"),n.length>0||!i&&0===n.length?e(n):i.call(this.context,t,e)},e.prototype.fetch=function(){return this.storage.data(this.at)||[]},e.prototype.save=function(t){return this.storage.data(this.at,this.context.callbacks("beforeSave").call(this.context,t||[]))},e.prototype.load=function(t){return!this.saved()&&t?this._load(t):void 0},e.prototype.reload=function(t){return this._load(t)},e.prototype._load=function(e){return"string"==typeof e?t.ajax(e,{dataType:"json"}).done(function(t){return function(e){return t.save(e)}}(this)):this.save(e)},e}();var c;c=function(){function e(e){this.context=e,this.$el=t("
          "),this.$elUl=this.$el.children(),this.timeoutID=null,this.context.$el.append(this.$el),this.bindEvent()}return e.prototype.init=function(){var t,e;return e=this.context.getOpt("alias")||this.context.at.charCodeAt(0),t=this.context.getOpt("headerTpl"),t&&1===this.$el.children().length&&this.$el.prepend(t),this.$el.attr({id:"at-view-"+e})},e.prototype.destroy=function(){return this.$el.remove()},e.prototype.bindEvent=function(){var e,i,n;return e=this.$el.find("ul"),i=0,n=0,e.on("mousemove.atwho-view","li",function(r){return function(r){var o;if((i!==r.clientX||n!==r.clientY)&&(i=r.clientX,n=r.clientY,o=t(r.currentTarget),!o.hasClass("cur")))return e.find(".cur").removeClass("cur"),o.addClass("cur")}}(this)).on("click.atwho-view","li",function(i){return function(n){return e.find(".cur").removeClass("cur"),t(n.currentTarget).addClass("cur"),i.choose(n),n.preventDefault()}}(this))},e.prototype.visible=function(){return this.$el.is(":visible")},e.prototype.highlighted=function(){return this.$el.find(".cur").length>0},e.prototype.choose=function(t){var e,i;return(e=this.$el.find(".cur")).length&&(i=this.context.insertContentFor(e),this.context._stopDelayedCall(),this.context.insert(this.context.callbacks("beforeInsert").call(this.context,i,e,t),e),this.context.trigger("inserted",[e,t]),this.hide(t)),this.context.getOpt("hideWithoutSuffix")?this.stopShowing=!0:void 0},e.prototype.reposition=function(e){var i,n,r,o;return i=this.context.app.iframeAsRoot?this.context.app.window:window,e.bottom+this.$el.height()-t(i).scrollTop()>t(i).height()&&(e.bottom=e.top-this.$el.height()),e.left>(r=t(i).width()-this.$el.width()-5)&&(e.left=r),n={left:e.left,top:e.bottom},null!=(o=this.context.callbacks("beforeReposition"))&&o.call(this.context,n),this.$el.offset(n),this.context.trigger("reposition",[n])},e.prototype.next=function(){var t,e,i,n;return t=this.$el.find(".cur").removeClass("cur"),e=t.next(),e.length||(e=this.$el.find("li:first")),e.addClass("cur"),i=e[0],n=i.offsetTop+i.offsetHeight+(i.nextSibling?i.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,n-this.$el.height()))},e.prototype.prev=function(){var t,e,i,n;return t=this.$el.find(".cur").removeClass("cur"),i=t.prev(),i.length||(i=this.$el.find("li:last")),i.addClass("cur"),n=i[0],e=n.offsetTop+n.offsetHeight+(n.nextSibling?n.nextSibling.offsetHeight:0),this.scrollTop(Math.max(0,e-this.$el.height()))},e.prototype.scrollTop=function(t){var e;return e=this.context.getOpt("scrollDuration"),e?this.$elUl.animate({scrollTop:t},e):this.$elUl.scrollTop(t)},e.prototype.show=function(){var t;return this.stopShowing?void(this.stopShowing=!1):(this.visible()||(this.$el.show(),this.$el.scrollTop(0),this.context.trigger("shown")),(t=this.context.rect())?this.reposition(t):void 0)},e.prototype.hide=function(t,e){var i;if(this.visible())return isNaN(e)?(this.$el.hide(),this.context.trigger("hidden",[t])):(i=function(t){return function(){return t.hide()}}(this),clearTimeout(this.timeoutID),this.timeoutID=setTimeout(i,e))},e.prototype.render=function(e){var i,n,r,o,s,a,h;if(!(t.isArray(e)&&e.length>0))return void this.hide();for(this.$el.find("ul").empty(),n=this.$el.find("ul"),h=this.context.getOpt("displayTpl"),r=0,s=e.length;s>r;r++)o=e[r],o=t.extend({},o,{"atwho-at":this.context.at}),a=this.context.callbacks("tplEval").call(this.context,h,o,"onDisplay"),i=t(this.context.callbacks("highlighter").call(this.context,a,this.context.query.text)),i.data("item-data",o),n.append(i);return this.show(),this.context.getOpt("highlightFirst")?n.find("li:first").addClass("cur"):void 0},e}();var p;p={load:function(t,e){var i;return(i=this.controller(t))?i.model.load(e):void 0},isSelecting:function(){var t;return!!(null!=(t=this.controller())?t.view.visible():void 0)},hide:function(){var t;return null!=(t=this.controller())?t.view.hide():void 0},reposition:function(){var t;return(t=this.controller())?t.view.reposition(t.rect()):void 0},setIframe:function(t,e){return this.setupRootElement(t,e),null},run:function(){return this.dispatch()},destroy:function(){return this.shutdown(),this.$inputor.data("atwho",null)}},t.fn.atwho=function(e){var i,r;return i=arguments,r=null,this.filter('textarea, input, [contenteditable=""], [contenteditable=true]').each(function(){var o,s;return(s=(o=t(this)).data("atwho"))||o.data("atwho",s=new n(this)),"object"!=typeof e&&e?p[e]&&s?r=p[e].apply(s,Array.prototype.slice.call(i,1)):t.error("Method "+e+" does not exist on jQuery.atwho"):s.reg(e.at,e)}),null!=r?r:this},t.fn.atwho["default"]={at:void 0,alias:void 0,data:null,displayTpl:"
        • ${name}
        • ",insertTpl:"${atwho-at}${name}",headerTpl:null,callbacks:e,searchKey:"name",suffix:void 0,hideWithoutSuffix:!1,startWithSpace:!0,acceptSpaceBar:!1,highlightFirst:!0,limit:5,maxLen:20,minLen:0,displayTimeout:300,delay:null,spaceSelectsMatch:!1,tabSelectsMatch:!0,editableAtwhoQueryAttrs:{},scrollDuration:150,suspendOnComposing:!0,lookUpOnClick:!0},t.fn.atwho.debug=!1}); \ No newline at end of file diff --git a/pagure/static/atwho/jquery.atwho.css b/pagure/static/atwho/jquery.atwho.css index 8d3cc6d..7cdb23b 120000 --- a/pagure/static/atwho/jquery.atwho.css +++ b/pagure/static/atwho/jquery.atwho.css @@ -1 +1 @@ -jquery.atwho-1.4.1.css \ No newline at end of file +jquery.atwho-1.5.1.css \ No newline at end of file diff --git a/pagure/static/atwho/jquery.atwho.js b/pagure/static/atwho/jquery.atwho.js index 6404683..71094fd 120000 --- a/pagure/static/atwho/jquery.atwho.js +++ b/pagure/static/atwho/jquery.atwho.js @@ -1 +1 @@ -jquery.atwho-1.4.1.js \ No newline at end of file +jquery.atwho-1.5.1.js \ No newline at end of file diff --git a/pagure/static/atwho/jquery.atwho.min.css b/pagure/static/atwho/jquery.atwho.min.css index 564d968..9f0145a 120000 --- a/pagure/static/atwho/jquery.atwho.min.css +++ b/pagure/static/atwho/jquery.atwho.min.css @@ -1 +1 @@ -jquery.atwho-1.4.1.min.css \ No newline at end of file +jquery.atwho-1.5.1.min.css \ No newline at end of file diff --git a/pagure/static/atwho/jquery.atwho.min.js b/pagure/static/atwho/jquery.atwho.min.js index 168ae58..e1879fd 120000 --- a/pagure/static/atwho/jquery.atwho.min.js +++ b/pagure/static/atwho/jquery.atwho.min.js @@ -1 +1 @@ -jquery.atwho-1.4.1.min.js \ No newline at end of file +jquery.atwho-1.5.1.min.js \ No newline at end of file diff --git a/pagure/static/atwho/jquery.caret-0.3.1.js b/pagure/static/atwho/jquery.caret-0.3.1.js new file mode 100644 index 0000000..811ec63 --- /dev/null +++ b/pagure/static/atwho/jquery.caret-0.3.1.js @@ -0,0 +1,436 @@ +(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) { + var fn, found, offset, sel; + if (sel = oWindow.getSelection()) { + offset = 0; + found = false; + (fn = function(pos, parent) { + var node, range, _i, _len, _ref, _results; + _ref = parent.childNodes; + _results = []; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + node = _ref[_i]; + if (found) { + break; + } + if (node.nodeType === 3) { + if (offset + node.length >= pos) { + found = true; + range = oDocument.createRange(); + range.setStart(node, pos - offset); + sel.removeAllRanges(); + sel.addRange(range); + break; + } else { + _results.push(offset += node.length); + } + } else { + _results.push(fn(pos, node)); + } + } + return _results; + })(pos, this.domInputor); + } + 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; + + +})); diff --git a/pagure/static/atwho/jquery.caret-0.3.1.min.js b/pagure/static/atwho/jquery.caret-0.3.1.min.js new file mode 100644 index 0000000..a25584e --- /dev/null +++ b/pagure/static/atwho/jquery.caret-0.3.1.min.js @@ -0,0 +1,2 @@ +/*! jquery.caret 2016-02-27 */ +!function(a,b){"function"==typeof define&&define.amd?define(["jquery"],function(c){return a.returnExportsGlobal=b(c)}):"object"==typeof exports?module.exports=b(require("jquery")):b(jQuery)}(this,function(a){"use strict";var b,c,d,e,f,g,h,i,j,k,l;k="caret",b=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.setPos=function(a){var b,c,d,e;return(e=j.getSelection())&&(d=0,c=!1,(b=function(a,f){var g,i,j,k,l,m;for(l=f.childNodes,m=[],j=0,k=l.length;k>j&&(g=l[j],!c);j++)if(3===g.nodeType){if(d+g.length>=a){c=!0,i=h.createRange(),i.setStart(g,a-d),e.removeAllRanges(),e.addRange(i);break}m.push(d+=g.length)}else m.push(b(a,g));return m})(a,this.domInputor)),this.domInputor},b.prototype.getIEPosition=function(){return this.getPosition()},b.prototype.getPosition=function(){var a,b;return b=this.getOffset(),a=this.$inputor.offset(),b.left-=a.left,b.top-=a.top,b},b.prototype.getOldIEPos=function(){var a,b;return b=h.selection.createRange(),a=h.body.createTextRange(),a.moveToElementText(this.domInputor),a.setEndPoint("EndToEnd",b),a.text.length},b.prototype.getPos=function(){var a,b,c;return(c=this.range())?(a=c.cloneRange(),a.selectNodeContents(this.domInputor),a.setEnd(c.endContainer,c.endOffset),b=a.toString().length,a.detach(),b):h.selection?this.getOldIEPos():void 0},b.prototype.getOldIEOffset=function(){var a,b;return a=h.selection.createRange().duplicate(),a.moveStart("character",-1),b=a.getBoundingClientRect(),{height:b.bottom-b.top,left:b.left,top:b.top}},b.prototype.getOffset=function(){var b,c,d,e,f;return j.getSelection&&(d=this.range())?(d.endOffset-1>0&&d.endContainer!==this.domInputor&&(b=d.cloneRange(),b.setStart(d.endContainer,d.endOffset-1),b.setEnd(d.endContainer,d.endOffset),e=b.getBoundingClientRect(),c={height:e.height,left:e.left+e.width,top:e.top},b.detach()),c&&0!==(null!=c?c.height:void 0)||(b=d.cloneRange(),f=a(h.createTextNode("|")),b.insertNode(f[0]),b.selectNode(f[0]),e=b.getBoundingClientRect(),c={height:e.height,left:e.left,top:e.top},f.remove(),b.detach())):h.selection&&(c=this.getOldIEOffset()),c&&(c.top+=a(j).scrollTop(),c.left+=a(j).scrollLeft()),c},b.prototype.range=function(){var a;if(j.getSelection)return a=j.getSelection(),a.rangeCount>0?a.getRangeAt(0):null},b}(),c=function(){function b(a){this.$inputor=a,this.domInputor=this.$inputor[0]}return b.prototype.getIEPos=function(){var a,b,c,d,e,f,g;return b=this.domInputor,f=h.selection.createRange(),e=0,f&&f.parentElement()===b&&(d=b.value.replace(/\r\n/g,"\n"),c=d.length,g=b.createTextRange(),g.moveToBookmark(f.getBookmark()),a=b.createTextRange(),a.collapse(!1),e=g.compareEndPoints("StartToEnd",a)>-1?c:-g.moveStart("character",-c)),e},b.prototype.getPos=function(){return h.selection?this.getIEPos():this.domInputor.selectionStart},b.prototype.setPos=function(a){var b,c;return b=this.domInputor,h.selection?(c=b.createTextRange(),c.move("character",a),c.select()):b.setSelectionRange&&b.setSelectionRange(a,a),b},b.prototype.getIEOffset=function(a){var b,c,d,e;return c=this.domInputor.createTextRange(),a||(a=this.getPos()),c.move("character",a),d=c.boundingLeft,e=c.boundingTop,b=c.boundingHeight,{left:d,top:e,height:b}},b.prototype.getOffset=function(b){var c,d,e;return c=this.$inputor,h.selection?(d=this.getIEOffset(b),d.top+=a(j).scrollTop()+c.scrollTop(),d.left+=a(j).scrollLeft()+c.scrollLeft(),d):(d=c.offset(),e=this.getPosition(b),d={left:d.left+e.left-c.scrollLeft(),top:d.top+e.top-c.scrollTop(),height:e.height})},b.prototype.getPosition=function(a){var b,c,e,f,g,h,i;return b=this.$inputor,f=function(a){return a=a.replace(/<|>|`|"|&/g,"?").replace(/\r\n|\r|\n/g,"
          "),/firefox/i.test(navigator.userAgent)&&(a=a.replace(/\s/g," ")),a},void 0===a&&(a=this.getPos()),i=b.val().slice(0,a),e=b.val().slice(a),g=""+f(i)+"",g+="|",g+=""+f(e)+"",h=new d(b),c=h.create(g).rect()},b.prototype.getIEPosition=function(a){var b,c,d,e,f;return d=this.getIEOffset(a),c=this.$inputor.offset(),e=d.left-c.left,f=d.top-c.top,b=d.height,{left:e,top:f,height:b}},b}(),d=function(){function b(a){this.$inputor=a}return b.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"],b.prototype.mirrorCss=function(){var b,c=this;return b={position:"absolute",left:-9999,top:0,zIndex:-2e4},"TEXTAREA"===this.$inputor.prop("tagName")&&this.css_attr.push("width"),a.each(this.css_attr,function(a,d){return b[d]=c.$inputor.css(d)}),b},b.prototype.create=function(b){return this.$mirror=a("
          "),this.$mirror.css(this.mirrorCss()),this.$mirror.html(b),this.$inputor.after(this.$mirror),this},b.prototype.rect=function(){var a,b,c;return a=this.$mirror.find("#caret"),b=a.position(),c={left:b.left,top:b.top,height:a.height()},this.$mirror.remove(),c},b}(),e={contentEditable:function(a){return!(!a[0].contentEditable||"true"!==a[0].contentEditable)}},g={pos:function(a){return a||0===a?this.setPos(a):this.getPos()},position:function(a){return h.selection?this.getIEPosition(a):this.getPosition(a)},offset:function(a){var b;return b=this.getOffset(a)}},h=null,j=null,i=null,l=function(a){var b;return(b=null!=a?a.iframe:void 0)?(i=b,j=b.contentWindow,h=b.contentDocument||j.document):(i=void 0,j=window,h=document)},f=function(a){var b;h=a[0].ownerDocument,j=h.defaultView||h.parentWindow;try{return i=j.frameElement}catch(c){b=c}},a.fn.caret=function(d,f,h){var i;return g[d]?(a.isPlainObject(f)?(l(f),f=void 0):l(h),i=e.contentEditable(this)?new b(this):new c(this),g[d].apply(i,[f])):a.error("Method "+d+" does not exist on jQuery.caret")},a.fn.caret.EditableCaret=b,a.fn.caret.InputCaret=c,a.fn.caret.Utils=e,a.fn.caret.apis=g}); \ No newline at end of file diff --git a/pagure/static/atwho/jquery.caret-1.5.2.js b/pagure/static/atwho/jquery.caret-1.5.2.js deleted file mode 100644 index c29f029..0000000 --- a/pagure/static/atwho/jquery.caret-1.5.2.js +++ /dev/null @@ -1,543 +0,0 @@ -/*! jQuery Caret Plugin - v1.5.2 - 2014-03-25 - * https://github.com/acdvorak/jquery.caret - * Copyright (c) 2012-2014 Andrew C. Dvorak; Licensed MIT */ -(function($, undefined) { - - var _input = document.createElement('input'); - - var _support = { - setSelectionRange: ('setSelectionRange' in _input) || ('selectionStart' in _input), - createTextRange: ('createTextRange' in _input) || ('selection' in document) - }; - - var _rNewlineIE = /\r\n/g, - _rCarriageReturn = /\r/g; - - var _getValue = function(input) { - if (typeof(input.value) !== 'undefined') { - return input.value; - } - return $(input).text(); - }; - - var _setValue = function(input, value) { - if (typeof(input.value) !== 'undefined') { - input.value = value; - } else { - $(input).text(value); - } - }; - - var _getIndex = function(input, pos) { - var norm = _getValue(input).replace(_rCarriageReturn, ''); - var len = norm.length; - - if (typeof(pos) === 'undefined') { - pos = len; - } - - pos = Math.floor(pos); - - // Negative index counts backward from the end of the input/textarea's value - if (pos < 0) { - pos = len + pos; - } - - // Enforce boundaries - if (pos < 0) { pos = 0; } - if (pos > len) { pos = len; } - - return pos; - }; - - var _hasAttr = function(input, attrName) { - return input.hasAttribute ? input.hasAttribute(attrName) : (typeof(input[attrName]) !== 'undefined'); - }; - - /** - * @class - * @constructor - */ - var Range = function(start, end, length, text) { - this.start = start || 0; - this.end = end || 0; - this.length = length || 0; - this.text = text || ''; - }; - - Range.prototype.toString = function() { - return JSON.stringify(this, null, ' '); - }; - - var _getCaretW3 = function(input) { - return input.selectionStart; - }; - - /** - * @see http://stackoverflow.com/q/6943000/467582 - */ - var _getCaretIE = function(input) { - var caret, range, textInputRange, rawValue, len, endRange; - - // Yeah, you have to focus twice for IE 7 and 8. *cries* - input.focus(); - input.focus(); - - range = document.selection.createRange(); - - if (range && range.parentElement() === input) { - rawValue = _getValue(input); - - len = rawValue.length; - - // Create a working TextRange that lives only in the input - textInputRange = input.createTextRange(); - textInputRange.moveToBookmark(range.getBookmark()); - - // Check if the start and end of the selection are at the very end - // of the input, since moveStart/moveEnd doesn't return what we want - // in those cases - endRange = input.createTextRange(); - endRange.collapse(false); - - if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) { - caret = rawValue.replace(_rNewlineIE, '\n').length; - } else { - caret = -textInputRange.moveStart("character", -len); - } - - return caret; - } - - // NOTE: This occurs when you highlight part of a textarea and then click in the middle of the highlighted portion in IE 6-10. - // There doesn't appear to be anything we can do about it. -// alert("Your browser is incredibly stupid. I don't know what else to say."); -// alert(range + '\n\n' + range.parentElement().tagName + '#' + range.parentElement().id); - - return 0; - }; - - /** - * Gets the position of the caret in the given input. - * @param {HTMLInputElement|HTMLTextAreaElement} input input or textarea element - * @returns {Number} - * @see http://stackoverflow.com/questions/263743/how-to-get-cursor-position-in-textarea/263796#263796 - */ - var _getCaret = function(input) { - if (!input) { - return undefined; - } - - // Mozilla, et al. - if (_support.setSelectionRange) { - return _getCaretW3(input); - } - // IE - else if (_support.createTextRange) { - return _getCaretIE(input); - } - - return undefined; - }; - - var _setCaretW3 = function(input, pos) { - input.setSelectionRange(pos, pos); - }; - - var _setCaretIE = function(input, pos) { - var range = input.createTextRange(); - range.move('character', pos); - range.select(); - }; - - /** - * Sets the position of the caret in the given input. - * @param {HTMLInputElement|HTMLTextAreaElement} input input or textarea element - * @param {Number} pos - * @see http://parentnode.org/javascript/working-with-the-cursor-position/ - */ - var _setCaret = function(input, pos) { - input.focus(); - - pos = _getIndex(input, pos); - - // Mozilla, et al. - if (_support.setSelectionRange) { - _setCaretW3(input, pos); - } - // IE - else if (_support.createTextRange) { - _setCaretIE(input, pos); - } - }; - - /** - * Inserts the specified text at the current caret position in the given input. - * @param {HTMLInputElement|HTMLTextAreaElement} input input or textarea element - * @param {String} text - * @see http://parentnode.org/javascript/working-with-the-cursor-position/ - */ - var _insertAtCaret = function(input, text) { - var curPos = _getCaret(input); - - var oldValueNorm = _getValue(input).replace(_rCarriageReturn, ''); - - var newLength = +(curPos + text.length + (oldValueNorm.length - curPos)); - var maxLength = +input.getAttribute('maxlength'); - - if(_hasAttr(input, 'maxlength') && newLength > maxLength) { - var delta = text.length - (newLength - maxLength); - text = text.substr(0, delta); - } - - _setValue(input, oldValueNorm.substr(0, curPos) + text + oldValueNorm.substr(curPos)); - - _setCaret(input, curPos + text.length); - }; - - var _getInputRangeW3 = function(input) { - var range = new Range(); - - range.start = input.selectionStart; - range.end = input.selectionEnd; - - var min = Math.min(range.start, range.end); - var max = Math.max(range.start, range.end); - - range.length = max - min; - range.text = _getValue(input).substring(min, max); - - return range; - }; - - /** @see http://stackoverflow.com/a/3648244/467582 */ - var _getInputRangeIE = function(input) { - var range = new Range(); - - input.focus(); - - var selection = document.selection.createRange(); - - if (selection && selection.parentElement() === input) { - var len, normalizedValue, textInputRange, endRange, start = 0, end = 0; - var rawValue = _getValue(input); - - len = rawValue.length; - normalizedValue = rawValue.replace(/\r\n/g, "\n"); - - // Create a working TextRange that lives only in the input - textInputRange = input.createTextRange(); - textInputRange.moveToBookmark(selection.getBookmark()); - - // Check if the start and end of the selection are at the very end - // of the input, since moveStart/moveEnd doesn't return what we want - // in those cases - endRange = input.createTextRange(); - endRange.collapse(false); - - if (textInputRange.compareEndPoints("StartToEnd", endRange) > -1) { - start = end = len; - } else { - start = -textInputRange.moveStart("character", -len); - start += normalizedValue.slice(0, start).split("\n").length - 1; - - if (textInputRange.compareEndPoints("EndToEnd", endRange) > -1) { - end = len; - } else { - end = -textInputRange.moveEnd("character", -len); - end += normalizedValue.slice(0, end).split("\n").length - 1; - } - } - - /// normalize newlines - start -= (rawValue.substring(0, start).split('\r\n').length - 1); - end -= (rawValue.substring(0, end).split('\r\n').length - 1); - /// normalize newlines - - range.start = start; - range.end = end; - range.length = range.end - range.start; - range.text = normalizedValue.substr(range.start, range.length); - } - - return range; - }; - - /** - * Gets the selected text range of the given input. - * @param {HTMLInputElement|HTMLTextAreaElement} input input or textarea element - * @returns {Range} - * @see http://stackoverflow.com/a/263796/467582 - * @see http://stackoverflow.com/a/2966703/467582 - */ - var _getInputRange = function(input) { - if (!input) { - return undefined; - } - - // Mozilla, et al. - if (_support.setSelectionRange) { - return _getInputRangeW3(input); - } - // IE - else if (_support.createTextRange) { - return _getInputRangeIE(input); - } - - return undefined; - }; - - var _setInputRangeW3 = function(input, startPos, endPos) { - input.setSelectionRange(startPos, endPos); - }; - - var _setInputRangeIE = function(input, startPos, endPos) { - var tr = input.createTextRange(); - tr.moveEnd('textedit', -1); - tr.moveStart('character', startPos); - tr.moveEnd('character', endPos - startPos); - tr.select(); - }; - - /** - * Sets the selected text range of (i.e., highlights text in) the given input. - * @param {HTMLInputElement|HTMLTextAreaElement} input input or textarea element - * @param {Number} startPos Zero-based index - * @param {Number} endPos Zero-based index - * @see http://parentnode.org/javascript/working-with-the-cursor-position/ - * @see http://stackoverflow.com/a/2966703/467582 - */ - var _setInputRange = function(input, startPos, endPos) { - startPos = _getIndex(input, startPos); - endPos = _getIndex(input, endPos); - - // Mozilla, et al. - if (_support.setSelectionRange) { - _setInputRangeW3(input, startPos, endPos); - } - // IE - else if (_support.createTextRange) { - _setInputRangeIE(input, startPos, endPos); - } - }; - - /** - * Replaces the currently selected text with the given string. - * @param {HTMLInputElement|HTMLTextAreaElement} input input or textarea element - * @param {String} text New text that will replace the currently selected text. - * @see http://parentnode.org/javascript/working-with-the-cursor-position/ - */ - var _replaceInputRange = function(input, text) { - var $input = $(input); - - var oldValue = $input.val(); - var selection = _getInputRange(input); - - var newLength = +(selection.start + text.length + (oldValue.length - selection.end)); - var maxLength = +$input.attr('maxlength'); - - if($input.is('[maxlength]') && newLength > maxLength) { - var delta = text.length - (newLength - maxLength); - text = text.substr(0, delta); - } - - // Now that we know what the user selected, we can replace it - var startText = oldValue.substr(0, selection.start); - var endText = oldValue.substr(selection.end); - - $input.val(startText + text + endText); - - // Reset the selection - var startPos = selection.start; - var endPos = startPos + text.length; - - _setInputRange(input, selection.length ? startPos : endPos, endPos); - }; - - var _selectAllW3 = function(elem) { - var selection = window.getSelection(); - var range = document.createRange(); - range.selectNodeContents(elem); - selection.removeAllRanges(); - selection.addRange(range); - }; - - var _selectAllIE = function(elem) { - var range = document.body.createTextRange(); - range.moveToElementText(elem); - range.select(); - }; - - /** - * Select all text in the given element. - * @param {HTMLElement} elem Any block or inline element other than a form element. - */ - var _selectAll = function(elem) { - var $elem = $(elem); - if ($elem.is('input, textarea') || elem.select) { - $elem.select(); - return; - } - - // Mozilla, et al. - if (_support.setSelectionRange) { - _selectAllW3(elem); - } - // IE - else if (_support.createTextRange) { - _selectAllIE(elem); - } - }; - - var _deselectAll = function() { - if (document.selection) { - document.selection.empty(); - } - else if (window.getSelection) { - window.getSelection().removeAllRanges(); - } - }; - - $.extend($.fn, { - - /** - * Gets or sets the position of the caret or inserts text at the current caret position in an input or textarea element. - * @returns {Number|jQuery} The current caret position if invoked as a getter (with no arguments) - * or this jQuery object if invoked as a setter or inserter. - * @see http://web.archive.org/web/20080704185920/http://parentnode.org/javascript/working-with-the-cursor-position/ - * @since 1.0.0 - * @example - *
          -         *    // Get position
          -         *    var pos = $('input:first').caret();
          -         * 
          - * @example - *
          -         *    // Set position
          -         *    $('input:first').caret(15);
          -         *    $('input:first').caret(-3);
          -         * 
          - * @example - *
          -         *    // Insert text at current position
          -         *    $('input:first').caret('Some text');
          -         * 
          - */ - caret: function() { - var $inputs = this.filter('input, textarea'); - - // getCaret() - if (arguments.length === 0) { - var input = $inputs.get(0); - return _getCaret(input); - } - // setCaret(position) - else if (typeof arguments[0] === 'number') { - var pos = arguments[0]; - $inputs.each(function(_i, input) { - _setCaret(input, pos); - }); - } - // insertAtCaret(text) - else { - var text = arguments[0]; - $inputs.each(function(_i, input) { - _insertAtCaret(input, text); - }); - } - - return this; - }, - - /** - * Gets or sets the selection range or replaces the currently selected text in an input or textarea element. - * @returns {Range|jQuery} The current selection range if invoked as a getter (with no arguments) - * or this jQuery object if invoked as a setter or replacer. - * @see http://stackoverflow.com/a/2966703/467582 - * @since 1.0.0 - * @example - *
          -         *    // Get selection range
          -         *    var range = $('input:first').range();
          -         * 
          - * @example - *
          -         *    // Set selection range
          -         *    $('input:first').range(15);
          -         *    $('input:first').range(15, 20);
          -         *    $('input:first').range(-3);
          -         *    $('input:first').range(-8, -3);
          -         * 
          - * @example - *
          -         *    // Replace the currently selected text
          -         *    $('input:first').range('Replacement text');
          -         * 
          - */ - range: function() { - var $inputs = this.filter('input, textarea'); - - // getRange() = { start: pos, end: pos } - if (arguments.length === 0) { - var input = $inputs.get(0); - return _getInputRange(input); - } - // setRange(startPos, endPos) - else if (typeof arguments[0] === 'number') { - var startPos = arguments[0]; - var endPos = arguments[1]; - $inputs.each(function(_i, input) { - _setInputRange(input, startPos, endPos); - }); - } - // replaceRange(text) - else { - var text = arguments[0]; - $inputs.each(function(_i, input) { - _replaceInputRange(input, text); - }); - } - - return this; - }, - - /** - * Selects all text in each element of this jQuery object. - * @returns {jQuery} This jQuery object - * @see http://stackoverflow.com/a/11128179/467582 - * @since 1.5.0 - * @example - *
          -         *     // Select the contents of span elements when clicked
          -         *     $('span').on('click', function() { $(this).highlight(); });
          -         * 
          - */ - selectAll: function() { - return this.each(function(_i, elem) { - _selectAll(elem); - }); - } - - }); - - $.extend($, { - /** - * Deselects all text on the page. - * @returns {jQuery} The jQuery function - * @since 1.5.0 - * @example - *
          -         *     // Select some text
          -         *     $('span').selectAll();
          -         *
          -         *     // Deselect the text
          -         *     $.deselectAll();
          -         * 
          - */ - deselectAll: function() { - _deselectAll(); - return this; - } - }); - -}(window.jQuery || window.Zepto || window.$)); diff --git a/pagure/static/atwho/jquery.caret-1.5.2.min.js b/pagure/static/atwho/jquery.caret-1.5.2.min.js deleted file mode 100644 index 832a87d..0000000 --- a/pagure/static/atwho/jquery.caret-1.5.2.min.js +++ /dev/null @@ -1,6 +0,0 @@ -/*! jQuery Caret Plugin - v1.5.2 - 2014-03-25 - * https://github.com/acdvorak/jquery.caret - * Copyright (c) 2012-2014 Andrew C. Dvorak; Licensed MIT */ - -!function(a,b){var c=document.createElement("input"),d={setSelectionRange:"setSelectionRange"in c||"selectionStart"in c,createTextRange:"createTextRange"in c||"selection"in document},e=/\r\n/g,f=/\r/g,g=function(b){return"undefined"!=typeof b.value?b.value:a(b).text()},h=function(b,c){"undefined"!=typeof b.value?b.value=c:a(b).text(c)},i=function(a,b){var c=g(a).replace(f,""),d=c.length;return"undefined"==typeof b&&(b=d),b=Math.floor(b),0>b&&(b=d+b),0>b&&(b=0),b>d&&(b=d),b},j=function(a,b){return a.hasAttribute?a.hasAttribute(b):"undefined"!=typeof a[b]},k=function(a,b,c,d){this.start=a||0,this.end=b||0,this.length=c||0,this.text=d||""};k.prototype.toString=function(){return JSON.stringify(this,null," ")};var l=function(a){return a.selectionStart},m=function(a){var b,c,d,f,h,i;return a.focus(),a.focus(),c=document.selection.createRange(),c&&c.parentElement()===a?(f=g(a),h=f.length,d=a.createTextRange(),d.moveToBookmark(c.getBookmark()),i=a.createTextRange(),i.collapse(!1),b=d.compareEndPoints("StartToEnd",i)>-1?f.replace(e,"\n").length:-d.moveStart("character",-h)):0},n=function(a){return a?d.setSelectionRange?l(a):d.createTextRange?m(a):b:b},o=function(a,b){a.setSelectionRange(b,b)},p=function(a,b){var c=a.createTextRange();c.move("character",b),c.select()},q=function(a,b){a.focus(),b=i(a,b),d.setSelectionRange?o(a,b):d.createTextRange&&p(a,b)},r=function(a,b){var c=n(a),d=g(a).replace(f,""),e=+(c+b.length+(d.length-c)),i=+a.getAttribute("maxlength");if(j(a,"maxlength")&&e>i){var k=b.length-(e-i);b=b.substr(0,k)}h(a,d.substr(0,c)+b+d.substr(c)),q(a,c+b.length)},s=function(a){var b=new k;b.start=a.selectionStart,b.end=a.selectionEnd;var c=Math.min(b.start,b.end),d=Math.max(b.start,b.end);return b.length=d-c,b.text=g(a).substring(c,d),b},t=function(a){var b=new k;a.focus();var c=document.selection.createRange();if(c&&c.parentElement()===a){var d,e,f,h,i=0,j=0,l=g(a);d=l.length,e=l.replace(/\r\n/g,"\n"),f=a.createTextRange(),f.moveToBookmark(c.getBookmark()),h=a.createTextRange(),h.collapse(!1),f.compareEndPoints("StartToEnd",h)>-1?i=j=d:(i=-f.moveStart("character",-d),i+=e.slice(0,i).split("\n").length-1,f.compareEndPoints("EndToEnd",h)>-1?j=d:(j=-f.moveEnd("character",-d),j+=e.slice(0,j).split("\n").length-1)),i-=l.substring(0,i).split("\r\n").length-1,j-=l.substring(0,j).split("\r\n").length-1,b.start=i,b.end=j,b.length=b.end-b.start,b.text=e.substr(b.start,b.length)}return b},u=function(a){return a?d.setSelectionRange?s(a):d.createTextRange?t(a):b:b},v=function(a,b,c){a.setSelectionRange(b,c)},w=function(a,b,c){var d=a.createTextRange();d.moveEnd("textedit",-1),d.moveStart("character",b),d.moveEnd("character",c-b),d.select()},x=function(a,b,c){b=i(a,b),c=i(a,c),d.setSelectionRange?v(a,b,c):d.createTextRange&&w(a,b,c)},y=function(b,c){var d=a(b),e=d.val(),f=u(b),g=+(f.start+c.length+(e.length-f.end)),h=+d.attr("maxlength");if(d.is("[maxlength]")&&g>h){var i=c.length-(g-h);c=c.substr(0,i)}var j=e.substr(0,f.start),k=e.substr(f.end);d.val(j+c+k);var l=f.start,m=l+c.length;x(b,f.length?l:m,m)},z=function(a){var b=window.getSelection(),c=document.createRange();c.selectNodeContents(a),b.removeAllRanges(),b.addRange(c)},A=function(a){var b=document.body.createTextRange();b.moveToElementText(a),b.select()},B=function(b){var c=a(b);return c.is("input, textarea")||b.select?(c.select(),void 0):(d.setSelectionRange?z(b):d.createTextRange&&A(b),void 0)},C=function(){document.selection?document.selection.empty():window.getSelection&&window.getSelection().removeAllRanges()};a.extend(a.fn,{caret:function(){var a=this.filter("input, textarea");if(0===arguments.length){var b=a.get(0);return n(b)}if("number"==typeof arguments[0]){var c=arguments[0];a.each(function(a,b){q(b,c)})}else{var d=arguments[0];a.each(function(a,b){r(b,d)})}return this},range:function(){var a=this.filter("input, textarea");if(0===arguments.length){var b=a.get(0);return u(b)}if("number"==typeof arguments[0]){var c=arguments[0],d=arguments[1];a.each(function(a,b){x(b,c,d)})}else{var e=arguments[0];a.each(function(a,b){y(b,e)})}return this},selectAll:function(){return this.each(function(a,b){B(b)})}}),a.extend(a,{deselectAll:function(){return C(),this}})}(window.jQuery||window.Zepto||window.$); -//# sourceMappingURL=dist/jquery.caret-1.5.2.min.map \ No newline at end of file diff --git a/pagure/static/atwho/jquery.caret.js b/pagure/static/atwho/jquery.caret.js index a73e1e2..e0b716b 120000 --- a/pagure/static/atwho/jquery.caret.js +++ b/pagure/static/atwho/jquery.caret.js @@ -1 +1 @@ -jquery.caret-1.5.2.js \ No newline at end of file +jquery.caret-0.3.1.js \ No newline at end of file diff --git a/pagure/static/atwho/jquery.caret.min.js b/pagure/static/atwho/jquery.caret.min.js index 9878694..0cfd9eb 120000 --- a/pagure/static/atwho/jquery.caret.min.js +++ b/pagure/static/atwho/jquery.caret.min.js @@ -1 +1 @@ -jquery.caret-1.5.2.min.js \ No newline at end of file +jquery.caret-0.3.1.min.js \ No newline at end of file