From 7f886541473fb73591a8930e322250cdc6496bfc Mon Sep 17 00:00:00 2001 From: Roeland Jago Douma Date: Sun, 3 Feb 2019 19:56:44 +0100 Subject: [PATCH] Move of files_versions to webpack * Move CSS into bundle * Old merged.json no longer needed! * No need to load the style still Signed-off-by: Roeland Jago Douma --- .gitattributes | 2 + apps/files_versions/.l10nignore | 3 +- apps/files_versions/appinfo/app.php | 2 - apps/files_versions/js/files_versions.js | 2 + apps/files_versions/js/files_versions.js.map | 1 + apps/files_versions/js/merged.json | 7 ---- apps/files_versions/lib/Hooks.php | 2 +- .../files_versions/{ => src}/css/versions.css | 0 apps/files_versions/src/files_versions.js | 8 ++++ .../files_versions/{js => src}/filesplugin.js | 0 apps/files_versions/{js => src}/templates.js | 0 .../{js => src}/templates/item.handlebars | 0 .../{js => src}/templates/template.handlebars | 0 .../{js => src}/versioncollection.js | 0 .../{js => src}/versionmodel.js | 0 .../{js => src}/versionstabview.js | 0 apps/files_versions/webpack.js | 37 +++++++++++++++++++ core/js/core.json | 2 - tests/karma.config.js | 15 +------- webpack.common.js | 7 +++- 20 files changed, 61 insertions(+), 27 deletions(-) create mode 100644 apps/files_versions/js/files_versions.js create mode 100644 apps/files_versions/js/files_versions.js.map delete mode 100644 apps/files_versions/js/merged.json rename apps/files_versions/{ => src}/css/versions.css (100%) create mode 100644 apps/files_versions/src/files_versions.js rename apps/files_versions/{js => src}/filesplugin.js (100%) rename apps/files_versions/{js => src}/templates.js (100%) rename apps/files_versions/{js => src}/templates/item.handlebars (100%) rename apps/files_versions/{js => src}/templates/template.handlebars (100%) rename apps/files_versions/{js => src}/versioncollection.js (100%) rename apps/files_versions/{js => src}/versionmodel.js (100%) rename apps/files_versions/{js => src}/versionstabview.js (100%) create mode 100644 apps/files_versions/webpack.js diff --git a/.gitattributes b/.gitattributes index b2dea06fd7..32f68e85b5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,6 +3,8 @@ /apps/accessibility/js/accessibility.js binary /apps/accessibility/js/accessibility.js.map binary +/apps/files_versions/js/files_versions.js binary +/apps/files_versions/js/files_versions.js.map binary /apps/oauth2/js/oauth2.js binary /apps/oauth2/js/oauth2.js.map binary /apps/twofactor_backupcodes/js/*.js binary diff --git a/apps/files_versions/.l10nignore b/apps/files_versions/.l10nignore index 8b832897e3..a5844cfefe 100644 --- a/apps/files_versions/.l10nignore +++ b/apps/files_versions/.l10nignore @@ -1,2 +1,3 @@ # compiled vue templates -js/templates.js +js/files_versions.js +src/templates.js diff --git a/apps/files_versions/appinfo/app.php b/apps/files_versions/appinfo/app.php index 1ac7d40689..f28210553c 100644 --- a/apps/files_versions/appinfo/app.php +++ b/apps/files_versions/appinfo/app.php @@ -22,6 +22,4 @@ * */ -\OCP\Util::addStyle('files_versions', 'versions'); - \OCA\Files_Versions\Hooks::connectHooks(); diff --git a/apps/files_versions/js/files_versions.js b/apps/files_versions/js/files_versions.js new file mode 100644 index 0000000000..4405671a10 --- /dev/null +++ b/apps/files_versions/js/files_versions.js @@ -0,0 +1,2 @@ +!function(e){var t={};function n(i){if(t[i])return t[i].exports;var r=t[i]={i:i,l:!1,exports:{}};return e[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}n.m=e,n.c=t,n.d=function(e,t,i){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:i})},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 i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)n.d(i,r,function(t){return e[t]}.bind(null,r));return i},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="/js/",n(n.s=0)}([function(e,t,n){"use strict";n.r(t);n(1),n(2),n(3),n(4),n(5),n(6);window.OCA.Versions=OCA.Versions},function(e,t){var n;n=OC.Backbone.Model.extend({sync:OC.Backbone.davSync,davProperties:{size:"{DAV:}getcontentlength",mimetype:"{DAV:}getcontenttype",timestamp:"{DAV:}getlastmodified"},revert:function(e){e=e?_.clone(e):{};var t=this;return this.get("client").move("/versions/"+this.get("fileId")+"/"+this.get("id"),"/restore/target",!0).done(function(){e.success&&e.success.call(e.context,t,{},e),t.trigger("revert",t,e)}).fail(function(){e.error&&e.error.call(e.context,t,{},e),t.trigger("error",t,{},e)})},getFullPath:function(){return this.get("fullPath")},getPreviewUrl:function(){var e=OC.generateUrl("/apps/files_versions/preview"),t={file:this.get("fullPath"),version:this.get("timestamp")};return e+"?"+OC.buildQueryString(t)},getDownloadUrl:function(){return OC.linkToRemoteBase("dav")+"/versions/"+this.get("user")+"/versions/"+this.get("fileId")+"/"+this.get("id")}}),OCA.Versions=OCA.Versions||{},OCA.Versions.VersionModel=n},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 i,r;i=Handlebars.template,(r=OCA.Versions.Templates=OCA.Versions.Templates||{}).item=i({1:function(e,t,i,r,o){var s,l=null!=t?t:e.nullContext||{},a=i.helperMissing,c=e.escapeExpression;return'\t\t\t\t
\n\t\t\t\t\t'+c("function"===n(s=null!=(s=i.humanReadableSize||(null!=t?t.humanReadableSize:t))?s:a)?s.call(l,{name:"humanReadableSize",hash:{},data:o}):s)+"\n\t\t\t\t
\n"},3:function(e,t,i,r,o){var s,l=null!=t?t:e.nullContext||{},a=i.helperMissing,c=e.escapeExpression;return'\t\t\t\n'},compiler:[7,">= 4.0.0"],main:function(e,t,i,r,o){var s,l,a,c=null!=t?t:e.nullContext||{},u=i.helperMissing,f="function",d=e.escapeExpression,p=i.blockHelperMissing,h='
  • \n\t
    \n\t\t
    \n\t\t\t\n\t\t
    \n\t\t
    \n\t\t\t\n";return l=null!=(l=i.hasDetails||(null!=t?t.hasDetails:t))?l:u,a={name:"hasDetails",hash:{},fn:e.program(1,o,0),inverse:e.noop,data:o},s=n(l)===f?l.call(c,a):l,i.hasDetails||(s=p.call(t,s,a)),null!=s&&(h+=s),h+="\t\t
    \n",l=null!=(l=i.canRevert||(null!=t?t.canRevert:t))?l:u,a={name:"canRevert",hash:{},fn:e.program(3,o,0),inverse:e.noop,data:o},s=n(l)===f?l.call(c,a):l,i.canRevert||(s=p.call(t,s,a)),null!=s&&(h+=s),h+"\t
    \n
  • \n"},useData:!0}),r.template=i({compiler:[7,">= 4.0.0"],main:function(e,t,i,r,o){var s,l=null!=t?t:e.nullContext||{},a=i.helperMissing,c=e.escapeExpression;return'\n
    \n\n\n\n'},useData:!0})},function(e,t){var n;n=OC.Backbone.Collection.extend({model:OCA.Versions.VersionModel,sync:OC.Backbone.davSync,_fileInfo:null,_currentUser:null,_client:null,setFileInfo:function(e){this._fileInfo=e},getFileInfo:function(){return this._fileInfo},setCurrentUser:function(e){this._currentUser=e},getCurrentUser:function(){return this._currentUser||OC.getCurrentUser().uid},setClient:function(e){this._client=e},getClient:function(){return this._client||new OC.Files.Client({host:OC.getHost(),root:OC.linkToRemoteBase("dav")+"/versions/"+this.getCurrentUser(),useHTTPS:"https"===OC.getProtocol()})},url:function(){return OC.linkToRemoteBase("dav")+"/versions/"+this.getCurrentUser()+"/versions/"+this._fileInfo.get("id")},parse:function(e){var t=this._fileInfo.getFullPath(),n=this._fileInfo.get("id"),i=this._fileInfo.get("name"),r=this.getCurrentUser(),o=this.getClient();return _.map(e,function(e){return e.fullPath=t,e.fileId=n,e.name=i,e.timestamp=parseInt(moment(new Date(e.timestamp)).format("X"),10),e.id=parseInt(OC.basename(e.href),10),e.size=parseInt(e.size,10),e.user=r,e.client=o,e})}}),OCA.Versions=OCA.Versions||{},OCA.Versions.VersionCollection=n},function(e,i){var r;r=OCA.Files.DetailTabView.extend({id:"versionsTabView",className:"tab versionsTabView",_template:null,$versionsContainer:null,events:{"click .revertVersion":"_onClickRevertVersion"},initialize:function(){OCA.Files.DetailTabView.prototype.initialize.apply(this,arguments),this.collection=new OCA.Versions.VersionCollection,this.collection.on("request",this._onRequest,this),this.collection.on("sync",this._onEndRequest,this),this.collection.on("update",this._onUpdate,this),this.collection.on("error",this._onError,this),this.collection.on("add",this._onAddModel,this)},getLabel:function(){return t("files_versions","Versions")},getIcon:function(){return"icon-history"},nextPage:function(){this._loading||this.collection.getFileInfo()&&this.collection.getFileInfo().isDirectory()||this.collection.fetch()},_onClickRevertVersion:function(e){var n,i=this,r=$(e.target),o=this.collection.getFileInfo();r.is("li")||(r=r.closest("li")),e.preventDefault(),n=r.attr("data-revision");var s=this.collection.get(n);s.revert({success:function(){i.$versionsContainer.empty(),i.collection.setFileInfo(o),i.collection.reset([],{silent:!0}),i.collection.fetch(),i.$el.find(".versions").removeClass("hidden"),o.trigger("busy",o,!1),o.set({size:s.get("size"),mtime:1e3*s.get("timestamp"),etag:s.get("id")+s.get("timestamp")})},error:function(){o.trigger("busy",o,!1),i.$el.find(".versions").removeClass("hidden"),i._toggleLoading(!1),OC.Notification.show(t("files_version","Failed to revert {file} to revision {timestamp}.",{file:s.getFullPath(),timestamp:OC.Util.formatDate(1e3*s.get("timestamp"))}),{type:"error"})}}),this._toggleLoading(!0),o.trigger("busy",o,!0)},_toggleLoading:function(e){this._loading=e,this.$el.find(".loading").toggleClass("hidden",!e)},_onRequest:function(){this._toggleLoading(!0)},_onEndRequest:function(){this._toggleLoading(!1),this.$el.find(".empty").toggleClass("hidden",!!this.collection.length)},_onAddModel:function(e){var t=$(this.itemTemplate(this._formatItem(e)));this.$versionsContainer.append(t),t.find(".has-tooltip").tooltip()},template:function(e){return OCA.Versions.Templates.template(e)},itemTemplate:function(e){return OCA.Versions.Templates.item(e)},setFileInfo:function(e){e?(this.render(),this.collection.setFileInfo(e),this.collection.reset([],{silent:!0}),this.nextPage()):(this.render(),this.collection.reset())},_formatItem:function(e){var i=1e3*e.get("timestamp"),r=e.has("size")?e.get("size"):0,o=OC.MimeType.getIconUrl(e.get("mimetype")),s=new Image;return s.onload=function(){$("li[data-revision="+e.get("timestamp")+"] .preview").attr("src",e.getPreviewUrl())},s.src=e.getPreviewUrl(),_.extend({versionId:e.get("id"),formattedTimestamp:OC.Util.formatDate(i),relativeTimestamp:OC.Util.relativeModifiedDate(i),millisecondsTimestamp:i,humanReadableSize:OC.Util.humanFileSize(r,!0),altSize:n("files","%n byte","%n bytes",r),hasDetails:e.has("size"),downloadUrl:e.getDownloadUrl(),downloadIconUrl:OC.imagePath("core","actions/download"),downloadName:e.get("name"),revertIconUrl:OC.imagePath("core","actions/history"),previewUrl:o,revertLabel:t("files_versions","Restore"),canRevert:0!=(this.collection.getFileInfo().get("permissions")&OC.PERMISSION_UPDATE)},e.attributes)},render:function(){this.$el.html(this.template({emptyResultLabel:t("files_versions","No other versions available")})),this.$el.find(".has-tooltip").tooltip(),this.$versionsContainer=this.$el.find("ul.versions"),this.delegateEvents()},canDisplay:function(e){return!!e&&!e.isDirectory()}}),OCA.Versions=OCA.Versions||{},OCA.Versions.VersionsTabView=r},function(e,t){OCA.Versions=OCA.Versions||{},OCA.Versions.Util={attach:function(e){"trashbin"!==e.id&&"files.public"!==e.id&&e.registerTabView(new OCA.Versions.VersionsTabView("versionsTabView",{order:-10}))}},OC.Plugins.register("OCA.Files.FileList",OCA.Versions.Util)},function(e,t,n){var i=n(7);"string"==typeof i&&(i=[[e.i,i,""]]);var r={hmr:!0,transform:void 0,insertInto:void 0};n(9)(i,r);i.locals&&(e.exports=i.locals)},function(e,t,n){(e.exports=n(8)(!1)).push([e.i,".versionsTabView .clear-float {\n\tclear: both;\n}\n\n.versionsTabView li {\n\twidth: 100%;\n\tcursor: default;\n\theight: 56px;\n\tfloat: left;\n\tborder-bottom: 1px solid rgba(100,100,100,.1);\n}\n.versionsTabView li:last-child {\n\tborder-bottom: none;\n}\n\n.versionsTabView a,\n.versionsTabView div > span {\n\tvertical-align: middle;\n\topacity: .5;\n}\n\n.versionsTabView li a{\n\tpadding: 15px 10px 11px;\n}\n\n.versionsTabView a:hover,\n.versionsTabView a:focus {\n\topacity: 1;\n}\n\n.versionsTabView .preview-container {\n\tdisplay: inline-block;\n vertical-align: top;\n}\n\n.versionsTabView img {\n\tcursor: pointer;\n\tpadding-right: 4px;\n}\n\n.versionsTabView img.preview {\n\tcursor: default;\n}\n\n.versionsTabView .version-container {\n\tdisplay: inline-block;\n}\n\n.versionsTabView .versiondate {\n\tmin-width: 100px;\n\tvertical-align: super;\n}\n\n.versionsTabView .version-details {\n\ttext-align: left;\n}\n\n.versionsTabView .version-details > span {\n\tpadding: 0 10px;\n}\n\n.versionsTabView .revertVersion {\n\tcursor: pointer;\n\tfloat: right;\n\tmargin-right: -10px;\n}\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]||"",i=e[3];if(!i)return n;if(t&&"function"==typeof btoa){var r=(s=i,"/*# sourceMappingURL=data:application/json;charset=utf-8;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(s))))+" */"),o=i.sources.map(function(e){return"/*# sourceURL="+i.sourceRoot+e+" */"});return[n].concat(o).concat([r]).join("\n")}var s;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 i={},r=0;r=0&&u.splice(t,1)}function v(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var i=function(){0;return n.nc}();i&&(e.attrs.nonce=i)}return g(t,e.attrs),h(e,t),t}function g(e,t){Object.keys(t).forEach(function(n){e.setAttribute(n,t[n])})}function b(e,t){var n,i,r,o;if(t.transform&&e.css){if(!(o="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=o}if(t.singleton){var s=c++;n=a||(a=v(t)),i=C.bind(null,n,s,!1),r=C.bind(null,n,s,!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",g(t,e.attrs),h(e,t),t}(t),i=function(e,t,n){var i=n.css,r=n.sourceMap,o=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||o)&&(i=f(i));r&&(i+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var s=new Blob([i],{type:"text/css"}),l=e.href;e.href=URL.createObjectURL(s),l&&URL.revokeObjectURL(l)}.bind(null,n,t),r=function(){m(n),n.href&&URL.revokeObjectURL(n.href)}):(n=v(t),i=function(e,t){var n=t.css,i=t.media;i&&e.setAttribute("media",i);if(e.styleSheet)e.styleSheet.cssText=n;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(n))}}.bind(null,n),r=function(){m(n)});return i(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;i(e=t)}else r()}}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=s()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var n=p(e,t);return d(n,t),function(e){for(var i=[],r=0;r\\n\t\t\t\t\t\"\n + alias4(((helper = (helper = helpers.humanReadableSize || (depth0 != null ? depth0.humanReadableSize : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"humanReadableSize\",\"hash\":{},\"data\":data}) : helper)))\n + \"\\n\t\t\t\t\\n\";\n},\"3\":function(container,depth0,helpers,partials,data) {\n var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=\"function\", alias4=container.escapeExpression;\n\n return \"\t\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\", alias4=container.escapeExpression, alias5=helpers.blockHelperMissing, buffer = \n \"
  • \\n\t
    \\n\t\t
    \\n\t\t\t\\n\t\t
    \\n\t\t
    \\n\t\t\t\\n\";\n stack1 = ((helper = (helper = helpers.hasDetails || (depth0 != null ? depth0.hasDetails : depth0)) != null ? helper : alias2),(options={\"name\":\"hasDetails\",\"hash\":{},\"fn\":container.program(1, data, 0),\"inverse\":container.noop,\"data\":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));\n if (!helpers.hasDetails) { stack1 = alias5.call(depth0,stack1,options)}\n if (stack1 != null) { buffer += stack1; }\n buffer += \"\t\t
    \\n\";\n stack1 = ((helper = (helper = helpers.canRevert || (depth0 != null ? depth0.canRevert : depth0)) != null ? helper : alias2),(options={\"name\":\"canRevert\",\"hash\":{},\"fn\":container.program(3, data, 0),\"inverse\":container.noop,\"data\":data}),(typeof helper === alias3 ? helper.call(alias1,options) : helper));\n if (!helpers.canRevert) { stack1 = alias5.call(depth0,stack1,options)}\n if (stack1 != null) { buffer += stack1; }\n return buffer + \"\t
    \\n
  • \\n\";\n},\"useData\":true});\ntemplates['template'] = template({\"compiler\":[7,\">= 4.0.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=helpers.helperMissing, alias3=\"function\", alias4=container.escapeExpression;\n\n return \"
      \\n
      \\n
      \\n\t
      \\n\t\t
      \\n\t\t

      \"\n + alias4(((helper = (helper = helpers.emptyResultLabel || (depth0 != null ? depth0.emptyResultLabel : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"emptyResultLabel\",\"hash\":{},\"data\":data}) : helper)))\n + \"

      \\n\t
      \\n
      \\n\\n
      \\n\";\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 () {\n\t/**\n\t * @memberof OCA.Versions\n\t */\n\tvar VersionCollection = OC.Backbone.Collection.extend({\n\t\tmodel: OCA.Versions.VersionModel,\n\t\tsync: OC.Backbone.davSync,\n\n\t\t/**\n\t\t * @var OCA.Files.FileInfoModel\n\t\t */\n\t\t_fileInfo: null,\n\n\t\t_currentUser: null,\n\n\t\t_client: null,\n\n\t\tsetFileInfo: function (fileInfo) {\n\t\t\tthis._fileInfo = fileInfo;\n\t\t},\n\n\t\tgetFileInfo: function () {\n\t\t\treturn this._fileInfo;\n\t\t},\n\n\t\tsetCurrentUser: function(user) {\n\t\t\tthis._currentUser = user;\n\t\t},\n\n\t\tgetCurrentUser: function() {\n\t\t\treturn this._currentUser || OC.getCurrentUser().uid;\n\t\t},\n\n\t\tsetClient: function(client) {\n\t\t\tthis._client = client;\n\t\t},\n\n\t\tgetClient: function() {\n\t\t\treturn this._client || new OC.Files.Client({\n\t\t\t\thost: OC.getHost(),\n\t\t\t\troot: OC.linkToRemoteBase('dav') + '/versions/' + this.getCurrentUser(),\n\t\t\t\tuseHTTPS: OC.getProtocol() === 'https'\n\t\t\t});\n\t\t},\n\n\t\turl: function () {\n\t\t\treturn OC.linkToRemoteBase('dav') + '/versions/' + this.getCurrentUser() + '/versions/' + this._fileInfo.get('id');\n\t\t},\n\n\t\tparse: function(result) {\n\t\t\tvar fullPath = this._fileInfo.getFullPath();\n\t\t\tvar fileId = this._fileInfo.get('id');\n\t\t\tvar name = this._fileInfo.get('name');\n\t\t\tvar user = this.getCurrentUser();\n\t\t\tvar client = this.getClient();\n\t\t\treturn _.map(result, function(version) {\n\t\t\t\tversion.fullPath = fullPath;\n\t\t\t\tversion.fileId = fileId;\n\t\t\t\tversion.name = name;\n\t\t\t\tversion.timestamp = parseInt(moment(new Date(version.timestamp)).format('X'), 10);\n\t\t\t\tversion.id = parseInt(OC.basename(version.href), 10);\n\t\t\t\tversion.size = parseInt(version.size, 10);\n\t\t\t\tversion.user = user;\n\t\t\t\tversion.client = client;\n\t\t\t\treturn version;\n\t\t\t});\n\t\t}\n\t});\n\n\tOCA.Versions = OCA.Versions || {};\n\n\tOCA.Versions.VersionCollection = VersionCollection;\n})();\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() {\n\t/**\n\t * @memberof OCA.Versions\n\t */\n\tvar VersionsTabView = OCA.Files.DetailTabView.extend(/** @lends OCA.Versions.VersionsTabView.prototype */{\n\t\tid: 'versionsTabView',\n\t\tclassName: 'tab versionsTabView',\n\n\t\t_template: null,\n\n\t\t$versionsContainer: null,\n\n\t\tevents: {\n\t\t\t'click .revertVersion': '_onClickRevertVersion'\n\t\t},\n\n\t\tinitialize: function() {\n\t\t\tOCA.Files.DetailTabView.prototype.initialize.apply(this, arguments);\n\t\t\tthis.collection = new OCA.Versions.VersionCollection();\n\t\t\tthis.collection.on('request', this._onRequest, this);\n\t\t\tthis.collection.on('sync', this._onEndRequest, this);\n\t\t\tthis.collection.on('update', this._onUpdate, this);\n\t\t\tthis.collection.on('error', this._onError, this);\n\t\t\tthis.collection.on('add', this._onAddModel, this);\n\t\t},\n\n\t\tgetLabel: function() {\n\t\t\treturn t('files_versions', 'Versions');\n\t\t},\n\n\t\tgetIcon: function() {\n\t\t\treturn 'icon-history';\n\t\t},\n\n\t\tnextPage: function() {\n\t\t\tif (this._loading) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (this.collection.getFileInfo() && this.collection.getFileInfo().isDirectory()) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tthis.collection.fetch();\n\t\t},\n\n\t\t_onClickRevertVersion: function(ev) {\n\t\t\tvar self = this;\n\t\t\tvar $target = $(ev.target);\n\t\t\tvar fileInfoModel = this.collection.getFileInfo();\n\t\t\tvar revision;\n\t\t\tif (!$target.is('li')) {\n\t\t\t\t$target = $target.closest('li');\n\t\t\t}\n\n\t\t\tev.preventDefault();\n\t\t\trevision = $target.attr('data-revision');\n\n\t\t\tvar versionModel = this.collection.get(revision);\n\t\t\tversionModel.revert({\n\t\t\t\tsuccess: function() {\n\t\t\t\t\t// reset and re-fetch the updated collection\n\t\t\t\t\tself.$versionsContainer.empty();\n\t\t\t\t\tself.collection.setFileInfo(fileInfoModel);\n\t\t\t\t\tself.collection.reset([], {silent: true});\n\t\t\t\t\tself.collection.fetch();\n\n\t\t\t\t\tself.$el.find('.versions').removeClass('hidden');\n\n\t\t\t\t\t// update original model\n\t\t\t\t\tfileInfoModel.trigger('busy', fileInfoModel, false);\n\t\t\t\t\tfileInfoModel.set({\n\t\t\t\t\t\tsize: versionModel.get('size'),\n\t\t\t\t\t\tmtime: versionModel.get('timestamp') * 1000,\n\t\t\t\t\t\t// temp dummy, until we can do a PROPFIND\n\t\t\t\t\t\tetag: versionModel.get('id') + versionModel.get('timestamp')\n\t\t\t\t\t});\n\t\t\t\t},\n\n\t\t\t\terror: function() {\n\t\t\t\t\tfileInfoModel.trigger('busy', fileInfoModel, false);\n\t\t\t\t\tself.$el.find('.versions').removeClass('hidden');\n\t\t\t\t\tself._toggleLoading(false);\n\t\t\t\t\tOC.Notification.show(t('files_version', 'Failed to revert {file} to revision {timestamp}.',\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\tfile: versionModel.getFullPath(),\n\t\t\t\t\t\t\ttimestamp: OC.Util.formatDate(versionModel.get('timestamp') * 1000)\n\t\t\t\t\t\t}),\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'error'\n\t\t\t\t\t\t}\n\t\t\t\t\t);\n\t\t\t\t}\n\t\t\t});\n\n\t\t\t// spinner\n\t\t\tthis._toggleLoading(true);\n\t\t\tfileInfoModel.trigger('busy', fileInfoModel, true);\n\t\t},\n\n\t\t_toggleLoading: function(state) {\n\t\t\tthis._loading = state;\n\t\t\tthis.$el.find('.loading').toggleClass('hidden', !state);\n\t\t},\n\n\t\t_onRequest: function() {\n\t\t\tthis._toggleLoading(true);\n\t\t},\n\n\t\t_onEndRequest: function() {\n\t\t\tthis._toggleLoading(false);\n\t\t\tthis.$el.find('.empty').toggleClass('hidden', !!this.collection.length);\n\t\t},\n\n\t\t_onAddModel: function(model) {\n\t\t\tvar $el = $(this.itemTemplate(this._formatItem(model)));\n\t\t\tthis.$versionsContainer.append($el);\n\t\t\t$el.find('.has-tooltip').tooltip();\n\t\t},\n\n\t\ttemplate: function(data) {\n\t\t\treturn OCA.Versions.Templates['template'](data);\n\t\t},\n\n\t\titemTemplate: function(data) {\n\t\t\treturn OCA.Versions.Templates['item'](data);\n\t\t},\n\n\t\tsetFileInfo: function(fileInfo) {\n\t\t\tif (fileInfo) {\n\t\t\t\tthis.render();\n\t\t\t\tthis.collection.setFileInfo(fileInfo);\n\t\t\t\tthis.collection.reset([], {silent: true});\n\t\t\t\tthis.nextPage();\n\t\t\t} else {\n\t\t\t\tthis.render();\n\t\t\t\tthis.collection.reset();\n\t\t\t}\n\t\t},\n\n\t\t_formatItem: function(version) {\n\t\t\tvar timestamp = version.get('timestamp') * 1000;\n\t\t\tvar size = version.has('size') ? version.get('size') : 0;\n\t\t\tvar preview = OC.MimeType.getIconUrl(version.get('mimetype'));\n\t\t\tvar img = new Image();\n\t\t\timg.onload = function () {\n\t\t\t\t$('li[data-revision=' + version.get('timestamp') + '] .preview').attr('src', version.getPreviewUrl());\n\t\t\t};\n\t\t\timg.src = version.getPreviewUrl();\n\n\t\t\treturn _.extend({\n\t\t\t\tversionId: version.get('id'),\n\t\t\t\tformattedTimestamp: OC.Util.formatDate(timestamp),\n\t\t\t\trelativeTimestamp: OC.Util.relativeModifiedDate(timestamp),\n\t\t\t\tmillisecondsTimestamp: timestamp,\n\t\t\t\thumanReadableSize: OC.Util.humanFileSize(size, true),\n\t\t\t\taltSize: n('files', '%n byte', '%n bytes', size),\n\t\t\t\thasDetails: version.has('size'),\n\t\t\t\tdownloadUrl: version.getDownloadUrl(),\n\t\t\t\tdownloadIconUrl: OC.imagePath('core', 'actions/download'),\n\t\t\t\tdownloadName: version.get('name'),\n\t\t\t\trevertIconUrl: OC.imagePath('core', 'actions/history'),\n\t\t\t\tpreviewUrl: preview,\n\t\t\t\trevertLabel: t('files_versions', 'Restore'),\n\t\t\t\tcanRevert: (this.collection.getFileInfo().get('permissions') & OC.PERMISSION_UPDATE) !== 0\n\t\t\t}, version.attributes);\n\t\t},\n\n\t\t/**\n\t\t * Renders this details view\n\t\t */\n\t\trender: function() {\n\t\t\tthis.$el.html(this.template({\n\t\t\t\temptyResultLabel: t('files_versions', 'No other versions available'),\n\t\t\t}));\n\t\t\tthis.$el.find('.has-tooltip').tooltip();\n\t\t\tthis.$versionsContainer = this.$el.find('ul.versions');\n\t\t\tthis.delegateEvents();\n\t\t},\n\n\t\t/**\n\t\t * Returns true for files, false for folders.\n\t\t *\n\t\t * @return {bool} true for files, false for folders\n\t\t */\n\t\tcanDisplay: function(fileInfo) {\n\t\t\tif (!fileInfo) {\n\t\t\t\treturn false;\n\t\t\t}\n\t\t\treturn !fileInfo.isDirectory();\n\t\t}\n\t});\n\n\tOCA.Versions = OCA.Versions || {};\n\n\tOCA.Versions.VersionsTabView = VersionsTabView;\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() {\n\tOCA.Versions = OCA.Versions || {};\n\n\t/**\n\t * @namespace\n\t */\n\tOCA.Versions.Util = {\n\t\t/**\n\t\t * Initialize the versions plugin.\n\t\t *\n\t\t * @param {OCA.Files.FileList} fileList file list to be extended\n\t\t */\n\t\tattach: function(fileList) {\n\t\t\tif (fileList.id === 'trashbin' || fileList.id === 'files.public') {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tfileList.registerTabView(new OCA.Versions.VersionsTabView('versionsTabView', {order: -10}));\n\t\t}\n\t};\n})();\n\nOC.Plugins.register('OCA.Files.FileList', OCA.Versions.Util);\n\n","\nvar content = require(\"!!../../../../node_modules/css-loader/dist/cjs.js!./versions.css\");\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!./versions.css\", function() {\n\t\tvar newContent = require(\"!!../../../../node_modules/css-loader/dist/cjs.js!./versions.css\");\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, \".versionsTabView .clear-float {\\n\\tclear: both;\\n}\\n\\n.versionsTabView li {\\n\\twidth: 100%;\\n\\tcursor: default;\\n\\theight: 56px;\\n\\tfloat: left;\\n\\tborder-bottom: 1px solid rgba(100,100,100,.1);\\n}\\n.versionsTabView li:last-child {\\n\\tborder-bottom: none;\\n}\\n\\n.versionsTabView a,\\n.versionsTabView div > span {\\n\\tvertical-align: middle;\\n\\topacity: .5;\\n}\\n\\n.versionsTabView li a{\\n\\tpadding: 15px 10px 11px;\\n}\\n\\n.versionsTabView a:hover,\\n.versionsTabView a:focus {\\n\\topacity: 1;\\n}\\n\\n.versionsTabView .preview-container {\\n\\tdisplay: inline-block;\\n vertical-align: top;\\n}\\n\\n.versionsTabView img {\\n\\tcursor: pointer;\\n\\tpadding-right: 4px;\\n}\\n\\n.versionsTabView img.preview {\\n\\tcursor: default;\\n}\\n\\n.versionsTabView .version-container {\\n\\tdisplay: inline-block;\\n}\\n\\n.versionsTabView .versiondate {\\n\\tmin-width: 100px;\\n\\tvertical-align: super;\\n}\\n\\n.versionsTabView .version-details {\\n\\ttext-align: left;\\n}\\n\\n.versionsTabView .version-details > span {\\n\\tpadding: 0 10px;\\n}\\n\\n.versionsTabView .revertVersion {\\n\\tcursor: pointer;\\n\\tfloat: right;\\n\\tmargin-right: -10px;\\n}\\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