nextcloud-notes/js/public/app.min.js.map

1 line
26 KiB
Plaintext

{"version":3,"sources":["app.js","controllers/appcontroller.js","controllers/notecontroller.js","controllers/notescontroller.js","directives/autofocus.js","directives/editor.js","directives/tooltip.js","filters/and.js","filters/noteTitle.js","filters/wordCount.js","services/debounce.js","services/is.js","services/notesmodel.js","services/savequeue.js","services/urlFinder.js"],"names":["angular","$","requestToken","SimpleMDE","undefined","app","module","config","$provide","$routeProvider","RestangularProvider","$httpProvider","$windowProvider","defaults","headers","common","requesttoken","value","saveInterval","when","templateUrl","controller","resolve","note","$route","$q","is","Restangular","deferred","defer","noteId","current","params","loading","one","get","then","reject","promise","otherwise","redirectTo","baseUrl","OC","generateUrl","setBaseUrl","run","$rootScope","$location","NotesModel","attr","filePath","$on","notes","getAll","length","sorted","sort","a","b","modified","path","id","$scope","init","lastViewedNote","search","$routeParams","SaveQueue","debounce","$document","updateIfExists","isSaving","isManualSaving","updateTitle","title","content","split","t","onEdit","unsaved","autoSave","add","manualSave","error","addManual","unbind","bind","event","ctrlKey","metaKey","String","fromCharCode","which","toLowerCase","preventDefault","toggleDistractionFree","launchIntoFullscreen","element","requestFullscreen","mozRequestFullScreen","webkitRequestFullscreen","msRequestFullscreen","exitFullscreen","document","mozCancelFullScreen","webkitExitFullscreen","fullscreenElement","mozFullScreenElement","webkitFullscreenElement","getElementById","$window","route","notesResource","all","getList","addAll","create","post","remove","$emit","toggleFavorite","customPUT","favorite","onbeforeunload","i","directive","restrict","link","scope","focus","$timeout","urlFinder","simplemde","spellChecker","autoDownloadFontAwesome","toolbar","status","forceSync","editorElement","codemirror","getWrapperElement","on","$apply","url","this","isDefined","window","open","tooltip","container","filter","$filter","items","searchString","searchValues","filtered","trim","replace","wordCount","n","factory","func","delay","timeout","context","args","arguments","cancel","apply","notesIds","prototype","updated","push","splice","_queue","_flushLock","_manualSaveActive","_flush","keys","Object","self","requests","put","_noteUpdateRequest","_saveFailed","response","prev","next","text","jQuery","oc_requesttoken"],"mappings":"CA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J,OAAA,WAEA,GAAAC,GAAAC,OAAAD,KAAAlC,KAAA8B,OACA,IAAA,IAAAI,EAAA5H,SAAA0F,KAAA+B,WAAA,CAGA/B,KAAA+B,YAAA,CAQA,KAAA,GALAK,GAAApC,KACAqC,KAIAzD,EAAA,EAAAA,EAAAsD,EAAA5H,OAAAsE,GAAA,EAAA,CACA,GAAArG,GAAAyH,KAAA8B,OAAAI,EAAAtD,GAGAyD,GAAAT,KAAArJ,EAAA+J,MAAAlJ,KACA4G,KAAAuC,mBAAAjG,KAAA,KAAA/D,IADAA,SAEAyH,KAAAwC,YAAAlG,KAAA,KAAA/D,KAGAyH,KAAA8B,UAIArJ,EAAAwF,IAAAoE,GAAAjJ,KAAA,WACAgJ,EAAAL,YAAA,EACAK,EAAAH,SACAG,EAAAJ,mBAAA,MAGAO,mBAAA,SAAAhK,EAAAkK,GACAlK,EAAA4D,OAAA,EACA5D,EAAAmD,MAAA+G,EAAA/G,MACAnD,EAAAoC,SAAA8H,EAAA9H,SACA8H,EAAA9G,UAAApD,EAAAoD,UACApD,EAAAwD,SAAA,IAGAyG,YAAA,SAAAjK,GACAA,EAAA4D,OAAA,GAEAZ,SAAA,WACA,MAAAyE,MAAA+B,YAEAvG,eAAA,WACA,MAAAwE,MAAAgC,oBAIA,GAAA7G,MCpEA9D,EAAA2J,QAAA,aAAA,WAGA,MAAA,UAAA/D,GAWA,IAVAA,EAAAhG,EAAAgG,GAGAA,EAAAvE,GAAA,0BACA,IAAAuE,EAAAyF,OAAApI,SACA2C,EAAAA,EAAAyF,QAKAzF,EAAAvE,GAAA,aACAuE,EAAAA,EAAA0F,MAIA,MAAA1F,EAAAvE,GAAA,0BACAuE,EAAAA,EAAA0F,MAIA,OAAA1F,GAAAvE,GAAA,+BACAuE,EAAA2F,OAGAxL,OAGAJ,QAAA6L,OAAAC,gBAAA3L","file":"app.min.js","sourcesContent":["/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\n/* jshint unused: false */\nvar app = angular.module('Notes', ['restangular', 'ngRoute']).\nconfig(function($provide, $routeProvider, RestangularProvider, $httpProvider,\n $windowProvider) {\n 'use strict';\n\n // Always send the CSRF token by default\n $httpProvider.defaults.headers.common.requesttoken = requestToken;\n\n // you have to use $provide inside the config method to provide a globally\n // shared and injectable object\n $provide.value('Constants', {\n saveInterval: 5*1000 // miliseconds\n });\n\n // define your routes that that load templates into the ng-view\n $routeProvider.when('/notes/:noteId', {\n templateUrl: 'note.html',\n controller: 'NoteController',\n resolve: {\n // $routeParams does not work inside resolve so use $route\n // note is the name of the argument that will be injected into the\n // controller\n /* @ngInject */\n note: function ($route, $q, is, Restangular) {\n\n var deferred = $q.defer();\n var noteId = $route.current.params.noteId;\n is.loading = true;\n\n Restangular.one('notes', noteId).get().then(function (note) {\n is.loading = false;\n deferred.resolve(note);\n }, function () {\n is.loading = false;\n deferred.reject();\n });\n\n return deferred.promise;\n }\n }\n }).otherwise({\n redirectTo: '/'\n });\n\n var baseUrl = OC.generateUrl('/apps/notes');\n RestangularProvider.setBaseUrl(baseUrl);\n\n\n\n}).run(function ($rootScope, $location, NotesModel) {\n 'use strict';\n\n $('link[rel=\"shortcut icon\"]').attr(\n\t\t 'href',\n\t\t OC.filePath('notes', 'img', 'favicon.png')\n );\n\n // handle route errors\n $rootScope.$on('$routeChangeError', function () {\n var notes = NotesModel.getAll();\n\n // route change error should redirect to the latest note if possible\n if (notes.length > 0) {\n var sorted = notes.sort(function (a, b) {\n if(a.modified > b.modified) {\n return 1;\n } else if(a.modified < b.modified) {\n return -1;\n } else {\n return 0;\n }\n });\n\n var note = notes[sorted.length-1];\n $location.path('/notes/' + note.id);\n } else {\n $location.path('/');\n }\n });\n});\n","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\napp.controller('AppController', function ($scope, $location, is) {\n 'use strict';\n\n $scope.is = is;\n\n $scope.init = function (lastViewedNote) {\n if(lastViewedNote !== 0) {\n $location.path('/notes/' + lastViewedNote);\n }\n };\n\n $scope.search = '';\n});\n","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\napp.controller('NoteController', function($routeParams, $scope, NotesModel,\n SaveQueue, note, debounce,\n $document) {\n 'use strict';\n\n NotesModel.updateIfExists(note);\n\n $scope.note = NotesModel.get($routeParams.noteId);\n\n $scope.isSaving = function () {\n return SaveQueue.isSaving();\n };\n $scope.isManualSaving = function () {\n return SaveQueue.isManualSaving();\n };\n\n $scope.updateTitle = function () {\n $scope.note.title = $scope.note.content.split('\\n')[0] ||\n t('notes', 'New note');\n };\n\n $scope.onEdit = function() {\n var note = $scope.note;\n note.unsaved = true;\n $scope.autoSave(note);\n };\n\n $scope.autoSave = debounce(function(note) {\n SaveQueue.add(note);\n }, 1000);\n\n $scope.manualSave = function() {\n var note = $scope.note;\n note.error = false;\n SaveQueue.addManual(note);\n };\n\n $document.unbind('keypress.notes.save');\n $document.bind('keypress.notes.save', function(event) {\n if(event.ctrlKey || event.metaKey) {\n switch(String.fromCharCode(event.which).toLowerCase()) {\n case 's':\n event.preventDefault();\n $scope.manualSave();\n break;\n }\n }\n });\n\n $scope.toggleDistractionFree = function() {\n function launchIntoFullscreen(element) {\n if(element.requestFullscreen) {\n element.requestFullscreen();\n } else if(element.mozRequestFullScreen) {\n element.mozRequestFullScreen();\n } else if(element.webkitRequestFullscreen) {\n element.webkitRequestFullscreen();\n } else if(element.msRequestFullscreen) {\n element.msRequestFullscreen();\n }\n }\n\n function exitFullscreen() {\n if(document.exitFullscreen) {\n document.exitFullscreen();\n } else if(document.mozCancelFullScreen) {\n document.mozCancelFullScreen();\n } else if(document.webkitExitFullscreen) {\n document.webkitExitFullscreen();\n }\n }\n\n if(document.fullscreenElement ||\n document.mozFullScreenElement ||\n document.webkitFullscreenElement) {\n exitFullscreen();\n } else {\n launchIntoFullscreen(document.getElementById('app-content'));\n }\n };\n\n});\n","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\n// This is available by using ng-controller=\"NotesController\" in your HTML\napp.controller('NotesController', function($routeParams, $scope, $location,\n Restangular, NotesModel, $window) {\n 'use strict';\n\n $scope.route = $routeParams;\n $scope.notes = NotesModel.getAll();\n\n var notesResource = Restangular.all('notes');\n\n // initial request for getting all notes\n notesResource.getList().then(function (notes) {\n NotesModel.addAll(notes);\n });\n\n $scope.create = function () {\n notesResource.post().then(function (note) {\n NotesModel.add(note);\n $location.path('/notes/' + note.id);\n });\n };\n\n $scope.delete = function (noteId) {\n var note = NotesModel.get(noteId);\n note.remove().then(function () {\n NotesModel.remove(noteId);\n $scope.$emit('$routeChangeError');\n });\n };\n\n $scope.toggleFavorite = function (noteId) {\n var note = NotesModel.get(noteId);\n note.customPUT({favorite: !note.favorite},\n 'favorite', {}, {}).then(function (favorite) {\n note.favorite = favorite ? true : false;\n });\n };\n\n\n $window.onbeforeunload = function() {\n var notes = NotesModel.getAll();\n for(var i=0; i<notes.length; i++) {\n if(notes[i].unsaved) {\n return t('notes', 'There are unsaved notes. Leaving ' +\n 'the page will discard all changes!');\n }\n }\n return null;\n };\n});\n","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\napp.directive('notesAutofocus', function () {\n 'use strict';\n return {\n restrict: 'A',\n link: function (scope, element) {\n element.focus();\n }\n };\n});\n","/*global SimpleMDE*/\napp.directive('editor', ['$timeout',\n 'urlFinder',\n function ($timeout, urlFinder) {\n\t'use strict';\n\treturn {\n\t\trestrict: 'A',\n\t\tlink: function(scope, element) {\n\n\t\t\tvar simplemde = new SimpleMDE({\n\t\t\t\telement: element[0],\n\t\t\t\tspellChecker: false,\n\t\t\t\tautoDownloadFontAwesome: false,\n\t\t\t\ttoolbar: false,\n\t\t\t\tstatus: false,\n\t\t\t\tforceSync: true\n\t\t\t});\n\t\t\tvar editorElement = $(simplemde.codemirror.getWrapperElement());\n\n\t\t\tsimplemde.value(scope.note.content);\n\n\t\t\tsimplemde.codemirror.on('change', function() {\n\t\t\t\t$timeout(function() {\n\t\t\t\t\tscope.$apply(function () {\n\t\t\t\t\t\tscope.note.content = simplemde.value();\n\t\t\t\t\t\tscope.onEdit();\n\t\t\t\t\t\tscope.updateTitle();\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t});\n\n\t\t\teditorElement.on('click', '.cm-link, .cm-url', function(event) {\n\t\t\t\tif(event.ctrlKey) {\n\t\t\t\t\tvar url = urlFinder(this);\n\t\t\t\t\tif(angular.isDefined(url)) {\n\t\t\t\t\t\twindow.open(url, '_blank');\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t});\n\t\t}\n\t};\n}]);\n","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\napp.directive('notesTooltip', function () {\n 'use strict';\n\n return {\n restrict: 'A',\n link: function (scope, element) {\n element.tooltip({'container': 'body'});\n\n element.on('$destroy', function() {\n element.tooltip('hide');\n });\n }\n };\n});\n","/**\n * filter by multiple words (AND operation)\n */\napp.filter('and', ['$filter', function ($filter) {\n\t'use strict';\n\treturn function (items, searchString) {\n\t\tvar searchValues = searchString.split(' ');\n\t\tvar filtered = items;\n\t\tfor(var i in searchValues) {\n\t\t\tfiltered = $filter('filter')(filtered, searchValues[i]);\n\t\t}\n\t\treturn filtered;\n\t};\n}]);\n","/**\n * removes whitespaces and leading #\n */\napp.filter('noteTitle', function () {\n\t'use strict';\n\treturn function (value) {\n \tvalue = value.split('\\n')[0] || 'newNote';\n\t\treturn value.trim().replace(/^#+/g, '');\n\t};\n});\n","app.filter('wordCount', function () {\n\t'use strict';\n\treturn function (value) {\n\t\tif (value && (typeof value === 'string')) {\n\t\t\tvar wordCount = value.split(/\\s+/).filter(\n\t\t\t\t// only count words containing\n\t\t\t\t// at least one alphanumeric character\n\t\t\t\tfunction(value) {\n\t\t\t\t\treturn value.search(/[A-Za-z0-9]/) !== -1;\n\t\t\t\t}\n\t\t\t).length;\n\t\t\treturn window.n('notes', '%n word', '%n words', wordCount);\n\t\t} else {\n\t\t\treturn 0;\n\t\t}\n\t};\n});\n","/**\n * Copyright (c) 2016, Hendrik Leppelsack\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\napp.factory('debounce', ['$timeout', function($timeout) {\n\t'use strict';\n\n\treturn function debounce(func, delay) {\n\t\tvar timeout;\n\n\t\treturn function() {\n\t\t\tvar context = this, args = arguments;\n\n\t\t\tif(timeout) {\n\t\t\t\t$timeout.cancel(timeout);\n\t\t\t}\n\t\t\ttimeout = $timeout(function() {\n\t\t\t\tfunc.apply(context, args);\n\t\t\t}, delay);\n\t\t};\n\t};\n}]);\n","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\napp.factory('is', function () {\n 'use strict';\n\n return {\n loading: false\n };\n});","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\n// take care of fileconflicts by appending a number\napp.factory('NotesModel', function () {\n 'use strict';\n\n var NotesModel = function () {\n this.notes = [];\n this.notesIds = {};\n };\n\n NotesModel.prototype = {\n addAll: function (notes) {\n for(var i=0; i<notes.length; i+=1) {\n this.add(notes[i]);\n }\n },\n add: function(note) {\n this.updateIfExists(note);\n },\n getAll: function () {\n return this.notes;\n },\n get: function (id) {\n return this.notesIds[id];\n },\n updateIfExists: function(updated) {\n var note = this.notesIds[updated.id];\n if(angular.isDefined(note)) {\n note.title = updated.title;\n note.modified = updated.modified;\n note.content = updated.content;\n note.favorite = updated.favorite;\n } else {\n this.notes.push(updated);\n this.notesIds[updated.id] = updated;\n }\n },\n remove: function (id) {\n for(var i=0; i<this.notes.length; i+=1) {\n var note = this.notes[i];\n if(note.id === id) {\n this.notes.splice(i, 1);\n delete this.notesIds[id];\n break;\n }\n }\n }\n };\n\n return new NotesModel();\n});\n","/**\n * Copyright (c) 2013, Bernhard Posselt <dev@bernhard-posselt.com>\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\napp.factory('SaveQueue', function($q) {\n 'use strict';\n\n var SaveQueue = function () {\n this._queue = {};\n this._flushLock = false;\n this._manualSaveActive = false;\n };\n\n SaveQueue.prototype = {\n add: function (note) {\n this._queue[note.id] = note;\n this._flush();\n },\n addManual: function (note) {\n this._manualSaveActive = true;\n this.add(note);\n },\n _flush: function () {\n // if there are no changes dont execute the requests\n var keys = Object.keys(this._queue);\n if(keys.length === 0 || this._flushLock) {\n return;\n } else {\n this._flushLock = true;\n }\n\n var self = this;\n var requests = [];\n\n // iterate over updated objects and run an update request for\n // each one of them\n for(var i=0; i<keys.length; i+=1) {\n var note = this._queue[keys[i]];\n // if the update finished, update the modified and title\n // attributes on the note\n requests.push(note.put().then(\n this._noteUpdateRequest.bind(null, note))\n .catch(this._saveFailed.bind(null, note))\n );\n }\n this._queue = {};\n\n // if all update requests are completed, run the flush\n // again to update the next batch of queued notes\n $q.all(requests).then(function () {\n self._flushLock = false;\n self._flush();\n self._manualSaveActive = false;\n });\n },\n _noteUpdateRequest: function (note, response) {\n note.error = false;\n note.title = response.title;\n note.modified = response.modified;\n if(response.content === note.content) {\n note.unsaved = false;\n }\n },\n _saveFailed: function (note) {\n note.error = true;\n },\n isSaving: function () {\n return this._flushLock;\n },\n isManualSaving: function () {\n return this._manualSaveActive;\n },\n };\n\n return new SaveQueue();\n});\n","/**\n * Copyright (c) 2016, Hendrik Leppelsack\n * This file is licensed under the Affero General Public License version 3 or\n * later.\n * See the COPYING file.\n */\n\n// finds the url which should be opened when a link is clicked\n// example: '[hello](http://example.com)'\napp.factory('urlFinder', [function() {\n\t'use strict';\n\n\treturn function urlFinder(element) {\n\t\telement = $(element);\n\n\t\t// special case: click on ')'\n\t\tif(element.is('.cm-url.cm-formatting')) {\n\t\t\tif(element.prev().length !== 0) {\n\t\t\t\telement = element.prev();\n\t\t\t}\n\t\t}\n\n\t\t// skip '[hello]'\n\t\twhile(element.is('.cm-link')) {\n\t\t\telement = element.next();\n\t\t}\n\n\t\t// skip '('\n\t\twhile(element.is('.cm-url.cm-formatting')) {\n\t\t\telement = element.next();\n\t\t}\n\n\t\t// check if we actually have a cm-url\n\t\tif(element.is('.cm-url:not(.cm-formatting)')) {\n\t\t\treturn element.text();\n\t\t}\n\n\t\treturn undefined;\n\t};\n}]);\n"]}