From 75d52dea17a72054538ddcc0904052c98b819a6a Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Mon, 4 Feb 2019 16:53:54 +0100 Subject: [PATCH] Move core/systemtags to webpack * Use webpack to bundle the core systemtags so the webserver can serve them statically * Bundle the core scss in there as well (saves a request) Signed-off-by: Roeland Jago Douma --- apps/systemtags/appinfo/app.php | 3 +- core/js/dist/systemtags.js | 2 + core/js/dist/systemtags.js.map | 1 + core/js/systemtags/merged-systemtags.js | 8 + core/js/systemtags/merged.json | 8 - core/webpack.common.js | 13 +- package-lock.json | 1314 ++++++++++++++++++++++- package.json | 2 + 8 files changed, 1330 insertions(+), 21 deletions(-) create mode 100644 core/js/dist/systemtags.js create mode 100644 core/js/dist/systemtags.js.map create mode 100644 core/js/systemtags/merged-systemtags.js delete mode 100644 core/js/systemtags/merged.json diff --git a/apps/systemtags/appinfo/app.php b/apps/systemtags/appinfo/app.php index 6f47827348..0fcf413486 100644 --- a/apps/systemtags/appinfo/app.php +++ b/apps/systemtags/appinfo/app.php @@ -33,9 +33,8 @@ $eventDispatcher->addListener( 'OCA\Files::loadAdditionalScripts', function() { // FIXME: no public API for these ? - \OCP\Util::addScript('systemtags/merged'); + \OCP\Util::addScript('dist/systemtags'); \OCP\Util::addScript('systemtags', 'merged'); - \OCP\Util::addStyle('systemtags'); \OCP\Util::addStyle('systemtags', 'systemtagsfilelist'); } ); diff --git a/core/js/dist/systemtags.js b/core/js/dist/systemtags.js new file mode 100644 index 0000000000..6501a3e57c --- /dev/null +++ b/core/js/dist/systemtags.js @@ -0,0 +1,2 @@ +!function(e){var t={};function n(s){if(t[s])return t[s].exports;var i=t[s]={i:s,l:!1,exports:{}};return e[s].call(i.exports,i,i.exports,n),i.l=!0,i.exports}n.m=e,n.c=t,n.d=function(e,t,s){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:s})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var s=Object.create(null);if(n.r(s),Object.defineProperty(s,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)n.d(s,i,function(t){return e[t]}.bind(null,i));return s},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=10)}([,,,,,,,,,,function(e,t,n){"use strict";n.r(t);n(11),n(12),n(13),n(14),n(15),n(16),n(17)},function(e,n){!function(e){e.SystemTags={getDescriptiveTag:function(e){if(_.isUndefined(e.name)&&!_.isUndefined(e.toJSON)&&(e=e.toJSON()),_.isUndefined(e.name))return $("").addClass("non-existing-tag").text(t("core","Non-existing tag #{tag}",{tag:e}));var n,s=$("");if(s.append(escapeHTML(e.name)),e.userAssignable||(n=t("core","restricted")),e.userVisible||(n=t("core","invisible")),n){var i=$("").text(" "+t("core","({scope})",{scope:n}));s.append(i)}return s}}}(OC)},function(e,t){function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var s,i;s=Handlebars.template,(i=OC.SystemTags.Templates=OC.SystemTags.Templates||{}).result=s({1:function(e,t,n,s,i){return" new-item"},3:function(e,t,n,s,i){var a,o;return'\t\t'+(null!=(a="function"==typeof(o=null!=(o=n.tagMarkup||(null!=t?t.tagMarkup:t))?o:n.helperMissing)?o.call(null!=t?t:e.nullContext||{},{name:"tagMarkup",hash:{},data:i}):o)?a:"")+"\n"},5:function(e,t,n,s,i){var a;return'\t\t'+e.escapeExpression("function"==typeof(a=null!=(a=n.name||(null!=t?t.name:t))?a:n.helperMissing)?a.call(null!=t?t:e.nullContext||{},{name:"name",hash:{},data:i}):a)+"\n"},7:function(e,t,n,s,i){var a;return'\t\t\n\t\t\t\n\t\t\n'},compiler:[7,">= 4.0.0"],main:function(e,t,s,i,a){var o,l,r,c=null!=t?t:e.nullContext||{},u=s.helperMissing,d='\n\n'+(null!=(o=s.if.call(c,null!=t?t.isAdmin:t,{name:"if",hash:{},fn:e.program(3,a,0),inverse:e.program(5,a,0),data:a}))?o:"");return l=null!=(l=s.allowActions||(null!=t?t.allowActions:t))?l:u,r={name:"allowActions",hash:{},fn:e.program(7,a,0),inverse:e.noop,data:a},o="function"===n(l)?l.call(c,r):l,s.allowActions||(o=s.blockHelperMissing.call(t,o,r)),null!=o&&(d+=o),d+"\n"},useData:!0}),i.result_form=s({1:function(e,t,n,s,i){var a;return'\t\t\n'},compiler:[7,">= 4.0.0"],main:function(e,t,s,i,a){var o,l,r=null!=t?t:e.nullContext||{},c=s.helperMissing,u=e.escapeExpression;return'
\n\t \n\t\n'+(null!=(o=s.if.call(r,null!=t?t.isAdmin:t,{name:"if",hash:{},fn:e.program(1,a,0),inverse:e.noop,data:a}))?o:"")+"
\n"},useData:!0}),i.selection=s({1:function(e,t,n,s,i){var a,o;return'\t'+(null!=(a="function"==typeof(o=null!=(o=n.tagMarkup||(null!=t?t.tagMarkup:t))?o:n.helperMissing)?o.call(null!=t?t:e.nullContext||{},{name:"tagMarkup",hash:{},data:i}):o)?a:"")+"\n"},3:function(e,t,n,s,i){var a;return'\t'+e.escapeExpression("function"==typeof(a=null!=(a=n.name||(null!=t?t.name:t))?a:n.helperMissing)?a.call(null!=t?t:e.nullContext||{},{name:"name",hash:{},data:i}):a)+"\n"},compiler:[7,">= 4.0.0"],main:function(e,t,n,s,i){var a;return null!=(a=n.if.call(null!=t?t:e.nullContext||{},null!=t?t.isAdmin:t,{name:"if",hash:{},fn:e.program(1,i,0),inverse:e.program(3,i,0),data:i}))?a:""},useData:!0})},function(e,t){!function(e){_.extend(e.Files.Client,{PROPERTY_FILEID:"{"+e.Files.Client.NS_OWNCLOUD+"}id",PROPERTY_CAN_ASSIGN:"{"+e.Files.Client.NS_OWNCLOUD+"}can-assign",PROPERTY_DISPLAYNAME:"{"+e.Files.Client.NS_OWNCLOUD+"}display-name",PROPERTY_USERVISIBLE:"{"+e.Files.Client.NS_OWNCLOUD+"}user-visible",PROPERTY_USERASSIGNABLE:"{"+e.Files.Client.NS_OWNCLOUD+"}user-assignable"});var t=e.Backbone.Model.extend({sync:e.Backbone.davSync,defaults:{userVisible:!0,userAssignable:!0,canAssign:!0},davProperties:{id:e.Files.Client.PROPERTY_FILEID,name:e.Files.Client.PROPERTY_DISPLAYNAME,userVisible:e.Files.Client.PROPERTY_USERVISIBLE,userAssignable:e.Files.Client.PROPERTY_USERASSIGNABLE,canAssign:e.Files.Client.PROPERTY_CAN_ASSIGN},parse:function(e){return{id:e.id,name:e.name,userVisible:!0===e.userVisible||"true"===e.userVisible,userAssignable:!0===e.userAssignable||"true"===e.userAssignable,canAssign:!0===e.canAssign||"true"===e.canAssign}}});e.SystemTags=e.SystemTags||{},e.SystemTags.SystemTagModel=t}(OC)},function(e,t){!function(e){var t=e.Backbone.Collection.extend({sync:e.Backbone.davSync,usePUT:!0,_objectId:null,_objectType:"files",model:e.SystemTags.SystemTagModel,url:function(){return e.linkToRemote("dav")+"/systemtags-relations/"+this._objectType+"/"+this._objectId},setObjectId:function(e){this._objectId=e},setObjectType:function(e){this._objectType=e},initialize:function(e,t){t=t||{},_.isUndefined(t.objectId)||(this._objectId=t.objectId),_.isUndefined(t.objectType)||(this._objectType=t.objectType)},getTagIds:function(){return this.map(function(e){return e.id})}});e.SystemTags=e.SystemTags||{},e.SystemTags.SystemTagsMappingCollection=t}(OC)},function(e,t){!function(e){var t=e.Backbone.Collection.extend({sync:e.Backbone.davSync,model:e.SystemTags.SystemTagModel,url:function(){return e.linkToRemote("dav")+"/systemtags/"},filterByName:function(e){return this.filter(function(t){return function(e,t){return e.get("name").substr(0,t.length).toLowerCase()===t.toLowerCase()}(t,e)})},reset:function(){return this.fetched=!1,e.Backbone.Collection.prototype.reset.apply(this,arguments)},fetch:function(t){var n=this;if(t=t||{},this.fetched||t.force)return t.success&&t.success(this,null,t),this.trigger("sync",this,null,t),Promise.resolve();var s=t.success;return(t=_.extend({},t)).success=function(){if(n.fetched=!0,s)return s.apply(this,arguments)},e.Backbone.Collection.prototype.fetch.call(this,t)}});e.SystemTags=e.SystemTags||{},e.SystemTags.SystemTagsCollection=t,e.SystemTags.collection=new e.SystemTags.SystemTagsCollection}(OC)},function(e,n){!function(e){var n=e.Backbone.View.extend({_rendered:!1,_newTag:null,_lastUsedTags:[],className:"systemTagsInputFieldContainer",template:function(e){return''},initialize:function(t){t=t||{},this._multiple=!!t.multiple,this._allowActions=_.isUndefined(t.allowActions)||!!t.allowActions,this._allowCreate=_.isUndefined(t.allowCreate)||!!t.allowCreate,this._isAdmin=!!t.isAdmin,_.isFunction(t.initSelection)&&(this._initSelection=t.initSelection),this.collection=t.collection||e.SystemTags.collection;var n=this;this.collection.on("change:name remove",function(){_.defer(n._refreshSelection)}),_.defer(_.bind(this._getLastUsedTags,this)),_.bindAll(this,"_refreshSelection","_onClickRenameTag","_onClickDeleteTag","_onSelectTag","_onDeselectTag","_onSubmitRenameTag")},_getLastUsedTags:function(){var t=this;$.ajax({type:"GET",url:e.generateUrl("/apps/systemtags/lastused"),success:function(e){t._lastUsedTags=e}})},_refreshSelection:function(){this.$tagsField.select2("val",this.$tagsField.val())},_onClickRenameTag:function(n){var s=$(n.target).closest(".systemtags-item"),i=s.attr("data-id"),a=this.collection.get(i).get("name"),o=$(e.SystemTags.Templates.result_form({cid:this.cid,name:a,deleteTooltip:t("core","Delete"),renameLabel:t("core","Rename"),isAdmin:this._isAdmin}));return s.find(".label").after(o),s.find(".label, .systemtags-actions").addClass("hidden"),s.closest(".select2-result").addClass("has-form"),o.find("[title]").tooltip({placement:"bottom",container:"body"}),o.find("input").focus().selectRange(0,a.length),!1},_onSubmitRenameTag:function(e){e.preventDefault();var t=$(e.target),n=t.closest(".systemtags-item"),s=n.attr("data-id"),i=this.collection.get(s),a=$(e.target).find("input").val().trim();a&&a!==i.get("name")&&(i.save({name:a}),n.find(".label").text(a)),n.find(".label, .systemtags-actions").removeClass("hidden"),t.remove(),n.closest(".select2-result").removeClass("has-form")},_onClickDeleteTag:function(e){var t=$(e.target).closest(".systemtags-item"),n=t.attr("data-id");return this.collection.get(n).destroy(),$(e.target).tooltip("hide"),t.closest(".select2-result").remove(),!1},_addToSelect2Selection:function(e){var t=this.$tagsField.select2("data");t.push(e),this.$tagsField.select2("data",t)},_onSelectTag:function(e){var t,n=this;if(e.object&&e.object.isNew)return t=this.collection.create({name:e.object.name.trim(),userVisible:!0,userAssignable:!0,canAssign:!0},{success:function(e){n._addToSelect2Selection(e.toJSON()),n._lastUsedTags.unshift(e.id),n.trigger("select",e)},error:function(t,s){409===s.status&&(n.collection.reset(),n.collection.fetch({success:function(t){var s=t.where({name:e.object.name.trim(),userVisible:!0,userAssignable:!0});s.length&&(s=s[0],n._addToSelect2Selection(s.toJSON()),n.trigger("select",s))}}))}}),this.$tagsField.select2("close"),e.preventDefault(),!1;t=this.collection.get(e.object.id),this._lastUsedTags.unshift(t.id),this._newTag=null,this.trigger("select",t)},_onDeselectTag:function(e){this.trigger("deselect",e.choice.id)},_queryTagsAutocomplete:function(e){var t=this;this.collection.fetch({success:function(n){var s=n.filterByName(e.term.trim());t._isAdmin||(s=_.filter(s,function(e){return e.get("canAssign")})),e.callback({results:_.invoke(s,"toJSON")})}})},_preventDefault:function(e){e.stopPropagation()},_formatDropDownResult:function(n){return e.SystemTags.Templates.result(_.extend({renameTooltip:t("core","Rename"),allowActions:this._allowActions,tagMarkup:this._isAdmin?e.SystemTags.getDescriptiveTag(n)[0].innerHTML:null,isAdmin:this._isAdmin},n))},_formatSelection:function(t){return e.SystemTags.Templates.selection(_.extend({tagMarkup:this._isAdmin?e.SystemTags.getDescriptiveTag(t)[0].innerHTML:null,isAdmin:this._isAdmin},t))},_createSearchChoice:function(e){if(e=e.trim(),!this.collection.filter(function(t){return t.get("name")===e}).length)return this._newTag?this._newTag.name=e:this._newTag={id:-1,name:e,userAssignable:!0,userVisible:!0,canAssign:!0,isNew:!0},this._newTag},_initSelection:function(e,t){var n=this,s=$(e).val().split(",");function i(e){var t=e.toJSON();return n._isAdmin||t.canAssign||(t.locked=!0),t}this.collection.fetch({success:function(){t(function(e){var t=n.collection.filter(function(t){return e.indexOf(t.id)>=0&&(n._isAdmin||t.get("userVisible"))});return _.map(t,i)}(s))}})},render:function(){var n=this;this.$el.html(this.template()),this.$el.find("[title]").tooltip({placement:"bottom"}),this.$tagsField=this.$el.find("[name=tags]"),this.$tagsField.select2({placeholder:t("core","Collaborative tags"),containerCssClass:"systemtags-select2-container",dropdownCssClass:"systemtags-select2-dropdown",closeOnSelect:!1,allowClear:!1,multiple:this._multiple,toggleSelect:this._multiple,query:_.bind(this._queryTagsAutocomplete,this),id:function(e){return e.id},initSelection:_.bind(this._initSelection,this),formatResult:_.bind(this._formatDropDownResult,this),formatSelection:_.bind(this._formatSelection,this),createSearchChoice:this._allowCreate?_.bind(this._createSearchChoice,this):void 0,sortResults:function(t){var s=_.pluck(n.$tagsField.select2("data"),"id");return t.sort(function(t,i){var a=s.indexOf(t.id)>=0,o=s.indexOf(i.id)>=0;if(a===o){var l=n._lastUsedTags.indexOf(t.id),r=n._lastUsedTags.indexOf(i.id);return l!==r?-1===r?-1:-1===l?1:l\n * @copyright Copyright (c) 2016, Robin Appelman \n * @copyright Copyright (c) 2016, Jan-Christoph Borchardt \n * @copyright Copyright (c) 2016, Vincent Petry \n * @copyright Copyright (c) 2016, Erik Pellikka \n * @copyright Copyright (c) 2015, Vincent Petry \n *\n * @license GNU AGPL version 3 or any later version\n *\n */\n.systemtags-select2-dropdown .select2-result-label .checkmark {\n visibility: hidden;\n margin-left: -5px;\n margin-right: 5px;\n padding: 4px; }\n\n.systemtags-select2-dropdown .select2-result-label .new-item .systemtags-actions {\n display: none; }\n\n.systemtags-select2-dropdown .select2-selected .select2-result-label .checkmark {\n visibility: visible; }\n\n.systemtags-select2-dropdown .select2-result-label .icon {\n display: inline-block;\n opacity: .5; }\n .systemtags-select2-dropdown .select2-result-label .icon.rename {\n padding: 4px; }\n\n.systemtags-select2-dropdown .systemtags-actions {\n position: absolute;\n right: 5px; }\n\n.systemtags-select2-dropdown .systemtags-rename-form {\n display: inline-block;\n width: calc(100% - 20px);\n top: -6px;\n position: relative; }\n .systemtags-select2-dropdown .systemtags-rename-form input {\n display: inline-block;\n height: 30px;\n width: calc(100% - 40px); }\n\n.systemtags-select2-dropdown .label {\n width: 85%;\n display: inline-block;\n overflow: hidden;\n text-overflow: ellipsis; }\n .systemtags-select2-dropdown .label.hidden {\n display: none; }\n\n.systemtags-select2-dropdown span {\n line-height: 25px; }\n\n.systemtags-select2-dropdown .systemtags-item {\n display: inline-block;\n height: 25px;\n width: 100%; }\n\n.systemtags-select2-dropdown .select2-result-label {\n height: 25px; }\n\n.systemtags-select2-container {\n width: 100%; }\n .systemtags-select2-container .select2-choices .select2-search-choice.select2-locked .label {\n opacity: 0.5; }\n\n#select2-drop.systemtags-select2-dropdown .select2-results li.select2-result {\n padding: 5px; }\n',""])},function(e,t,n){"use strict";e.exports=function(e){var t=[];return t.toString=function(){return this.map(function(t){var n=function(e,t){var n=e[1]||"",s=e[3];if(!s)return n;if(t&&"function"==typeof btoa){var i=(o=s,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(o))))+" */"),a=s.sources.map(function(e){return"/*# sourceURL="+s.sourceRoot+e+" */"});return[n].concat(a).concat([i]).join("\n")}var o;return[n].join("\n")}(t,e);return t[2]?"@media "+t[2]+"{"+n+"}":n}).join("")},t.i=function(e,n){"string"==typeof e&&(e=[[null,e,""]]);for(var s={},i=0;i=0&&u.splice(t,1)}function g(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var s=function(){0;return n.nc}();s&&(e.attrs.nonce=s)}return y(t,e.attrs),m(e,t),t}function y(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function b(e,t){var n,s,i,a;if(t.transform&&e.css){if(!(a="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=a}if(t.singleton){var o=c++;n=r||(r=g(t)),s=T.bind(null,n,o,!1),i=T.bind(null,n,o,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(n=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",y(t,e.attrs),m(e,t),t}(t),s=function(e,t,n){var s=n.css,i=n.sourceMap,a=void 0===t.convertToAbsoluteUrls&&i;(t.convertToAbsoluteUrls||a)&&(s=d(s));i&&(s+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(i))))+" */");var o=new Blob([s],{type:"text/css"}),l=e.href;e.href=URL.createObjectURL(o),l&&URL.revokeObjectURL(l)}.bind(null,n,t),i=function(){h(n),n.href&&URL.revokeObjectURL(n.href)}):(n=g(t),s=function(e,t){var n=t.css,s=t.media;s&&e.setAttribute("media",s);if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),i=function(){h(n)});return s(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;s(e=t)}else i()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=o()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=p(e,t);return f(n,t),function(e){for(var s=[],i=0;i').addClass('non-existing-tag').text(\n\t\t\t\t\tt('core', 'Non-existing tag #{tag}', {\n\t\t\t\t\t\ttag: tag\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t}\n\n\t\t\tvar $span = $('');\n\t\t\t$span.append(escapeHTML(tag.name));\n\n\t\t\tvar scope;\n\t\t\tif (!tag.userAssignable) {\n\t\t\t\tscope = t('core', 'restricted');\n\t\t\t}\n\t\t\tif (!tag.userVisible) {\n\t\t\t\t// invisible also implicitly means not assignable\n\t\t\t\tscope = t('core', 'invisible');\n\t\t\t}\n\t\t\tif (scope) {\n\t\t\t\tvar $tag = $('').text(' ' +\n\t\t\t\t\tt('core', '({scope})', {\n\t\t\t\t\t\tscope: scope\n\t\t\t\t\t})\n\t\t\t\t);\n\t\t\t\t$span.append($tag);\n\t\t\t}\n\t\t\treturn $span;\n\t\t}\n\t};\n})(OC);\n\n","(function() {\n var template = Handlebars.template, templates = OC.SystemTags.Templates = OC.SystemTags.Templates || {};\ntemplates['result'] = template({\"1\":function(container,depth0,helpers,partials,data) {\n return \" new-item\";\n},\"3\":function(container,depth0,helpers,partials,data) {\n var stack1, helper;\n\n return \"\t\t\"\n + ((stack1 = ((helper = (helper = helpers.tagMarkup || (depth0 != null ? depth0.tagMarkup : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"tagMarkup\",\"hash\":{},\"data\":data}) : helper))) != null ? stack1 : \"\")\n + \"\\n\";\n},\"5\":function(container,depth0,helpers,partials,data) {\n var helper;\n\n return \"\t\t\"\n + container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"name\",\"hash\":{},\"data\":data}) : helper)))\n + \"\\n\";\n},\"7\":function(container,depth0,helpers,partials,data) {\n var helper;\n\n return \"\t\t\\n\t\t\t\\n\t\t\\n\";\n},\"compiler\":[7,\">= 4.0.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1, helper, options, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=\"function\", buffer = \n \"\\n\\n\"\n + ((stack1 = helpers[\"if\"].call(alias1,(depth0 != null ? depth0.isAdmin : depth0),{\"name\":\"if\",\"hash\":{},\"fn\":container.program(3, data, 0),\"inverse\":container.program(5, data, 0),\"data\":data})) != null ? stack1 : \"\");\n stack1 = ((helper = (helper = helpers.allowActions || (depth0 != null ? depth0.allowActions : depth0)) != null ? helper : alias2),(options={\"name\":\"allowActions\",\"hash\":{},\"fn\":container.program(7, data, 0),\"inverse\":container.noop,\"data\":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));\n if (!helpers.allowActions) { stack1 = helpers.blockHelperMissing.call(depth0,stack1,options)}\n if (stack1 != null) { buffer += stack1; }\n return buffer + \"\\n\";\n},\"useData\":true});\ntemplates['result_form'] = template({\"1\":function(container,depth0,helpers,partials,data) {\n var helper;\n\n return \"\t\t\\n\";\n},\"compiler\":[7,\">= 4.0.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1, helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=\"function\", alias4=container.escapeExpression;\n\n return \"
\\n\t \\n\t\\n\"\n + ((stack1 = helpers[\"if\"].call(alias1,(depth0 != null ? depth0.isAdmin : depth0),{\"name\":\"if\",\"hash\":{},\"fn\":container.program(1, data, 0),\"inverse\":container.noop,\"data\":data})) != null ? stack1 : \"\")\n + \"
\\n\";\n},\"useData\":true});\ntemplates['selection'] = template({\"1\":function(container,depth0,helpers,partials,data) {\n var stack1, helper;\n\n return \"\t\"\n + ((stack1 = ((helper = (helper = helpers.tagMarkup || (depth0 != null ? depth0.tagMarkup : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"tagMarkup\",\"hash\":{},\"data\":data}) : helper))) != null ? stack1 : \"\")\n + \"\\n\";\n},\"3\":function(container,depth0,helpers,partials,data) {\n var helper;\n\n return \"\t\"\n + container.escapeExpression(((helper = (helper = helpers.name || (depth0 != null ? depth0.name : depth0)) != null ? helper : helpers.helperMissing),(typeof helper === \"function\" ? helper.call(depth0 != null ? depth0 : (container.nullContext || {}),{\"name\":\"name\",\"hash\":{},\"data\":data}) : helper)))\n + \"\\n\";\n},\"compiler\":[7,\">= 4.0.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var stack1;\n\n return ((stack1 = helpers[\"if\"].call(depth0 != null ? depth0 : (container.nullContext || {}),(depth0 != null ? depth0.isAdmin : depth0),{\"name\":\"if\",\"hash\":{},\"fn\":container.program(1, data, 0),\"inverse\":container.program(3, data, 0),\"data\":data})) != null ? stack1 : \"\");\n},\"useData\":true});\n})();","/*\n * Copyright (c) 2015\n *\n * This file is licensed under the Affero General Public License version 3\n * or later.\n *\n * See the COPYING-README file.\n *\n */\n\n(function(OC) {\n\n\t_.extend(OC.Files.Client, {\n\t\tPROPERTY_FILEID:\t'{' + OC.Files.Client.NS_OWNCLOUD + '}id',\n\t\tPROPERTY_CAN_ASSIGN:'{' + OC.Files.Client.NS_OWNCLOUD + '}can-assign',\n\t\tPROPERTY_DISPLAYNAME:\t'{' + OC.Files.Client.NS_OWNCLOUD + '}display-name',\n\t\tPROPERTY_USERVISIBLE:\t'{' + OC.Files.Client.NS_OWNCLOUD + '}user-visible',\n\t\tPROPERTY_USERASSIGNABLE:'{' + OC.Files.Client.NS_OWNCLOUD + '}user-assignable',\n\t});\n\n\t/**\n\t * @class OCA.SystemTags.SystemTagsCollection\n\t * @classdesc\n\t *\n\t * System tag\n\t *\n\t */\n\tvar SystemTagModel = OC.Backbone.Model.extend(\n\t\t/** @lends OCA.SystemTags.SystemTagModel.prototype */ {\n\t\tsync: OC.Backbone.davSync,\n\n\t\tdefaults: {\n\t\t\tuserVisible: true,\n\t\t\tuserAssignable: true,\n\t\t\tcanAssign: true\n\t\t},\n\n\t\tdavProperties: {\n\t\t\t'id':\tOC.Files.Client.PROPERTY_FILEID,\n\t\t\t'name': OC.Files.Client.PROPERTY_DISPLAYNAME,\n\t\t\t'userVisible': \tOC.Files.Client.PROPERTY_USERVISIBLE,\n\t\t\t'userAssignable': \tOC.Files.Client.PROPERTY_USERASSIGNABLE,\n\t\t\t// read-only, effective permissions computed by the server,\n\t\t\t'canAssign': OC.Files.Client.PROPERTY_CAN_ASSIGN\n\t\t},\n\n\t\tparse: function(data) {\n\t\t\treturn {\n\t\t\t\tid: data.id,\n\t\t\t\tname: data.name,\n\t\t\t\tuserVisible: data.userVisible === true || data.userVisible === 'true',\n\t\t\t\tuserAssignable: data.userAssignable === true || data.userAssignable === 'true',\n\t\t\t\tcanAssign: data.canAssign === true || data.canAssign === 'true'\n\t\t\t};\n\t\t}\n\t});\n\n\tOC.SystemTags = OC.SystemTags || {};\n\tOC.SystemTags.SystemTagModel = SystemTagModel;\n})(OC);\n","/*\n * Copyright (c) 2015\n *\n * This file is licensed under the Affero General Public License version 3\n * or later.\n *\n * See the COPYING-README file.\n *\n */\n\n(function(OC) {\n\t/**\n\t * @class OC.SystemTags.SystemTagsMappingCollection\n\t * @classdesc\n\t *\n\t * Collection of tags assigned to a an object\n\t *\n\t */\n\tvar SystemTagsMappingCollection = OC.Backbone.Collection.extend(\n\t\t/** @lends OC.SystemTags.SystemTagsMappingCollection.prototype */ {\n\n\t\tsync: OC.Backbone.davSync,\n\n\t\t/**\n\t\t * Use PUT instead of PROPPATCH\n\t\t */\n\t\tusePUT: true,\n\n\t\t/**\n\t\t * Id of the file for which to filter activities by\n\t\t *\n\t\t * @var int\n\t\t */\n\t\t_objectId: null,\n\n\t\t/**\n\t\t * Type of the object to filter by\n\t\t *\n\t\t * @var string\n\t\t */\n\t\t_objectType: 'files',\n\n\t\tmodel: OC.SystemTags.SystemTagModel,\n\n\t\turl: function() {\n\t\t\treturn OC.linkToRemote('dav') + '/systemtags-relations/' + this._objectType + '/' + this._objectId;\n\t\t},\n\n\t\t/**\n\t\t * Sets the object id to filter by or null for all.\n\t\t *\n\t\t * @param {int} objectId file id or null\n\t\t */\n\t\tsetObjectId: function(objectId) {\n\t\t\tthis._objectId = objectId;\n\t\t},\n\n\t\t/**\n\t\t * Sets the object type to filter by or null for all.\n\t\t *\n\t\t * @param {int} objectType file id or null\n\t\t */\n\t\tsetObjectType: function(objectType) {\n\t\t\tthis._objectType = objectType;\n\t\t},\n\n\t\tinitialize: function(models, options) {\n\t\t\toptions = options || {};\n\t\t\tif (!_.isUndefined(options.objectId)) {\n\t\t\t\tthis._objectId = options.objectId;\n\t\t\t}\n\t\t\tif (!_.isUndefined(options.objectType)) {\n\t\t\t\tthis._objectType = options.objectType;\n\t\t\t}\n\t\t},\n\n\t\tgetTagIds: function() {\n\t\t\treturn this.map(function(model) {\n\t\t\t\treturn model.id;\n\t\t\t});\n\t\t}\n\t});\n\n\tOC.SystemTags = OC.SystemTags || {};\n\tOC.SystemTags.SystemTagsMappingCollection = SystemTagsMappingCollection;\n})(OC);\n\n","/*\n * Copyright (c) 2015\n *\n * This file is licensed under the Affero General Public License version 3\n * or later.\n *\n * See the COPYING-README file.\n *\n */\n\n(function(OC) {\n\n\tfunction filterFunction(model, term) {\n\t\treturn model.get('name').substr(0, term.length).toLowerCase() === term.toLowerCase();\n\t}\n\n\t/**\n\t * @class OCA.SystemTags.SystemTagsCollection\n\t * @classdesc\n\t *\n\t * Collection of tags assigned to a file\n\t *\n\t */\n\tvar SystemTagsCollection = OC.Backbone.Collection.extend(\n\t\t/** @lends OC.SystemTags.SystemTagsCollection.prototype */ {\n\n\t\tsync: OC.Backbone.davSync,\n\n\t\tmodel: OC.SystemTags.SystemTagModel,\n\n\t\turl: function() {\n\t\t\treturn OC.linkToRemote('dav') + '/systemtags/';\n\t\t},\n\n\t\tfilterByName: function(name) {\n\t\t\treturn this.filter(function(model) {\n\t\t\t\treturn filterFunction(model, name);\n\t\t\t});\n\t\t},\n\n\t\treset: function() {\n\t\t\tthis.fetched = false;\n\t\t\treturn OC.Backbone.Collection.prototype.reset.apply(this, arguments);\n\t\t},\n\n\t\t/**\n\t\t * Lazy fetch.\n\t\t * Only fetches once, subsequent calls will directly call the success handler.\n\t\t *\n\t\t * @param options\n\t\t * @param [options.force] true to force fetch even if cached entries exist\n\t\t *\n\t\t * @see Backbone.Collection#fetch\n\t\t */\n\t\tfetch: function(options) {\n\t\t\tvar self = this;\n\t\t\toptions = options || {};\n\t\t\tif (this.fetched || options.force) {\n\t\t\t\t// directly call handler\n\t\t\t\tif (options.success) {\n\t\t\t\t\toptions.success(this, null, options);\n\t\t\t\t}\n\t\t\t\t// trigger sync event\n\t\t\t\tthis.trigger('sync', this, null, options);\n\t\t\t\treturn Promise.resolve();\n\t\t\t}\n\n\t\t\tvar success = options.success;\n\t\t\toptions = _.extend({}, options);\n\t\t\toptions.success = function() {\n\t\t\t\tself.fetched = true;\n\t\t\t\tif (success) {\n\t\t\t\t\treturn success.apply(this, arguments);\n\t\t\t\t}\n\t\t\t};\n\n\t\t\treturn OC.Backbone.Collection.prototype.fetch.call(this, options);\n\t\t}\n\t});\n\n\tOC.SystemTags = OC.SystemTags || {};\n\tOC.SystemTags.SystemTagsCollection = SystemTagsCollection;\n\n\t/**\n\t * @type OC.SystemTags.SystemTagsCollection\n\t */\n\tOC.SystemTags.collection = new OC.SystemTags.SystemTagsCollection();\n})(OC);\n\n","/*\n * Copyright (c) 2015\n *\n * This file is licensed under the Affero General Public License version 3\n * or later.\n *\n * See the COPYING-README file.\n *\n */\n\n/* global Handlebars */\n\n(function(OC) {\n\n\t/**\n\t * @class OC.SystemTags.SystemTagsInputField\n\t * @classdesc\n\t *\n\t * Displays a file's system tags\n\t *\n\t */\n\tvar SystemTagsInputField = OC.Backbone.View.extend(\n\t\t/** @lends OC.SystemTags.SystemTagsInputField.prototype */ {\n\n\t\t_rendered: false,\n\n\t\t_newTag: null,\n\n\t\t_lastUsedTags: [],\n\n\t\tclassName: 'systemTagsInputFieldContainer',\n\n\t\ttemplate: function(data) {\n\t\t\treturn '';\n\t\t},\n\n\t\t/**\n\t\t * Creates a new SystemTagsInputField\n\t\t *\n\t\t * @param {Object} [options]\n\t\t * @param {string} [options.objectType=files] object type for which tags are assigned to\n\t\t * @param {bool} [options.multiple=false] whether to allow selecting multiple tags\n\t\t * @param {bool} [options.allowActions=true] whether tags can be renamed/delete within the dropdown\n\t\t * @param {bool} [options.allowCreate=true] whether new tags can be created\n\t\t * @param {bool} [options.isAdmin=true] whether the user is an administrator\n\t\t * @param {Function} options.initSelection function to convert selection to data\n\t\t */\n\t\tinitialize: function(options) {\n\t\t\toptions = options || {};\n\n\t\t\tthis._multiple = !!options.multiple;\n\t\t\tthis._allowActions = _.isUndefined(options.allowActions) || !!options.allowActions;\n\t\t\tthis._allowCreate = _.isUndefined(options.allowCreate) || !!options.allowCreate;\n\t\t\tthis._isAdmin = !!options.isAdmin;\n\n\t\t\tif (_.isFunction(options.initSelection)) {\n\t\t\t\tthis._initSelection = options.initSelection;\n\t\t\t}\n\n\t\t\tthis.collection = options.collection || OC.SystemTags.collection;\n\n\t\t\tvar self = this;\n\t\t\tthis.collection.on('change:name remove', function() {\n\t\t\t\t// refresh selection\n\t\t\t\t_.defer(self._refreshSelection);\n\t\t\t});\n\n\t\t\t_.defer(_.bind(this._getLastUsedTags, this));\n\n\t\t\t_.bindAll(\n\t\t\t\tthis,\n\t\t\t\t'_refreshSelection',\n\t\t\t\t'_onClickRenameTag',\n\t\t\t\t'_onClickDeleteTag',\n\t\t\t\t'_onSelectTag',\n\t\t\t\t'_onDeselectTag',\n\t\t\t\t'_onSubmitRenameTag'\n\t\t\t);\n\t\t},\n\n\t\t_getLastUsedTags: function() {\n\t\t\tvar self = this;\n\t\t\t$.ajax({\n\t\t\t\ttype: 'GET',\n\t\t\t\turl: OC.generateUrl('/apps/systemtags/lastused'),\n\t\t\t\tsuccess: function (response) {\n\t\t\t\t\tself._lastUsedTags = response;\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Refreshes the selection, triggering a call to\n\t\t * select2's initSelection\n\t\t */\n\t\t_refreshSelection: function() {\n\t\t\tthis.$tagsField.select2('val', this.$tagsField.val());\n\t\t},\n\n\t\t/**\n\t\t * Event handler whenever the user clicked the \"rename\" action.\n\t\t * This will display the rename field.\n\t\t */\n\t\t_onClickRenameTag: function(ev) {\n\t\t\tvar $item = $(ev.target).closest('.systemtags-item');\n\t\t\tvar tagId = $item.attr('data-id');\n\t\t\tvar tagModel = this.collection.get(tagId);\n\n\t\t\tvar oldName = tagModel.get('name');\n\t\t\tvar $renameForm = $(OC.SystemTags.Templates['result_form']({\n\t\t\t\tcid: this.cid,\n\t\t\t\tname: oldName,\n\t\t\t\tdeleteTooltip: t('core', 'Delete'),\n\t\t\t\trenameLabel: t('core', 'Rename'),\n\t\t\t\tisAdmin: this._isAdmin\n\t\t\t}));\n\t\t\t$item.find('.label').after($renameForm);\n\t\t\t$item.find('.label, .systemtags-actions').addClass('hidden');\n\t\t\t$item.closest('.select2-result').addClass('has-form');\n\n\t\t\t$renameForm.find('[title]').tooltip({\n\t\t\t\tplacement: 'bottom',\n\t\t\t\tcontainer: 'body'\n\t\t\t});\n\t\t\t$renameForm.find('input').focus().selectRange(0, oldName.length);\n\t\t\treturn false;\n\t\t},\n\n\t\t/**\n\t\t * Event handler whenever the rename form has been submitted after\n\t\t * the user entered a new tag name.\n\t\t * This will submit the change to the server. \n\t\t *\n\t\t * @param {Object} ev event\n\t\t */\n\t\t_onSubmitRenameTag: function(ev) {\n\t\t\tev.preventDefault();\n\t\t\tvar $form = $(ev.target);\n\t\t\tvar $item = $form.closest('.systemtags-item');\n\t\t\tvar tagId = $item.attr('data-id');\n\t\t\tvar tagModel = this.collection.get(tagId);\n\t\t\tvar newName = $(ev.target).find('input').val().trim();\n\t\t\tif (newName && newName !== tagModel.get('name')) {\n\t\t\t\ttagModel.save({'name': newName});\n\t\t\t\t// TODO: spinner, and only change text after finished saving\n\t\t\t\t$item.find('.label').text(newName);\n\t\t\t}\n\t\t\t$item.find('.label, .systemtags-actions').removeClass('hidden');\n\t\t\t$form.remove();\n\t\t\t$item.closest('.select2-result').removeClass('has-form');\n\t\t},\n\n\t\t/**\n\t\t * Event handler whenever a tag must be deleted\n\t\t *\n\t\t * @param {Object} ev event\n\t\t */\n\t\t_onClickDeleteTag: function(ev) {\n\t\t\tvar $item = $(ev.target).closest('.systemtags-item');\n\t\t\tvar tagId = $item.attr('data-id');\n\t\t\tthis.collection.get(tagId).destroy();\n\t\t\t$(ev.target).tooltip('hide');\n\t\t\t$item.closest('.select2-result').remove();\n\t\t\t// TODO: spinner\n\t\t\treturn false;\n\t\t},\n\n\t\t_addToSelect2Selection: function(selection) {\n\t\t\tvar data = this.$tagsField.select2('data');\n\t\t\tdata.push(selection);\n\t\t\tthis.$tagsField.select2('data', data);\n\t\t},\n\n\t\t/**\n\t\t * Event handler whenever a tag is selected.\n\t\t * Also called whenever tag creation is requested through the dummy tag object.\n\t\t *\n\t\t * @param {Object} e event\n\t\t */\n\t\t_onSelectTag: function(e) {\n\t\t\tvar self = this;\n\t\t\tvar tag;\n\t\t\tif (e.object && e.object.isNew) {\n\t\t\t\t// newly created tag, check if existing\n\t\t\t\t// create a new tag\n\t\t\t\ttag = this.collection.create({\n\t\t\t\t\tname: e.object.name.trim(),\n\t\t\t\t\tuserVisible: true,\n\t\t\t\t\tuserAssignable: true,\n\t\t\t\t\tcanAssign: true\n\t\t\t\t}, {\n\t\t\t\t\tsuccess: function(model) {\n\t\t\t\t\t\tself._addToSelect2Selection(model.toJSON());\n\t\t\t\t\t\tself._lastUsedTags.unshift(model.id);\n\t\t\t\t\t\tself.trigger('select', model);\n\t\t\t\t\t},\n\t\t\t\t\terror: function(model, xhr) {\n\t\t\t\t\t\tif (xhr.status === 409) {\n\t\t\t\t\t\t\t// re-fetch collection to get the missing tag\n\t\t\t\t\t\t\tself.collection.reset();\n\t\t\t\t\t\t\tself.collection.fetch({\n\t\t\t\t\t\t\t\tsuccess: function(collection) {\n\t\t\t\t\t\t\t\t\t// find the tag in the collection\n\t\t\t\t\t\t\t\t\tvar model = collection.where({\n\t\t\t\t\t\t\t\t\t\tname: e.object.name.trim(),\n\t\t\t\t\t\t\t\t\t\tuserVisible: true,\n\t\t\t\t\t\t\t\t\t\tuserAssignable: true\n\t\t\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\t\t\tif (model.length) {\n\t\t\t\t\t\t\t\t\t\tmodel = model[0];\n\t\t\t\t\t\t\t\t\t\t// the tag already exists or was already assigned,\n\t\t\t\t\t\t\t\t\t\t// add it to the list anyway\n\t\t\t\t\t\t\t\t\t\tself._addToSelect2Selection(model.toJSON());\n\t\t\t\t\t\t\t\t\t\tself.trigger('select', model);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t\tthis.$tagsField.select2('close');\n\t\t\t\te.preventDefault();\n\t\t\t\treturn false;\n\t\t\t} else {\n\t\t\t\ttag = this.collection.get(e.object.id);\n\t\t\t\tthis._lastUsedTags.unshift(tag.id);\n\t\t\t}\n\t\t\tthis._newTag = null;\n\t\t\tthis.trigger('select', tag);\n\t\t},\n\n\t\t/**\n\t\t * Event handler whenever a tag gets deselected.\n\t\t *\n\t\t * @param {Object} e event\n\t\t */\n\t\t_onDeselectTag: function(e) {\n\t\t\tthis.trigger('deselect', e.choice.id);\n\t\t},\n\n\t\t/**\n\t\t * Autocomplete function for dropdown results\n\t\t *\n\t\t * @param {Object} query select2 query object\n\t\t */\n\t\t_queryTagsAutocomplete: function(query) {\n\t\t\tvar self = this;\n\t\t\tthis.collection.fetch({\n\t\t\t\tsuccess: function(collection) {\n\t\t\t\t\tvar tagModels = collection.filterByName(query.term.trim());\n\t\t\t\t\tif (!self._isAdmin) {\n\t\t\t\t\t\ttagModels = _.filter(tagModels, function(tagModel) {\n\t\t\t\t\t\t\treturn tagModel.get('canAssign');\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tquery.callback({\n\t\t\t\t\t\tresults: _.invoke(tagModels, 'toJSON')\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\t_preventDefault: function(e) {\n\t\t\te.stopPropagation();\n\t\t},\n\n\t\t/**\n\t\t * Formats a single dropdown result\n\t\t *\n\t\t * @param {Object} data data to format\n\t\t * @return {string} HTML markup\n\t\t */\n\t\t_formatDropDownResult: function(data) {\n\t\t\treturn OC.SystemTags.Templates['result'](_.extend({\n\t\t\t\trenameTooltip: t('core', 'Rename'),\n\t\t\t\tallowActions: this._allowActions,\n\t\t\t\ttagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null,\n\t\t\t\tisAdmin: this._isAdmin\n\t\t\t}, data));\n\t\t},\n\n\t\t/**\n\t\t * Formats a single selection item\n\t\t *\n\t\t * @param {Object} data data to format\n\t\t * @return {string} HTML markup\n\t\t */\n\t\t_formatSelection: function(data) {\n\t\t\treturn OC.SystemTags.Templates['selection'](_.extend({\n\t\t\t\ttagMarkup: this._isAdmin ? OC.SystemTags.getDescriptiveTag(data)[0].innerHTML : null,\n\t\t\t\tisAdmin: this._isAdmin\n\t\t\t}, data));\n\t\t},\n\n\t\t/**\n\t\t * Create new dummy choice for select2 when the user\n\t\t * types an arbitrary string\n\t\t *\n\t\t * @param {string} term entered term\n\t\t * @return {Object} dummy tag\n\t\t */\n\t\t_createSearchChoice: function(term) {\n\t\t\tterm = term.trim();\n\t\t\tif (this.collection.filter(function(entry) {\n\t\t\t\t\treturn entry.get('name') === term;\n\t\t\t\t}).length) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tif (!this._newTag) {\n\t\t\t\tthis._newTag = {\n\t\t\t\t\tid: -1,\n\t\t\t\t\tname: term,\n\t\t\t\t\tuserAssignable: true,\n\t\t\t\t\tuserVisible: true,\n\t\t\t\t\tcanAssign: true,\n\t\t\t\t\tisNew: true\n\t\t\t\t};\n\t\t\t} else {\n\t\t\t\tthis._newTag.name = term;\n\t\t\t}\n\n\t\t\treturn this._newTag;\n\t\t},\n\n\t\t_initSelection: function(element, callback) {\n\t\t\tvar self = this;\n\t\t\tvar ids = $(element).val().split(',');\n\n\t\t\tfunction modelToSelection(model) {\n\t\t\t\tvar data = model.toJSON();\n\t\t\t\tif (!self._isAdmin && !data.canAssign) {\n\t\t\t\t\t// lock static tags for non-admins\n\t\t\t\t\tdata.locked = true;\n\t\t\t\t}\n\t\t\t\treturn data;\n\t\t\t}\n\n\t\t\tfunction findSelectedObjects(ids) {\n\t\t\t\tvar selectedModels = self.collection.filter(function(model) {\n\t\t\t\t\treturn ids.indexOf(model.id) >= 0 && (self._isAdmin || model.get('userVisible'));\n\t\t\t\t});\n\t\t\t\treturn _.map(selectedModels, modelToSelection);\n\t\t\t}\n\n\t\t\tthis.collection.fetch({\n\t\t\t\tsuccess: function() {\n\t\t\t\t\tcallback(findSelectedObjects(ids));\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\t/**\n\t\t * Renders this details view\n\t\t */\n\t\trender: function() {\n\t\t\tvar self = this;\n\t\t\tthis.$el.html(this.template());\n\n\t\t\tthis.$el.find('[title]').tooltip({placement: 'bottom'});\n\t\t\tthis.$tagsField = this.$el.find('[name=tags]');\n\t\t\tthis.$tagsField.select2({\n\t\t\t\tplaceholder: t('core', 'Collaborative tags'),\n\t\t\t\tcontainerCssClass: 'systemtags-select2-container',\n\t\t\t\tdropdownCssClass: 'systemtags-select2-dropdown',\n\t\t\t\tcloseOnSelect: false,\n\t\t\t\tallowClear: false,\n\t\t\t\tmultiple: this._multiple,\n\t\t\t\ttoggleSelect: this._multiple,\n\t\t\t\tquery: _.bind(this._queryTagsAutocomplete, this),\n\t\t\t\tid: function(tag) {\n\t\t\t\t\treturn tag.id;\n\t\t\t\t},\n\t\t\t\tinitSelection: _.bind(this._initSelection, this),\n\t\t\t\tformatResult: _.bind(this._formatDropDownResult, this),\n\t\t\t\tformatSelection: _.bind(this._formatSelection, this),\n\t\t\t\tcreateSearchChoice: this._allowCreate ? _.bind(this._createSearchChoice, this) : undefined,\n\t\t\t\tsortResults: function(results) {\n\t\t\t\t\tvar selectedItems = _.pluck(self.$tagsField.select2('data'), 'id');\n\t\t\t\t\tresults.sort(function(a, b) {\n\t\t\t\t\t\tvar aSelected = selectedItems.indexOf(a.id) >= 0;\n\t\t\t\t\t\tvar bSelected = selectedItems.indexOf(b.id) >= 0;\n\t\t\t\t\t\tif (aSelected === bSelected) {\n\t\t\t\t\t\t\tvar aLastUsed = self._lastUsedTags.indexOf(a.id);\n\t\t\t\t\t\t\tvar bLastUsed = self._lastUsedTags.indexOf(b.id);\n\n\t\t\t\t\t\t\tif (aLastUsed !== bLastUsed) {\n\t\t\t\t\t\t\t\tif (bLastUsed === -1) {\n\t\t\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\tif (aLastUsed === -1) {\n\t\t\t\t\t\t\t\t\treturn 1;\n\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\treturn aLastUsed < bLastUsed ? -1 : 1;\n\t\t\t\t\t\t\t}\n\n\t\t\t\t\t\t\t// Both not found\n\t\t\t\t\t\t\treturn OC.Util.naturalSortCompare(a.name, b.name);\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif (aSelected && !bSelected) {\n\t\t\t\t\t\t\treturn -1;\n\t\t\t\t\t\t}\n\t\t\t\t\t\treturn 1;\n\t\t\t\t\t});\n\t\t\t\t\treturn results;\n\t\t\t\t},\n\t\t\t\tformatNoMatches: function() {\n\t\t\t\t\treturn t('core', 'No tags found');\n\t\t\t\t}\n\t\t\t})\n\t\t\t\t.on('select2-selecting', this._onSelectTag)\n\t\t\t\t.on('select2-removing', this._onDeselectTag);\n\n\t\t\tvar $dropDown = this.$tagsField.select2('dropdown');\n\t\t\t// register events for inside the dropdown\n\t\t\t$dropDown.on('mouseup', '.rename', this._onClickRenameTag);\n\t\t\t$dropDown.on('mouseup', '.delete', this._onClickDeleteTag);\n\t\t\t$dropDown.on('mouseup', '.select2-result-selectable.has-form', this._preventDefault);\n\t\t\t$dropDown.on('submit', '.systemtags-rename-form', this._onSubmitRenameTag);\n\n\t\t\tthis.delegateEvents();\n\t\t},\n\n\t\tremove: function() {\n\t\t\tif (this.$tagsField) {\n\t\t\t\tthis.$tagsField.select2('destroy');\n\t\t\t}\n\t\t},\n\n\t\tgetValues: function() {\n\t\t\tthis.$tagsField.select2('val');\n\t\t},\n\n\t\tsetValues: function(values) {\n\t\t\tthis.$tagsField.select2('val', values);\n\t\t},\n\n\t\tsetData: function(data) {\n\t\t\tthis.$tagsField.select2('data', data);\n\t\t}\n\t});\n\n\tOC.SystemTags = OC.SystemTags || {};\n\tOC.SystemTags.SystemTagsInputField = SystemTagsInputField;\n\n})(OC);\n\n","\nvar content = require(\"!!../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/lib/loader.js!./systemtags.scss\");\n\nif(typeof content === 'string') content = [[module.id, content, '']];\n\nvar transform;\nvar insertInto;\n\n\n\nvar options = {\"hmr\":true}\n\noptions.transform = transform\noptions.insertInto = undefined;\n\nvar update = require(\"!../../node_modules/style-loader/lib/addStyles.js\")(content, options);\n\nif(content.locals) module.exports = content.locals;\n\nif(module.hot) {\n\tmodule.hot.accept(\"!!../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/lib/loader.js!./systemtags.scss\", function() {\n\t\tvar newContent = require(\"!!../../node_modules/css-loader/dist/cjs.js!../../node_modules/sass-loader/lib/loader.js!./systemtags.scss\");\n\n\t\tif(typeof newContent === 'string') newContent = [[module.id, newContent, '']];\n\n\t\tvar locals = (function(a, b) {\n\t\t\tvar key, idx = 0;\n\n\t\t\tfor(key in a) {\n\t\t\t\tif(!b || a[key] !== b[key]) return false;\n\t\t\t\tidx++;\n\t\t\t}\n\n\t\t\tfor(key in b) idx--;\n\n\t\t\treturn idx === 0;\n\t\t}(content.locals, newContent.locals));\n\n\t\tif(!locals) throw new Error('Aborting CSS HMR due to changed css-modules locals.');\n\n\t\tupdate(newContent);\n\t});\n\n\tmodule.hot.dispose(function() { update(); });\n}","exports = module.exports = require(\"../../node_modules/css-loader/dist/runtime/api.js\")(false);\n// Module\nexports.push([module.id, \"@charset \\\"UTF-8\\\";\\n/**\\n * @copyright Copyright (c) 2016, John Molakvoæ \\n * @copyright Copyright (c) 2016, Robin Appelman \\n * @copyright Copyright (c) 2016, Jan-Christoph Borchardt \\n * @copyright Copyright (c) 2016, Vincent Petry \\n * @copyright Copyright (c) 2016, Erik Pellikka \\n * @copyright Copyright (c) 2015, Vincent Petry \\n *\\n * @license GNU AGPL version 3 or any later version\\n *\\n */\\n.systemtags-select2-dropdown .select2-result-label .checkmark {\\n visibility: hidden;\\n margin-left: -5px;\\n margin-right: 5px;\\n padding: 4px; }\\n\\n.systemtags-select2-dropdown .select2-result-label .new-item .systemtags-actions {\\n display: none; }\\n\\n.systemtags-select2-dropdown .select2-selected .select2-result-label .checkmark {\\n visibility: visible; }\\n\\n.systemtags-select2-dropdown .select2-result-label .icon {\\n display: inline-block;\\n opacity: .5; }\\n .systemtags-select2-dropdown .select2-result-label .icon.rename {\\n padding: 4px; }\\n\\n.systemtags-select2-dropdown .systemtags-actions {\\n position: absolute;\\n right: 5px; }\\n\\n.systemtags-select2-dropdown .systemtags-rename-form {\\n display: inline-block;\\n width: calc(100% - 20px);\\n top: -6px;\\n position: relative; }\\n .systemtags-select2-dropdown .systemtags-rename-form input {\\n display: inline-block;\\n height: 30px;\\n width: calc(100% - 40px); }\\n\\n.systemtags-select2-dropdown .label {\\n width: 85%;\\n display: inline-block;\\n overflow: hidden;\\n text-overflow: ellipsis; }\\n .systemtags-select2-dropdown .label.hidden {\\n display: none; }\\n\\n.systemtags-select2-dropdown span {\\n line-height: 25px; }\\n\\n.systemtags-select2-dropdown .systemtags-item {\\n display: inline-block;\\n height: 25px;\\n width: 100%; }\\n\\n.systemtags-select2-dropdown .select2-result-label {\\n height: 25px; }\\n\\n.systemtags-select2-container {\\n width: 100%; }\\n .systemtags-select2-container .select2-choices .select2-search-choice.select2-locked .label {\\n opacity: 0.5; }\\n\\n#select2-drop.systemtags-select2-dropdown .select2-results li.select2-result {\\n padding: 5px; }\\n\", \"\"]);\n\n","\"use strict\";\n\n/*\n MIT License http://www.opensource.org/licenses/mit-license.php\n Author Tobias Koppers @sokra\n*/\n// css base code, injected by the css-loader\nmodule.exports = function (useSourceMap) {\n var list = []; // return the list of modules as css string\n\n list.toString = function toString() {\n return this.map(function (item) {\n var content = cssWithMappingToString(item, useSourceMap);\n\n if (item[2]) {\n return '@media ' + item[2] + '{' + content + '}';\n } else {\n return content;\n }\n }).join('');\n }; // import a list of modules into the list\n\n\n list.i = function (modules, mediaQuery) {\n if (typeof modules === 'string') {\n modules = [[null, modules, '']];\n }\n\n var alreadyImportedModules = {};\n\n for (var i = 0; i < this.length; i++) {\n var id = this[i][0];\n\n if (id != null) {\n alreadyImportedModules[id] = true;\n }\n }\n\n for (i = 0; i < modules.length; i++) {\n var item = modules[i]; // skip already imported module\n // this implementation is not 100% perfect for weird media query combinations\n // when a module is imported multiple times with different media queries.\n // I hope this will never occur (Hey this way we have smaller bundles)\n\n if (item[0] == null || !alreadyImportedModules[item[0]]) {\n if (mediaQuery && !item[2]) {\n item[2] = mediaQuery;\n } else if (mediaQuery) {\n item[2] = '(' + item[2] + ') and (' + mediaQuery + ')';\n }\n\n list.push(item);\n }\n }\n };\n\n return list;\n};\n\nfunction cssWithMappingToString(item, useSourceMap) {\n var content = item[1] || '';\n var cssMapping = item[3];\n\n if (!cssMapping) {\n return content;\n }\n\n if (useSourceMap && typeof btoa === 'function') {\n var sourceMapping = toComment(cssMapping);\n var sourceURLs = cssMapping.sources.map(function (source) {\n return '/*# sourceURL=' + cssMapping.sourceRoot + source + ' */';\n });\n return [content].concat(sourceURLs).concat([sourceMapping]).join('\\n');\n }\n\n return [content].join('\\n');\n} // Adapted from convert-source-map (MIT)\n\n\nfunction toComment(sourceMap) {\n // eslint-disable-next-line no-undef\n var base64 = btoa(unescape(encodeURIComponent(JSON.stringify(sourceMap))));\n var data = 'sourceMappingURL=data:application/json;charset=utf-8;base64,' + base64;\n return '/*# ' + data + ' */';\n}","/*\n\tMIT License http://www.opensource.org/licenses/mit-license.php\n\tAuthor Tobias Koppers @sokra\n*/\n\nvar stylesInDom = {};\n\nvar\tmemoize = function (fn) {\n\tvar memo;\n\n\treturn function () {\n\t\tif (typeof memo === \"undefined\") memo = fn.apply(this, arguments);\n\t\treturn memo;\n\t};\n};\n\nvar isOldIE = memoize(function () {\n\t// Test for IE <= 9 as proposed by Browserhacks\n\t// @see http://browserhacks.com/#hack-e71d8692f65334173fee715c222cb805\n\t// Tests for existence of standard globals is to allow style-loader\n\t// to operate correctly into non-standard environments\n\t// @see https://github.com/webpack-contrib/style-loader/issues/177\n\treturn window && document && document.all && !window.atob;\n});\n\nvar getTarget = function (target, parent) {\n if (parent){\n return parent.querySelector(target);\n }\n return document.querySelector(target);\n};\n\nvar getElement = (function (fn) {\n\tvar memo = {};\n\n\treturn function(target, parent) {\n // If passing function in options, then use it for resolve \"head\" element.\n // Useful for Shadow Root style i.e\n // {\n // insertInto: function () { return document.querySelector(\"#foo\").shadowRoot }\n // }\n if (typeof target === 'function') {\n return target();\n }\n if (typeof memo[target] === \"undefined\") {\n\t\t\tvar styleTarget = getTarget.call(this, target, parent);\n\t\t\t// Special case to return head of iframe instead of iframe itself\n\t\t\tif (window.HTMLIFrameElement && styleTarget instanceof window.HTMLIFrameElement) {\n\t\t\t\ttry {\n\t\t\t\t\t// This will throw an exception if access to iframe is blocked\n\t\t\t\t\t// due to cross-origin restrictions\n\t\t\t\t\tstyleTarget = styleTarget.contentDocument.head;\n\t\t\t\t} catch(e) {\n\t\t\t\t\tstyleTarget = null;\n\t\t\t\t}\n\t\t\t}\n\t\t\tmemo[target] = styleTarget;\n\t\t}\n\t\treturn memo[target]\n\t};\n})();\n\nvar singleton = null;\nvar\tsingletonCounter = 0;\nvar\tstylesInsertedAtTop = [];\n\nvar\tfixUrls = require(\"./urls\");\n\nmodule.exports = function(list, options) {\n\tif (typeof DEBUG !== \"undefined\" && DEBUG) {\n\t\tif (typeof document !== \"object\") throw new Error(\"The style-loader cannot be used in a non-browser environment\");\n\t}\n\n\toptions = options || {};\n\n\toptions.attrs = typeof options.attrs === \"object\" ? options.attrs : {};\n\n\t// Force single-tag solution on IE6-9, which has a hard limit on the # of