X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=manifoldapi%2Fstatic%2Fjs%2Fplugin.js;h=495bdc7db81ec5ca02f42c5e63e82b93f6a2a35d;hb=b754744bb47b51851da85efa2f039951a96f8031;hp=da26f1f37108f94c3c011e166e38294dabb770b8;hpb=6eb1d8c9d03d2b10b514c317b6fff11172097346;p=unfold.git diff --git a/manifoldapi/static/js/plugin.js b/manifoldapi/static/js/plugin.js index da26f1f3..495bdc7d 100644 --- a/manifoldapi/static/js/plugin.js +++ b/manifoldapi/static/js/plugin.js @@ -1,3 +1,24 @@ +// Common parts for angularjs plugins +// only one ng-app is allowed + +var ManifoldApp = angular.module('ManifoldApp', []); +ManifoldApp.config(function ($interpolateProvider) { + $interpolateProvider.startSymbol('{[{').endSymbol('}]}'); +}); + +ManifoldApp.factory('$exceptionHandler', function () { + return function (exception, cause) { + console.log(exception.message); + }; +}); + +ManifoldApp.filter('offset', function() { + return function(input, start) { + start = parseInt(start, 10); + return input.slice(start); + }; +}); + // INHERITANCE // http://alexsexton.com/blog/2010/02/using-inheritance-patterns-to-organize-large-jquery-applications/ // We will use John Resig's proposal @@ -295,15 +316,18 @@ var Plugin = Class.extend({ // use spin() to get our default spin settings (called presets) // use spin(true) to get spin's builtin defaults // you can also call spin_presets() yourself and tweak what you need to, like topmenuvalidation does - spin: function (presets) { - var presets = ( presets === undefined ) ? spin_presets() : presets; - try { this.$element.spin(presets); } - catch (err) { messages.debug("Cannot turn on spin " + err); } + spin: function (message) { + if (!message) { + message = 'Please be patient, this can take a minute or two.'; + } + $('div.loading').fadeIn('fast'); + $('div.loading').find('.message').text(message); + }, unspin: function() { - try { this.$element.spin(false); } - catch (err) { messages.debug("Cannot turn off spin " + err); } + $('div.loading').fadeOut('fast'); + }, /* TEMPLATE */