From 1da16619e0f1931b71caf85586c28faa3c433a3e Mon Sep 17 00:00:00 2001 From: amrbedair Date: Fri, 30 May 2014 18:47:16 +0200 Subject: [PATCH] TbTags --- build.properties | 2 +- .../bootstrap-tags/css/bootstrap-tags.css | 78 +++ .../bootstrap-tags/js/bootstrap-tags.js | 622 ++++++++++++++++++ .../bootstrap-tags/js/bootstrap-tags.min.js | 7 + src/assets/css/bootstrap-tags.css | 62 -- src/assets/js/bootstrap.tags.js | 315 --------- src/components/Booster.php | 2 +- src/components/packages.php | 6 + src/widgets/TbTags.php | 34 +- 9 files changed, 736 insertions(+), 392 deletions(-) create mode 100644 src/assets/bootstrap-tags/css/bootstrap-tags.css create mode 100644 src/assets/bootstrap-tags/js/bootstrap-tags.js create mode 100644 src/assets/bootstrap-tags/js/bootstrap-tags.min.js delete mode 100755 src/assets/css/bootstrap-tags.css delete mode 100755 src/assets/js/bootstrap.tags.js diff --git a/build.properties b/build.properties index 568153df..5136ccdc 100644 --- a/build.properties +++ b/build.properties @@ -15,5 +15,5 @@ path.reports=./reports # Current version under which project will be distributed. # Versioning is being made according to Semantic Versioning specification at http://semver.org/ -project.version=4.0.0-beta-2 +project.version=4.0.0 diff --git a/src/assets/bootstrap-tags/css/bootstrap-tags.css b/src/assets/bootstrap-tags/css/bootstrap-tags.css new file mode 100644 index 00000000..c3269b62 --- /dev/null +++ b/src/assets/bootstrap-tags/css/bootstrap-tags.css @@ -0,0 +1,78 @@ +/* bootstrap-tags styles */ +.bootstrap-tags.bootstrap-3 .tag a { + margin: 0 0 0 .3em; } +.bootstrap-tags.bootstrap-3 .glyphicon-white { + color: #fff; } + +.bootstrap-tags.bootstrap-2 .tag.md { + padding: .3em .4em .4em; } +.bootstrap-tags.bootstrap-2 .tag.lg { + padding: .4em .4em .5em; } + +.bootstrap-tags { + position: relative; } + .bootstrap-tags .tags { + width: inherit; + height: 0; + position: absolute; + padding: 0; + margin: 0; } + .bootstrap-tags .tag-data { + display: none; } + .bootstrap-tags .tags-input { + width: 100%; + margin: 0; + padding: 0; + height: 1.7em; + box-sizing: content-box; + -webkit-box-sizing: content-box; + -moz-box-sizing: content-box; } + .bootstrap-tags .tag-list { + width: 280px; + height: auto; + min-height: 26px; + left: 2px; + top: 2px; + position: relative; } + .bootstrap-tags .tag { + padding: .4em .4em .4em; + margin: 0 .1em; + float: left; } + .bootstrap-tags .tag.sm { + padding: .4em .4em .5em; + font-size: 12px; } + .bootstrap-tags .tag.md { + font-size: 14px; } + .bootstrap-tags .tag.lg { + font-size: 18px; + padding: .4em .4em .4em; + margin: 0 .2em .2em 0; } + .bootstrap-tags .tag a { + color: #bbb; + cursor: pointer; + opacity: .5; } + .bootstrap-tags .tag .remove { + vertical-align: bottom; + top: 0; } + .bootstrap-tags ul.tags-suggestion-list { + width: 300px; + height: auto; + list-style: none; + margin: 0; + z-index: 2; + max-height: 160px; + overflow: scroll; } + .bootstrap-tags ul.tags-suggestion-list li.tags-suggestion { + padding: 3px 20px; + height: auto; } + .bootstrap-tags ul.tags-suggestion-list li.tags-suggestion-highlighted { + color: white; + text-decoration: none; + background-color: #0081C2; + background-image: -moz-linear-gradient(top, #0088cc, #0077b3); + background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#0088cc), to(#0077b3)); + background-image: -webkit-linear-gradient(top, #0088cc, #0077b3); + background-image: -o-linear-gradient(top, #0088cc, #0077b3); + background-image: linear-gradient(to bottom, #0088cc, #0077b3); + background-repeat: repeat-x; + filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); } diff --git a/src/assets/bootstrap-tags/js/bootstrap-tags.js b/src/assets/bootstrap-tags/js/bootstrap-tags.js new file mode 100644 index 00000000..d13ad03d --- /dev/null +++ b/src/assets/bootstrap-tags/js/bootstrap-tags.js @@ -0,0 +1,622 @@ +/*! + * bootstrap-tags 1.1.0 + * https://github.com/maxwells/bootstrap-tags + * Copyright 2013 Max Lahey; Licensed MIT + */ + +(function($) { + (function() { + window.Tags || (window.Tags = {}); + jQuery(function() { + $.tags = function(element, options) { + var key, tag, tagData, value, _i, _len, _ref, _this = this; + if (options == null) { + options = {}; + } + for (key in options) { + value = options[key]; + this[key] = value; + } + this.bootstrapVersion || (this.bootstrapVersion = "3"); + this.readOnly || (this.readOnly = false); + this.suggestOnClick || (this.suggestOnClick = false); + this.suggestions || (this.suggestions = []); + this.restrictTo = options.restrictTo != null ? options.restrictTo.concat(this.suggestions) : false; + this.exclude || (this.exclude = false); + this.displayPopovers = options.popovers != null ? true : options.popoverData != null; + this.popoverTrigger || (this.popoverTrigger = "hover"); + this.tagClass || (this.tagClass = "btn-info"); + this.tagSize || (this.tagSize = "md"); + this.promptText || (this.promptText = "Enter tags..."); + this.caseInsensitive || (this.caseInsensitive = false); + this.readOnlyEmptyMessage || (this.readOnlyEmptyMessage = "No tags to display..."); + this.maxNumTags || (this.maxNumTags = -1); + this.beforeAddingTag || (this.beforeAddingTag = function(tag) {}); + this.afterAddingTag || (this.afterAddingTag = function(tag) {}); + this.beforeDeletingTag || (this.beforeDeletingTag = function(tag) {}); + this.afterDeletingTag || (this.afterDeletingTag = function(tag) {}); + this.definePopover || (this.definePopover = function(tag) { + return 'associated content for "' + tag + '"'; + }); + this.excludes || (this.excludes = function() { + return false; + }); + this.tagRemoved || (this.tagRemoved = function(tag) {}); + this.pressedReturn || (this.pressedReturn = function(e) {}); + this.pressedDelete || (this.pressedDelete = function(e) {}); + this.pressedDown || (this.pressedDown = function(e) {}); + this.pressedUp || (this.pressedUp = function(e) {}); + this.$element = $(element); + if (options.tagData != null) { + this.tagsArray = options.tagData; + } else { + tagData = $(".tag-data", this.$element).html(); + this.tagsArray = tagData != null ? tagData.split(",") : []; + } + if (options.popoverData) { + this.popoverArray = options.popoverData; + } else { + this.popoverArray = []; + _ref = this.tagsArray; + for (_i = 0, _len = _ref.length; _i < _len; _i++) { + tag = _ref[_i]; + this.popoverArray.push(null); + } + } + this.getTags = function() { + return _this.tagsArray; + }; + this.getTagsContent = function() { + return _this.popoverArray; + }; + this.getTagsWithContent = function() { + var combined, i, _j, _ref1; + combined = []; + for (i = _j = 0, _ref1 = _this.tagsArray.length - 1; 0 <= _ref1 ? _j <= _ref1 : _j >= _ref1; i = 0 <= _ref1 ? ++_j : --_j) { + combined.push({ + tag: _this.tagsArray[i], + content: _this.popoverArray[i] + }); + } + return combined; + }; + this.getTag = function(tag) { + var index; + index = _this.tagsArray.indexOf(tag); + if (index > -1) { + return _this.tagsArray[index]; + } else { + return null; + } + }; + this.getTagWithContent = function(tag) { + var index; + index = _this.tagsArray.indexOf(tag); + return { + tag: _this.tagsArray[index], + content: _this.popoverArray[index] + }; + }; + this.hasTag = function(tag) { + return _this.tagsArray.indexOf(tag) > -1; + }; + this.removeTagClicked = function(e) { + if (e.currentTarget.tagName === "A") { + _this.removeTag($("span", e.currentTarget.parentElement).html()); + $(e.currentTarget.parentNode).remove(); + } + return _this; + }; + this.removeLastTag = function() { + if (_this.tagsArray.length > 0) { + _this.removeTag(_this.tagsArray[_this.tagsArray.length - 1]); + if (_this.canAddByMaxNum()) { + _this.enableInput(); + } + } + return _this; + }; + this.removeTag = function(tag) { + if (_this.tagsArray.indexOf(tag) > -1) { + if (_this.beforeDeletingTag(tag) === false) { + return; + } + _this.popoverArray.splice(_this.tagsArray.indexOf(tag), 1); + _this.tagsArray.splice(_this.tagsArray.indexOf(tag), 1); + _this.renderTags(); + _this.afterDeletingTag(tag); + if (_this.canAddByMaxNum()) { + _this.enableInput(); + } + } + return _this; + }; + this.canAddByRestriction = function(tag) { + return this.restrictTo === false || this.restrictTo.indexOf(tag) !== -1; + }; + this.canAddByExclusion = function(tag) { + return (this.exclude === false || this.exclude.indexOf(tag) === -1) && !this.excludes(tag); + }; + this.canAddByMaxNum = function() { + return this.maxNumTags === -1 || this.tagsArray.length < this.maxNumTags; + }; + this.addTag = function(tag) { + var associatedContent; + if (_this.canAddByRestriction(tag) && !_this.hasTag(tag) && tag.length > 0 && _this.canAddByExclusion(tag) && _this.canAddByMaxNum()) { + if (_this.beforeAddingTag(tag) === false) { + return; + } + associatedContent = _this.definePopover(tag); + _this.popoverArray.push(associatedContent || null); + _this.tagsArray.push(tag); + _this.afterAddingTag(tag); + _this.renderTags(); + if (!_this.canAddByMaxNum()) { + _this.disableInput(); + } + } + return _this; + }; + this.addTagWithContent = function(tag, content) { + if (_this.canAddByRestriction(tag) && !_this.hasTag(tag) && tag.length > 0) { + if (_this.beforeAddingTag(tag) === false) { + return; + } + _this.tagsArray.push(tag); + _this.popoverArray.push(content); + _this.afterAddingTag(tag); + _this.renderTags(); + } + return _this; + }; + this.renameTag = function(name, newName) { + _this.tagsArray[_this.tagsArray.indexOf(name)] = newName; + _this.renderTags(); + return _this; + }; + this.setPopover = function(tag, popoverContent) { + _this.popoverArray[_this.tagsArray.indexOf(tag)] = popoverContent; + _this.renderTags(); + return _this; + }; + this.clickHandler = function(e) { + return _this.makeSuggestions(e, true); + }; + this.keyDownHandler = function(e) { + var k, numSuggestions; + k = e.keyCode != null ? e.keyCode : e.which; + switch (k) { + case 13: + e.preventDefault(); + _this.pressedReturn(e); + tag = e.target.value; + if (_this.suggestedIndex !== -1) { + tag = _this.suggestionList[_this.suggestedIndex]; + } + _this.addTag(tag); + e.target.value = ""; + _this.renderTags(); + return _this.hideSuggestions(); + + case 46: + case 8: + _this.pressedDelete(e); + if (e.target.value === "") { + _this.removeLastTag(); + } + if (e.target.value.length === 1) { + return _this.hideSuggestions(); + } + break; + + case 40: + _this.pressedDown(e); + if (_this.input.val() === "" && (_this.suggestedIndex === -1 || _this.suggestedIndex == null)) { + _this.makeSuggestions(e, true); + } + numSuggestions = _this.suggestionList.length; + _this.suggestedIndex = _this.suggestedIndex < numSuggestions - 1 ? _this.suggestedIndex + 1 : numSuggestions - 1; + _this.selectSuggested(_this.suggestedIndex); + if (_this.suggestedIndex >= 0) { + return _this.scrollSuggested(_this.suggestedIndex); + } + break; + + case 38: + _this.pressedUp(e); + _this.suggestedIndex = _this.suggestedIndex > 0 ? _this.suggestedIndex - 1 : 0; + _this.selectSuggested(_this.suggestedIndex); + if (_this.suggestedIndex >= 0) { + return _this.scrollSuggested(_this.suggestedIndex); + } + break; + + case 9: + case 27: + _this.hideSuggestions(); + return _this.suggestedIndex = -1; + } + }; + this.keyUpHandler = function(e) { + var k; + k = e.keyCode != null ? e.keyCode : e.which; + if (k !== 40 && k !== 38 && k !== 27) { + return _this.makeSuggestions(e, false); + } + }; + this.getSuggestions = function(str, overrideLengthCheck) { + var _this = this; + this.suggestionList = []; + if (this.caseInsensitive) { + str = str.toLowerCase(); + } + $.each(this.suggestions, function(i, suggestion) { + var suggestionVal; + suggestionVal = _this.caseInsensitive ? suggestion.substring(0, str.length).toLowerCase() : suggestion.substring(0, str.length); + if (_this.tagsArray.indexOf(suggestion) < 0 && suggestionVal === str && (str.length > 0 || overrideLengthCheck)) { + return _this.suggestionList.push(suggestion); + } + }); + return this.suggestionList; + }; + this.makeSuggestions = function(e, overrideLengthCheck, val) { + if (val == null) { + val = e.target.value != null ? e.target.value : e.target.textContent; + } + _this.suggestedIndex = -1; + _this.$suggestionList.html(""); + $.each(_this.getSuggestions(val, overrideLengthCheck), function(i, suggestion) { + return _this.$suggestionList.append(_this.template("tags_suggestion", { + suggestion: suggestion + })); + }); + _this.$(".tags-suggestion").mouseover(_this.selectSuggestedMouseOver); + _this.$(".tags-suggestion").click(_this.suggestedClicked); + if (_this.suggestionList.length > 0) { + return _this.showSuggestions(); + } else { + return _this.hideSuggestions(); + } + }; + this.suggestedClicked = function(e) { + tag = e.target.textContent; + if (_this.suggestedIndex !== -1) { + tag = _this.suggestionList[_this.suggestedIndex]; + } + _this.addTag(tag); + _this.input.val(""); + _this.makeSuggestions(e, false, ""); + _this.input.focus(); + return _this.hideSuggestions(); + }; + this.hideSuggestions = function() { + return _this.$(".tags-suggestion-list").css({ + display: "none" + }); + }; + this.showSuggestions = function() { + return _this.$(".tags-suggestion-list").css({ + display: "block" + }); + }; + this.selectSuggestedMouseOver = function(e) { + $(".tags-suggestion").removeClass("tags-suggestion-highlighted"); + $(e.target).addClass("tags-suggestion-highlighted"); + $(e.target).mouseout(_this.selectSuggestedMousedOut); + return _this.suggestedIndex = _this.$(".tags-suggestion").index($(e.target)); + }; + this.selectSuggestedMousedOut = function(e) { + return $(e.target).removeClass("tags-suggestion-highlighted"); + }; + this.selectSuggested = function(i) { + var tagElement; + $(".tags-suggestion").removeClass("tags-suggestion-highlighted"); + tagElement = _this.$(".tags-suggestion").eq(i); + return tagElement.addClass("tags-suggestion-highlighted"); + }; + this.scrollSuggested = function(i) { + var pos, tagElement, topElement, topPos; + tagElement = _this.$(".tags-suggestion").eq(i); + topElement = _this.$(".tags-suggestion").eq(0); + pos = tagElement.position(); + topPos = topElement.position(); + if (pos != null) { + return _this.$(".tags-suggestion-list").scrollTop(pos.top - topPos.top); + } + }; + this.adjustInputPosition = function() { + var pBottom, pLeft, pTop, pWidth, tagElement, tagPosition; + tagElement = _this.$(".tag").last(); + tagPosition = tagElement.position(); + pLeft = tagPosition != null ? tagPosition.left + tagElement.outerWidth(true) : 0; + pTop = tagPosition != null ? tagPosition.top : 0; + pWidth = _this.$element.width() - pLeft; + $(".tags-input", _this.$element).css({ + paddingLeft: Math.max(pLeft, 0), + paddingTop: Math.max(pTop, 0), + width: pWidth + }); + pBottom = tagPosition != null ? tagPosition.top + tagElement.outerHeight(true) : 22; + return _this.$element.css({ + paddingBottom: pBottom - _this.$element.height() + }); + }; + this.renderTags = function() { + var tagList; + tagList = _this.$(".tags"); + tagList.html(""); + _this.input.attr("placeholder", _this.tagsArray.length === 0 ? _this.promptText : ""); + $.each(_this.tagsArray, function(i, tag) { + tag = $(_this.formatTag(i, tag)); + $("a", tag).click(_this.removeTagClicked); + $("a", tag).mouseover(_this.toggleCloseColor); + $("a", tag).mouseout(_this.toggleCloseColor); + if (_this.displayPopovers) { + _this.initializePopoverFor(tag, _this.tagsArray[i], _this.popoverArray[i]); + } + return tagList.append(tag); + }); + return _this.adjustInputPosition(); + }; + this.renderReadOnly = function() { + var tagList; + tagList = _this.$(".tags"); + tagList.html(_this.tagsArray.length === 0 ? _this.readOnlyEmptyMessage : ""); + return $.each(_this.tagsArray, function(i, tag) { + tag = $(_this.formatTag(i, tag, true)); + if (_this.displayPopovers) { + _this.initializePopoverFor(tag, _this.tagsArray[i], _this.popoverArray[i]); + } + return tagList.append(tag); + }); + }; + this.disableInput = function() { + return this.$("input").prop("disabled", true); + }; + this.enableInput = function() { + return this.$("input").prop("disabled", false); + }; + this.initializePopoverFor = function(tag, title, content) { + options = { + title: title, + content: content, + placement: "bottom" + }; + if (_this.popoverTrigger === "hoverShowClickHide") { + $(tag).mouseover(function() { + $(tag).popover("show"); + return $(".tag").not(tag).popover("hide"); + }); + $(document).click(function() { + return $(tag).popover("hide"); + }); + } else { + options.trigger = _this.popoverTrigger; + } + return $(tag).popover(options); + }; + this.toggleCloseColor = function(e) { + var opacity, tagAnchor; + tagAnchor = $(e.currentTarget); + opacity = tagAnchor.css("opacity"); + opacity = opacity < .8 ? 1 : .6; + return tagAnchor.css({ + opacity: opacity + }); + }; + this.formatTag = function(i, tag, isReadOnly) { + var escapedTag; + if (isReadOnly == null) { + isReadOnly = false; + } + escapedTag = tag.replace("<", "<").replace(">", ">"); + return _this.template("tag", { + tag: escapedTag, + tagClass: _this.tagClass, + isPopover: _this.displayPopovers, + isReadOnly: isReadOnly, + tagSize: _this.tagSize + }); + }; + this.addDocumentListeners = function() { + return $(document).mouseup(function(e) { + var container; + container = _this.$(".tags-suggestion-list"); + if (container.has(e.target).length === 0) { + return _this.hideSuggestions(); + } + }); + }; + this.template = function(name, options) { + return Tags.Templates.Template(this.getBootstrapVersion(), name, options); + }; + this.$ = function(selector) { + return $(selector, this.$element); + }; + this.getBootstrapVersion = function() { + return Tags.bootstrapVersion || this.bootstrapVersion; + }; + this.initializeDom = function() { + return this.$element.append(this.template("tags_container")); + }; + this.init = function() { + this.$element.addClass("bootstrap-tags").addClass("bootstrap-" + this.getBootstrapVersion()); + this.initializeDom(); + if (this.readOnly) { + this.renderReadOnly(); + this.removeTag = function() {}; + this.removeTagClicked = function() {}; + this.removeLastTag = function() {}; + this.addTag = function() {}; + this.addTagWithContent = function() {}; + this.renameTag = function() {}; + return this.setPopover = function() {}; + } else { + this.input = $(this.template("input", { + tagSize: this.tagSize + })); + if (this.suggestOnClick) { + this.input.click(this.clickHandler); + } + this.input.keydown(this.keyDownHandler); + this.input.keyup(this.keyUpHandler); + this.$element.append(this.input); + this.$suggestionList = $(this.template("suggestion_list")); + this.$element.append(this.$suggestionList); + this.renderTags(); + if (!this.canAddByMaxNum()) { + this.disableInput(); + } + return this.addDocumentListeners(); + } + }; + this.init(); + return this; + }; + return $.fn.tags = function(options) { + var stopOn, tagsObject; + tagsObject = {}; + stopOn = typeof options === "number" ? options : -1; + this.each(function(i, el) { + var $el; + $el = $(el); + if ($el.data("tags") == null) { + $el.data("tags", new $.tags(this, options)); + } + if (stopOn === i || i === 0) { + return tagsObject = $el.data("tags"); + } + }); + return tagsObject; + }; + }); + }).call(this); + (function() { + window.Tags || (window.Tags = {}); + Tags.Helpers || (Tags.Helpers = {}); + Tags.Helpers.addPadding = function(string, amount, doPadding) { + if (amount == null) { + amount = 1; + } + if (doPadding == null) { + doPadding = true; + } + if (!doPadding) { + return string; + } + if (amount === 0) { + return string; + } + return Tags.Helpers.addPadding(" " + string + " ", amount - 1); + }; + }).call(this); + (function() { + var _base; + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + (_base = Tags.Templates)["2"] || (_base["2"] = {}); + Tags.Templates["2"].input = function(options) { + var tagSize; + if (options == null) { + options = {}; + } + tagSize = function() { + switch (options.tagSize) { + case "sm": + return "small"; + + case "md": + return "medium"; + + case "lg": + return "large"; + } + }(); + return ""; + }; + }).call(this); + (function() { + var _base; + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + (_base = Tags.Templates)["2"] || (_base["2"] = {}); + Tags.Templates["2"].tag = function(options) { + if (options == null) { + options = {}; + } + return "
" + Tags.Helpers.addPadding(options.tag, 2, options.isReadOnly) + " " + (options.isReadOnly ? "" : "") + "
"; + }; + }).call(this); + (function() { + var _base; + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + (_base = Tags.Templates)["3"] || (_base["3"] = {}); + Tags.Templates["3"].input = function(options) { + if (options == null) { + options = {}; + } + return ""; + }; + }).call(this); + (function() { + var _base; + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + (_base = Tags.Templates)["3"] || (_base["3"] = {}); + Tags.Templates["3"].tag = function(options) { + if (options == null) { + options = {}; + } + return "
" + Tags.Helpers.addPadding(options.tag, 2, options.isReadOnly) + " " + (options.isReadOnly ? "" : "") + "
"; + }; + }).call(this); + (function() { + var _base; + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + (_base = Tags.Templates).shared || (_base.shared = {}); + Tags.Templates.shared.suggestion_list = function(options) { + if (options == null) { + options = {}; + } + return ''; + }; + }).call(this); + (function() { + var _base; + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + (_base = Tags.Templates).shared || (_base.shared = {}); + Tags.Templates.shared.tags_container = function(options) { + if (options == null) { + options = {}; + } + return '
'; + }; + }).call(this); + (function() { + var _base; + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + (_base = Tags.Templates).shared || (_base.shared = {}); + Tags.Templates.shared.tags_suggestion = function(options) { + if (options == null) { + options = {}; + } + return "
  • " + options.suggestion + "
  • "; + }; + }).call(this); + (function() { + window.Tags || (window.Tags = {}); + Tags.Templates || (Tags.Templates = {}); + Tags.Templates.Template = function(version, templateName, options) { + if (Tags.Templates[version] != null) { + if (Tags.Templates[version][templateName] != null) { + return Tags.Templates[version][templateName](options); + } + } + return Tags.Templates.shared[templateName](options); + }; + }).call(this); +})(window.jQuery); \ No newline at end of file diff --git a/src/assets/bootstrap-tags/js/bootstrap-tags.min.js b/src/assets/bootstrap-tags/js/bootstrap-tags.min.js new file mode 100644 index 00000000..2fb1e2f5 --- /dev/null +++ b/src/assets/bootstrap-tags/js/bootstrap-tags.min.js @@ -0,0 +1,7 @@ +/*! + * bootstrap-tags 1.1.0 + * https://github.com/maxwells/bootstrap-tags + * Copyright 2013 Max Lahey; Licensed MIT + */ + +!function(a){!function(){window.Tags||(window.Tags={}),jQuery(function(){return a.tags=function(b,c){var d,e,f,g,h,i,j,k=this;null==c&&(c={});for(d in c)g=c[d],this[d]=g;if(this.bootstrapVersion||(this.bootstrapVersion="3"),this.readOnly||(this.readOnly=!1),this.suggestOnClick||(this.suggestOnClick=!1),this.suggestions||(this.suggestions=[]),this.restrictTo=null!=c.restrictTo?c.restrictTo.concat(this.suggestions):!1,this.exclude||(this.exclude=!1),this.displayPopovers=null!=c.popovers?!0:null!=c.popoverData,this.popoverTrigger||(this.popoverTrigger="hover"),this.tagClass||(this.tagClass="btn-info"),this.tagSize||(this.tagSize="md"),this.promptText||(this.promptText="Enter tags..."),this.caseInsensitive||(this.caseInsensitive=!1),this.readOnlyEmptyMessage||(this.readOnlyEmptyMessage="No tags to display..."),this.maxNumTags||(this.maxNumTags=-1),this.beforeAddingTag||(this.beforeAddingTag=function(){}),this.afterAddingTag||(this.afterAddingTag=function(){}),this.beforeDeletingTag||(this.beforeDeletingTag=function(){}),this.afterDeletingTag||(this.afterDeletingTag=function(){}),this.definePopover||(this.definePopover=function(a){return'associated content for "'+a+'"'}),this.excludes||(this.excludes=function(){return!1}),this.tagRemoved||(this.tagRemoved=function(){}),this.pressedReturn||(this.pressedReturn=function(){}),this.pressedDelete||(this.pressedDelete=function(){}),this.pressedDown||(this.pressedDown=function(){}),this.pressedUp||(this.pressedUp=function(){}),this.$element=a(b),null!=c.tagData?this.tagsArray=c.tagData:(f=a(".tag-data",this.$element).html(),this.tagsArray=null!=f?f.split(","):[]),c.popoverData)this.popoverArray=c.popoverData;else for(this.popoverArray=[],j=this.tagsArray,h=0,i=j.length;i>h;h++)e=j[h],this.popoverArray.push(null);return this.getTags=function(){return k.tagsArray},this.getTagsContent=function(){return k.popoverArray},this.getTagsWithContent=function(){var a,b,c,d;for(a=[],b=c=0,d=k.tagsArray.length-1;d>=0?d>=c:c>=d;b=d>=0?++c:--c)a.push({tag:k.tagsArray[b],content:k.popoverArray[b]});return a},this.getTag=function(a){var b;return b=k.tagsArray.indexOf(a),b>-1?k.tagsArray[b]:null},this.getTagWithContent=function(a){var b;return b=k.tagsArray.indexOf(a),{tag:k.tagsArray[b],content:k.popoverArray[b]}},this.hasTag=function(a){return k.tagsArray.indexOf(a)>-1},this.removeTagClicked=function(b){return"A"===b.currentTarget.tagName&&(k.removeTag(a("span",b.currentTarget.parentElement).html()),a(b.currentTarget.parentNode).remove()),k},this.removeLastTag=function(){return k.tagsArray.length>0&&(k.removeTag(k.tagsArray[k.tagsArray.length-1]),k.canAddByMaxNum()&&k.enableInput()),k},this.removeTag=function(a){if(k.tagsArray.indexOf(a)>-1){if(k.beforeDeletingTag(a)===!1)return;k.popoverArray.splice(k.tagsArray.indexOf(a),1),k.tagsArray.splice(k.tagsArray.indexOf(a),1),k.renderTags(),k.afterDeletingTag(a),k.canAddByMaxNum()&&k.enableInput()}return k},this.canAddByRestriction=function(a){return this.restrictTo===!1||-1!==this.restrictTo.indexOf(a)},this.canAddByExclusion=function(a){return(this.exclude===!1||-1===this.exclude.indexOf(a))&&!this.excludes(a)},this.canAddByMaxNum=function(){return-1===this.maxNumTags||this.tagsArray.length0&&k.canAddByExclusion(a)&&k.canAddByMaxNum()){if(k.beforeAddingTag(a)===!1)return;b=k.definePopover(a),k.popoverArray.push(b||null),k.tagsArray.push(a),k.afterAddingTag(a),k.renderTags(),k.canAddByMaxNum()||k.disableInput()}return k},this.addTagWithContent=function(a,b){if(k.canAddByRestriction(a)&&!k.hasTag(a)&&a.length>0){if(k.beforeAddingTag(a)===!1)return;k.tagsArray.push(a),k.popoverArray.push(b),k.afterAddingTag(a),k.renderTags()}return k},this.renameTag=function(a,b){return k.tagsArray[k.tagsArray.indexOf(a)]=b,k.renderTags(),k},this.setPopover=function(a,b){return k.popoverArray[k.tagsArray.indexOf(a)]=b,k.renderTags(),k},this.clickHandler=function(a){return k.makeSuggestions(a,!0)},this.keyDownHandler=function(a){var b,c;switch(b=null!=a.keyCode?a.keyCode:a.which){case 13:return a.preventDefault(),k.pressedReturn(a),e=a.target.value,-1!==k.suggestedIndex&&(e=k.suggestionList[k.suggestedIndex]),k.addTag(e),a.target.value="",k.renderTags(),k.hideSuggestions();case 46:case 8:if(k.pressedDelete(a),""===a.target.value&&k.removeLastTag(),1===a.target.value.length)return k.hideSuggestions();break;case 40:if(k.pressedDown(a),""!==k.input.val()||-1!==k.suggestedIndex&&null!=k.suggestedIndex||k.makeSuggestions(a,!0),c=k.suggestionList.length,k.suggestedIndex=k.suggestedIndex=0)return k.scrollSuggested(k.suggestedIndex);break;case 38:if(k.pressedUp(a),k.suggestedIndex=k.suggestedIndex>0?k.suggestedIndex-1:0,k.selectSuggested(k.suggestedIndex),k.suggestedIndex>=0)return k.scrollSuggested(k.suggestedIndex);break;case 9:case 27:return k.hideSuggestions(),k.suggestedIndex=-1}},this.keyUpHandler=function(a){var b;return b=null!=a.keyCode?a.keyCode:a.which,40!==b&&38!==b&&27!==b?k.makeSuggestions(a,!1):void 0},this.getSuggestions=function(b,c){var d=this;return this.suggestionList=[],this.caseInsensitive&&(b=b.toLowerCase()),a.each(this.suggestions,function(a,e){var f;return f=d.caseInsensitive?e.substring(0,b.length).toLowerCase():e.substring(0,b.length),d.tagsArray.indexOf(e)<0&&f===b&&(b.length>0||c)?d.suggestionList.push(e):void 0}),this.suggestionList},this.makeSuggestions=function(b,c,d){return null==d&&(d=null!=b.target.value?b.target.value:b.target.textContent),k.suggestedIndex=-1,k.$suggestionList.html(""),a.each(k.getSuggestions(d,c),function(a,b){return k.$suggestionList.append(k.template("tags_suggestion",{suggestion:b}))}),k.$(".tags-suggestion").mouseover(k.selectSuggestedMouseOver),k.$(".tags-suggestion").click(k.suggestedClicked),k.suggestionList.length>0?k.showSuggestions():k.hideSuggestions()},this.suggestedClicked=function(a){return e=a.target.textContent,-1!==k.suggestedIndex&&(e=k.suggestionList[k.suggestedIndex]),k.addTag(e),k.input.val(""),k.makeSuggestions(a,!1,""),k.input.focus(),k.hideSuggestions()},this.hideSuggestions=function(){return k.$(".tags-suggestion-list").css({display:"none"})},this.showSuggestions=function(){return k.$(".tags-suggestion-list").css({display:"block"})},this.selectSuggestedMouseOver=function(b){return a(".tags-suggestion").removeClass("tags-suggestion-highlighted"),a(b.target).addClass("tags-suggestion-highlighted"),a(b.target).mouseout(k.selectSuggestedMousedOut),k.suggestedIndex=k.$(".tags-suggestion").index(a(b.target))},this.selectSuggestedMousedOut=function(b){return a(b.target).removeClass("tags-suggestion-highlighted")},this.selectSuggested=function(b){var c;return a(".tags-suggestion").removeClass("tags-suggestion-highlighted"),c=k.$(".tags-suggestion").eq(b),c.addClass("tags-suggestion-highlighted")},this.scrollSuggested=function(a){var b,c,d,e;return c=k.$(".tags-suggestion").eq(a),d=k.$(".tags-suggestion").eq(0),b=c.position(),e=d.position(),null!=b?k.$(".tags-suggestion-list").scrollTop(b.top-e.top):void 0},this.adjustInputPosition=function(){var b,c,d,e,f,g;return f=k.$(".tag").last(),g=f.position(),c=null!=g?g.left+f.outerWidth(!0):0,d=null!=g?g.top:0,e=k.$element.width()-c,a(".tags-input",k.$element).css({paddingLeft:Math.max(c,0),paddingTop:Math.max(d,0),width:e}),b=null!=g?g.top+f.outerHeight(!0):22,k.$element.css({paddingBottom:b-k.$element.height()})},this.renderTags=function(){var b;return b=k.$(".tags"),b.html(""),k.input.attr("placeholder",0===k.tagsArray.length?k.promptText:""),a.each(k.tagsArray,function(c,d){return d=a(k.formatTag(c,d)),a("a",d).click(k.removeTagClicked),a("a",d).mouseover(k.toggleCloseColor),a("a",d).mouseout(k.toggleCloseColor),k.displayPopovers&&k.initializePopoverFor(d,k.tagsArray[c],k.popoverArray[c]),b.append(d)}),k.adjustInputPosition()},this.renderReadOnly=function(){var b;return b=k.$(".tags"),b.html(0===k.tagsArray.length?k.readOnlyEmptyMessage:""),a.each(k.tagsArray,function(c,d){return d=a(k.formatTag(c,d,!0)),k.displayPopovers&&k.initializePopoverFor(d,k.tagsArray[c],k.popoverArray[c]),b.append(d)})},this.disableInput=function(){return this.$("input").prop("disabled",!0)},this.enableInput=function(){return this.$("input").prop("disabled",!1)},this.initializePopoverFor=function(b,d,e){return c={title:d,content:e,placement:"bottom"},"hoverShowClickHide"===k.popoverTrigger?(a(b).mouseover(function(){return a(b).popover("show"),a(".tag").not(b).popover("hide")}),a(document).click(function(){return a(b).popover("hide")})):c.trigger=k.popoverTrigger,a(b).popover(c)},this.toggleCloseColor=function(b){var c,d;return d=a(b.currentTarget),c=d.css("opacity"),c=.8>c?1:.6,d.css({opacity:c})},this.formatTag=function(a,b,c){var d;return null==c&&(c=!1),d=b.replace("<","<").replace(">",">"),k.template("tag",{tag:d,tagClass:k.tagClass,isPopover:k.displayPopovers,isReadOnly:c,tagSize:k.tagSize})},this.addDocumentListeners=function(){return a(document).mouseup(function(a){var b;return b=k.$(".tags-suggestion-list"),0===b.has(a.target).length?k.hideSuggestions():void 0})},this.template=function(a,b){return Tags.Templates.Template(this.getBootstrapVersion(),a,b)},this.$=function(b){return a(b,this.$element)},this.getBootstrapVersion=function(){return Tags.bootstrapVersion||this.bootstrapVersion},this.initializeDom=function(){return this.$element.append(this.template("tags_container"))},this.init=function(){return this.$element.addClass("bootstrap-tags").addClass("bootstrap-"+this.getBootstrapVersion()),this.initializeDom(),this.readOnly?(this.renderReadOnly(),this.removeTag=function(){},this.removeTagClicked=function(){},this.removeLastTag=function(){},this.addTag=function(){},this.addTagWithContent=function(){},this.renameTag=function(){},this.setPopover=function(){}):(this.input=a(this.template("input",{tagSize:this.tagSize})),this.suggestOnClick&&this.input.click(this.clickHandler),this.input.keydown(this.keyDownHandler),this.input.keyup(this.keyUpHandler),this.$element.append(this.input),this.$suggestionList=a(this.template("suggestion_list")),this.$element.append(this.$suggestionList),this.renderTags(),this.canAddByMaxNum()||this.disableInput(),this.addDocumentListeners())},this.init(),this},a.fn.tags=function(b){var c,d;return d={},c="number"==typeof b?b:-1,this.each(function(e,f){var g;return g=a(f),null==g.data("tags")&&g.data("tags",new a.tags(this,b)),c===e||0===e?d=g.data("tags"):void 0}),d}})}.call(this),function(){window.Tags||(window.Tags={}),Tags.Helpers||(Tags.Helpers={}),Tags.Helpers.addPadding=function(a,b,c){return null==b&&(b=1),null==c&&(c=!0),c?0===b?a:Tags.Helpers.addPadding(" "+a+" ",b-1):a}}.call(this),function(){var a;window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),(a=Tags.Templates)["2"]||(a["2"]={}),Tags.Templates["2"].input=function(a){var b;return null==a&&(a={}),b=function(){switch(a.tagSize){case"sm":return"small";case"md":return"medium";case"lg":return"large"}}(),""}}.call(this),function(){var a;window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),(a=Tags.Templates)["2"]||(a["2"]={}),Tags.Templates["2"].tag=function(a){return null==a&&(a={}),"
    "+Tags.Helpers.addPadding(a.tag,2,a.isReadOnly)+" "+(a.isReadOnly?"":"")+"
    "}}.call(this),function(){var a;window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),(a=Tags.Templates)["3"]||(a["3"]={}),Tags.Templates["3"].input=function(a){return null==a&&(a={}),""}}.call(this),function(){var a;window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),(a=Tags.Templates)["3"]||(a["3"]={}),Tags.Templates["3"].tag=function(a){return null==a&&(a={}),"
    "+Tags.Helpers.addPadding(a.tag,2,a.isReadOnly)+" "+(a.isReadOnly?"":"")+"
    "}}.call(this),function(){var a;window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),(a=Tags.Templates).shared||(a.shared={}),Tags.Templates.shared.suggestion_list=function(a){return null==a&&(a={}),''}}.call(this),function(){var a;window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),(a=Tags.Templates).shared||(a.shared={}),Tags.Templates.shared.tags_container=function(a){return null==a&&(a={}),'
    '}}.call(this),function(){var a;window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),(a=Tags.Templates).shared||(a.shared={}),Tags.Templates.shared.tags_suggestion=function(a){return null==a&&(a={}),"
  • "+a.suggestion+"
  • "}}.call(this),function(){window.Tags||(window.Tags={}),Tags.Templates||(Tags.Templates={}),Tags.Templates.Template=function(a,b,c){return null!=Tags.Templates[a]&&null!=Tags.Templates[a][b]?Tags.Templates[a][b](c):Tags.Templates.shared[b](c)}}.call(this)}(window.jQuery); \ No newline at end of file diff --git a/src/assets/css/bootstrap-tags.css b/src/assets/css/bootstrap-tags.css deleted file mode 100755 index 786214d9..00000000 --- a/src/assets/css/bootstrap-tags.css +++ /dev/null @@ -1,62 +0,0 @@ -/* bootstrap-tags styles */ - -.tag-list { - width: 280px; - height: 26px; - left:2px; - top:2px; - position:relative; -} -.tag-data { - display:none; -} -.tags-input { - width:100%; - height:100% !important; - margin:0; - padding-bottom:0 !important; - font-size:12px !important; -} -.tags { - width:inherit; - height:0; - position:absolute; - padding:0; - margin:0; -} -.tag { - padding: 1px 3px; - margin:1px; - float:left; -} -.tag a { - color: #bbb; - cursor:pointer; - opacity: .5; -} -ul.tags-suggestion-list { - width:100%; - height:auto; - list-style:none; - margin:0; - position:absolute; - z-index:2; - max-height:160px; - overflow: auto; -} -li.tags-suggestion { - padding:3px 20px; - height:auto; -} -li.tags-suggestion-highlighted { - color: white; - text-decoration: none; - background-color: #0081C2; - background-image: -moz-linear-gradient(top, #08C, #0077B3); - background-image: -webkit-gradient(linear, 0 0, 0 100%, from(#08C), to(#0077B3)); - background-image: -webkit-linear-gradient(top, #08C, #0077B3); - background-image: -o-linear-gradient(top, #08C, #0077B3); - background-image: linear-gradient(to bottom, #08C, #0077B3); - background-repeat: repeat-x; - filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ff0088cc', endColorstr='#ff0077b3', GradientType=0); -} \ No newline at end of file diff --git a/src/assets/js/bootstrap.tags.js b/src/assets/js/bootstrap.tags.js deleted file mode 100755 index 618b2178..00000000 --- a/src/assets/js/bootstrap.tags.js +++ /dev/null @@ -1,315 +0,0 @@ -// Generated by CoffeeScript 1.4.0 -(function() { - - jQuery(function() { - $.tags = function(element, options) { - var tagData, - _this = this; - this.suggestions = (options.suggestions != null ? options.suggestions : []); - this.restrictTo = (options.restrictTo != null ? options.restrictTo.concat(this.suggestions) : false); - this.exclude = (options.excludeList != null ? options.excludeList : false); - this.displayPopovers = (options.popovers != null ? true : options.popoverData != null); - this.tagClass = (options.tagClass != null ? options.tagClass : 'btn-info'); - this.promptText = (options.promptText != null ? options.promptText : 'Enter tags...'); - this.whenAddingTag = (options.whenAddingTag != null ? options.whenAddingTag : function(tag) {}); - this.definePopover = (options.definePopover ? options.definePopover : function(tag) { - return "associated content for \"" + tag + "\""; - }); - this.excludes = (options.excludes ? options.excludes : function() { - return false; - }); - this.tagRemoved = (options.tagRemoved ? options.tagRemoved : function(tag) {}); - this.pressedReturn = (options.pressedReturn != null ? options.pressedReturn : function(e) {}); - this.pressedDelete = (options.pressedDelete != null ? options.pressedDelete : function(e) {}); - this.pressedDown = (options.pressedDown != null ? options.pressedDown : function(e) {}); - this.pressedUp = (options.pressedUp != null ? options.pressedUp : function(e) {}); - this.$element = $(element); - if (options.tagData != null) { - this.tagsArray = options.tagData; - } else { - tagData = $('.tag-data', this.$element).html(); - this.tagsArray = (tagData != null ? tagData.split(',') : []); - } - if (this.displayPopovers) { - this.popoverArray = options.popoverData; - } - this.getTags = function() { - return _this.tagsArray; - }; - this.removeTagClicked = function(e) { - if (e.currentTarget.tagName === "A") { - _this.removeTag(e.currentTarget.previousSibling.textContent); - $(e.currentTarget.parentNode).remove(); - } - return _this; - }; - this.removeLastTag = function() { - var el; - el = $('.tag', _this.$element).last(); - el.remove(); - _this.removeTag(_this.tagsArray[_this.tagsArray.length - 1]); - return _this; - }; - this.removeTag = function(tag) { - if (_this.tagsArray.indexOf(tag) > -1) { - if (_this.displayPopovers) { - _this.popoverArray.splice(_this.tagsArray.indexOf(tag), 1); - } - _this.tagsArray.splice(_this.tagsArray.indexOf(tag), 1); - _this.renderTags(); - _this.tagRemoved(tag); - } - return _this; - }; - this.addTag = function(tag) { - var associatedContent; - if ((_this.restrictTo === false || _this.restrictTo.indexOf(tag) !== -1) && _this.tagsArray.indexOf(tag) < 0 && tag.length > 0 && (_this.exclude === false || _this.exclude.indexOf(tag) === -1) && !_this.excludes(tag)) { - _this.whenAddingTag(tag); - if (_this.displayPopovers) { - associatedContent = _this.definePopover(tag); - _this.popoverArray.push(associatedContent); - } - _this.tagsArray.push(tag); - _this.renderTags(); - } - return _this; - }; - this.addTagWithContent = function(tag, content) { - if ((_this.restrictTo === false || _this.restrictTo.indexOf(tag) !== -1) && _this.tagsArray.indexOf(tag) < 0 && tag.length > 0) { - _this.whenAddingTag(tag); - _this.tagsArray.push(tag); - _this.popoverArray.push(content); - _this.renderTags(); - } - return _this; - }; - this.renameTag = function(name, newName) { - _this.tagsArray[_this.tagsArray.indexOf(name)] = newName; - _this.renderTags(); - return _this; - }; - this.setPopover = function(tag, popoverContent) { - _this.popoverArray[_this.tagsArray.indexOf(tag)] = popoverContent; - _this.renderTags(); - return _this; - }; - this.keyDownHandler = function(e) { - var k, numSuggestions, tag; - k = (e.keyCode != null ? e.keyCode : e.which); - switch (k) { - case 13: - _this.pressedReturn(e); - tag = e.target.value; - if (_this.suggestedIndex !== -1) { - tag = _this.suggestionList[_this.suggestedIndex]; - } - _this.addTag(tag); - e.target.value = ''; - _this.renderTags(); - return _this.hideSuggestions(); - case 46: - case 8: - _this.pressedDelete(e); - if (e.target.value === '') { - _this.removeLastTag(); - } - if (e.target.value.length === 1) { - return _this.hideSuggestions(); - } - break; - case 40: - _this.pressedDown(e); - if (_this.input.val() === '' && (_this.suggestedIndex === -1 || !(_this.suggestedIndex != null))) { - _this.makeSuggestions(e, true); - } - numSuggestions = _this.suggestionList.length; - _this.suggestedIndex = (_this.suggestedIndex < numSuggestions - 1 ? _this.suggestedIndex + 1 : numSuggestions - 1); - _this.selectSuggested(_this.suggestedIndex); - if (_this.suggestedIndex >= 0) { - return _this.scrollSuggested(_this.suggestedIndex); - } - break; - case 38: - _this.pressedUp(e); - _this.suggestedIndex = (_this.suggestedIndex > 0 ? _this.suggestedIndex - 1 : 0); - _this.selectSuggested(_this.suggestedIndex); - if (_this.suggestedIndex >= 0) { - return _this.scrollSuggested(_this.suggestedIndex); - } - break; - case 9: - case 27: - _this.hideSuggestions(); - return _this.suggestedIndex = -1; - } - }; - this.keyUpHandler = function(e) { - var k; - k = (e.keyCode != null ? e.keyCode : e.which); - if (k !== 40 && k !== 38 && k !== 27) { - return _this.makeSuggestions(e, false); - } - }; - this.makeSuggestions = function(e, overrideLengthCheck) { - var val; - val = (e.target.value != null ? e.target.value : e.target.textContent); - _this.suggestedIndex = -1; - _this.$suggestionList.html(''); - _this.suggestionList = []; - $.each(_this.suggestions, function(i, suggestion) { - if (_this.tagsArray.indexOf(suggestion) < 0 && suggestion.substring(0, val.length) === val && (val.length > 0 || overrideLengthCheck)) { - _this.$suggestionList.append('
  • ' + suggestion + '
  • '); - return _this.suggestionList.push(suggestion); - } - }); - $('.tags-suggestion', _this.$element).mouseover(_this.selectSuggestedMouseOver); - $('.tags-suggestion', _this.$element).click(_this.suggestedClicked); - if (_this.suggestionList.length > 0) { - return _this.showSuggestions(); - } else { - return _this.hideSuggestions(); - } - }; - this.suggestedClicked = function(e) { - var tag; - tag = e.target.textContent; - if (_this.suggestedIndex !== -1) { - tag = _this.suggestionList[_this.suggestedIndex]; - } - _this.addTag(tag); - _this.input.val(''); - _this.makeSuggestions(e, false); - _this.input.focus(); - return _this.hideSuggestions(); - }; - this.hideSuggestions = function() { - return $('.tags-suggestion-list', _this.$element).css({ - display: "none" - }); - }; - this.showSuggestions = function() { - return $('.tags-suggestion-list', _this.$element).css({ - display: "block" - }); - }; - this.selectSuggestedMouseOver = function(e) { - $('.tags-suggestion').removeClass('tags-suggestion-highlighted'); - $(e.target).addClass('tags-suggestion-highlighted'); - $(e.target).mouseout(_this.selectSuggestedMousedOut); - return _this.suggestedIndex = $('.tags-suggestion', _this.$element).index($(e.target)); - }; - this.selectSuggestedMousedOut = function(e) { - return $(e.target).removeClass('tags-suggestion-highlighted'); - }; - this.selectSuggested = function(i) { - var tagElement; - $('.tags-suggestion').removeClass('tags-suggestion-highlighted'); - tagElement = $('.tags-suggestion', _this.$element).eq(i); - return tagElement.addClass('tags-suggestion-highlighted'); - }; - this.scrollSuggested = function(i) { - var pos, tagElement, topElement, topPos; - tagElement = $('.tags-suggestion', _this.$element).eq(i); - topElement = $('.tags-suggestion', _this.$element).eq(0); - pos = tagElement.position(); - topPos = topElement.position(); - if (pos != null) { - return $('.tags-suggestion-list', _this.$element).scrollTop(pos.top - topPos.top); - } - }; - this.adjustInputPosition = function() { - var pBottom, pLeft, pTop, tagElement, tagPosition; - tagElement = $('.tag', _this.$element).last(); - tagPosition = tagElement.position(); - pLeft = tagPosition != null ? tagPosition.left + tagElement.outerWidth(true) : 0; - pTop = tagPosition != null ? tagPosition.top : 0; - $('.tags-input', _this.$element).css({ - paddingLeft: pLeft, - paddingTop: pTop - }); - pBottom = tagPosition != null ? tagPosition.top + tagElement.outerHeight(true) : 22; - return _this.$element.css({ - height: pBottom - }); - }; - this.renderTags = function() { - var tagList; - tagList = $('.tags', _this.$element); - tagList.html(''); - _this.input.attr('placeholder', (_this.tagsArray.length === 0 ? _this.promptText : '')); - $.each(_this.tagsArray, function(i, tag) { - tag = $(_this.formatTag(i, tag)); - $('a', tag).click(_this.removeTagClicked); - $('a', tag).mouseover(_this.toggleCloseColor); - $('a', tag).mouseout(_this.toggleCloseColor); - if (_this.displayPopovers) { - $('span', tag).mouseover(function() { - return tag.popover('show'); - }); - $('span', tag).mouseout(function() { - return tag.popover('hide'); - }); - } - return tagList.append(tag); - }); - return _this.adjustInputPosition(); - }; - this.toggleCloseColor = function(e) { - var opacity, tagAnchor; - tagAnchor = $(e.currentTarget); - opacity = tagAnchor.css('opacity'); - opacity = (opacity < 0.8 ? 1.0 : 0.6); - return tagAnchor.css({ - opacity: opacity - }); - }; - this.formatTag = function(i, tag) { - var popoverContent; - if (_this.displayPopovers === true) { - popoverContent = _this.popoverArray[_this.tagsArray.indexOf(tag)]; - return "
    " + tag + "
    "; - } else { - return "
    " + tag + "
    "; - } - }; - this.addDocumentListeners = function() { - return $(document).mouseup(function(e) { - var container; - container = $('.tags-suggestion-list', _this.$element); - if (container.has(e.target).length === 0) { - return _this.hideSuggestions(); - } - }); - }; - this.init = function() { - this.input = $(""); - this.input.keydown(this.keyDownHandler); - this.input.keyup(this.keyUpHandler); - this.$element.append(this.input); - this.$suggestionList = $(''); - this.$element.append(this.$suggestionList); - this.renderTags(); - return this.addDocumentListeners(); - }; - this.init(); - return this; - }; - return $.fn.tags = function(options) { - var stopOn, tagsObject; - tagsObject = {}; - stopOn = (typeof options === "number" ? options : -1); - this.each(function(i, el) { - var $el; - $el = $(el); - if ($el.data('tags') == null) { - $el.data('tags', new $.tags(this, options)); - } - if (stopOn === i || i === 0) { - return tagsObject = $el.data('tags'); - } - }); - return tagsObject; - }; - }); - -}).call(this); diff --git a/src/components/Booster.php b/src/components/Booster.php index 05f8e276..6db58b5f 100644 --- a/src/components/Booster.php +++ b/src/components/Booster.php @@ -349,7 +349,7 @@ protected function registerJsPackagesIfEnabled() { */ public function getVersion() { - return '4.0.0-beta-2'; + return '4.0.0'; } /** diff --git a/src/components/packages.php b/src/components/packages.php index 80f2a60b..a1c214e8 100644 --- a/src/components/packages.php +++ b/src/components/packages.php @@ -159,4 +159,10 @@ 'css' => array('css/typeahead.css'), 'js' => array($this->minify ? 'js/typeahead.bundle.min.js' : 'js/typeahead.bundle.js'), ), + 'bootstrap-tags' => array( + 'depends' => array('jquery'), + 'baseUrl' => $this->getAssetsUrl() . '/bootstrap-tags', + 'css' => array('css/bootstrap-tags.css'), + 'js' => array($this->minify ? 'js/bootstrap-tags.min.js' : 'js/bootstrap-tags.js'), + ), ); diff --git a/src/widgets/TbTags.php b/src/widgets/TbTags.php index 09a416a9..bb8aa6fe 100644 --- a/src/widgets/TbTags.php +++ b/src/widgets/TbTags.php @@ -15,8 +15,8 @@ * * @package booster.widgets.forms.inputs */ -class TbTags extends CInputWidget -{ +class TbTags extends CInputWidget { + /** * @var TbActiveForm when created via TbActiveForm * @@ -114,8 +114,10 @@ class TbTags extends CInputWidget * * Initializes the widget. */ - public function init() - { + public function init() { + + parent::init(); + $this->options = CMap::mergeArray( array( 'suggestions' => $this->suggestions, @@ -135,8 +137,8 @@ public function init() * * Runs the widget. */ - public function run() - { + public function run() { + list($name, $id) = $this->resolveNameID(); $this->renderContent($id, $name); @@ -153,8 +155,7 @@ public function run() * * @return string with HTML tags */ - public function renderContent($id, $name) - { + public function renderContent($id, $name) { if ($this->hasModel()) { if ($this->form) { @@ -167,7 +168,15 @@ public function renderContent($id, $name) echo CHtml::hiddenField($name, $this->value); } - echo "
    "; + $this->htmlOptions['id'] = 'tags_'.$id; + if(isset($this->htmlOptions['class']) && !empty($this->htmlOptions['class'])) + $this->htmlOptions['class'] .= ' tag-list'; + else + $this->htmlOptions['class'] = 'tag-list'; + + echo CHtml::openTag('div', $this->htmlOptions); + echo "
    "; + echo CHtml::closeTag('div'); } /** @@ -179,11 +188,10 @@ public function renderContent($id, $name) * * @param string $id */ - public function registerClientScript($id) - { + public function registerClientScript($id) { + $booster = Booster::getBooster(); - $booster->registerAssetCss('bootstrap-tags.css'); - $booster->registerAssetJs('bootstrap.tags.js'); + $booster->registerPackage('bootstrap-tags'); $options = !empty($this->options) ? CJavaScript::encode($this->options) : '';