diff options
Diffstat (limited to 'module/web/static/js/utils')
-rw-r--r-- | module/web/static/js/utils/animations.js | 128 | ||||
-rw-r--r-- | module/web/static/js/utils/apitypes.js | 14 | ||||
-rw-r--r-- | module/web/static/js/utils/dialogs.js | 15 | ||||
-rw-r--r-- | module/web/static/js/utils/initHB.js | 10 | ||||
-rw-r--r-- | module/web/static/js/utils/lazyRequire.js | 96 | ||||
-rw-r--r-- | module/web/static/js/utils/remaining.js | 149 |
6 files changed, 0 insertions, 412 deletions
diff --git a/module/web/static/js/utils/animations.js b/module/web/static/js/utils/animations.js deleted file mode 100644 index 5131d3b8a..000000000 --- a/module/web/static/js/utils/animations.js +++ /dev/null @@ -1,128 +0,0 @@ -define(['jquery', 'underscore', 'transit'], function(jQuery, _) { - - // Adds an element and computes its height, which is saved as data attribute - // Important function to have slide animations - jQuery.fn.appendWithHeight = function(element, hide) { - var o = jQuery(this[0]); - element = jQuery(element); - - // TODO: additionally it could be placed out of viewport first - // The real height can only be retrieved when element is on DOM and display:true - element.css('visibility', 'hidden'); - o.append(element); - - var height = element.height(); - - // Hide the element - if (hide === true) { - element.hide(); - element.height(0); - } - - element.css('visibility', ''); - element.data('height', height); - - return this; - }; - - // Shortcut to have a animation when element is added - jQuery.fn.appendWithAnimation = function(element, animation) { - var o = jQuery(this[0]); - element = jQuery(element); - - if (animation === true) - element.hide(); - - o.append(element); - - if (animation === true) - element.fadeIn(); - -// element.calculateHeight(); - - return this; - }; - - // calculate the height and write it to data, should be used on invisible elements - jQuery.fn.calculateHeight = function(setHeight) { - var o = jQuery(this[0]); - var height = o.height(); - if (!height) { - var display = o.css('display'); - o.css('visibility', 'hidden'); - o.show(); - height = o.height(); - - o.css('display', display); - o.css('visibility', ''); - } - - if (setHeight) - o.css('height', height); - - o.data('height', height); - return this; - }; - - // TODO: carry arguments, optional height argument - - // reset arguments, sets overflow hidden - jQuery.fn.slideOut = function(reset) { - var o = jQuery(this[0]); - o.animate({height: o.data('height'), opacity: 'show'}, function() { - // reset css attributes; - if (reset) { - this.css('overflow', ''); - this.css('height', ''); - } - }); - return this; - }; - - jQuery.fn.slideIn = function(reset) { - var o = jQuery(this[0]); - if (reset) { - o.css('overflow', 'hidden'); - } - o.animate({height: 0, opacity: 'hide'}); - return this; - }; - - jQuery.fn.initTooltips = function(placement) { - placement || (placement = 'top'); - - var o = jQuery(this[0]); - o.find('[data-toggle="tooltip"]').tooltip( - { - delay: {show: 800, hide: 100}, - placement: placement - }); - - return this; - }; - - jQuery.fn._transit = jQuery.fn.transit; - - // Overriding transit plugin to support hide and show - jQuery.fn.transit = jQuery.fn.transition = function(props, duration, easing, callback) { - var self = this; - var cb = callback; - var newprops = _.extend({}, props); - - if (newprops && (newprops.opacity === 'hide')) { - newprops.opacity = 0; - - callback = function() { - self.css({display: 'none'}); - if (typeof cb === 'function') { - cb.apply(self); - } - }; - } else if (newprops && (newprops.opacity === 'show')) { - newprops.opacity = 1; - this.css({display: 'block'}); - } - - return this._transit(newprops, duration, easing, callback); - }; -});
\ No newline at end of file diff --git a/module/web/static/js/utils/apitypes.js b/module/web/static/js/utils/apitypes.js deleted file mode 100644 index 28620250e..000000000 --- a/module/web/static/js/utils/apitypes.js +++ /dev/null @@ -1,14 +0,0 @@ -// Autogenerated, do not edit! -define([], function() { - return { - DownloadState: {'Failed': 3, 'All': 0, 'Unmanaged': 4, 'Finished': 1, 'Unfinished': 2}, - DownloadStatus: {'Downloading': 10, 'NA': 0, 'Processing': 14, 'Waiting': 9, 'Decrypting': 13, 'Paused': 4, 'Failed': 7, 'Finished': 5, 'Skipped': 6, 'Unknown': 16, 'Aborted': 12, 'Online': 2, 'TempOffline': 11, 'Offline': 1, 'Custom': 15, 'Starting': 8, 'Queued': 3}, - FileStatus: {'Remote': 2, 'Ok': 0, 'Missing': 1}, - InputType: {'Multiple': 10, 'Int': 2, 'NA': 0, 'List': 11, 'Bool': 7, 'File': 3, 'Text': 1, 'Table': 12, 'Folder': 4, 'Password': 6, 'Click': 8, 'Select': 9, 'Textbox': 5}, - Interaction: {'Captcha': 2, 'All': 0, 'Query': 4, 'Notification': 1}, - MediaType: {'All': 0, 'Audio': 2, 'Image': 4, 'Other': 1, 'Video': 8, 'Document': 16, 'Archive': 32}, - PackageStatus: {'Paused': 1, 'Remote': 3, 'Folder': 2, 'Ok': 0}, - Permission: {'All': 0, 'Interaction': 32, 'Modify': 4, 'Add': 1, 'Accounts': 16, 'Plugins': 64, 'Download': 8, 'Delete': 2}, - Role: {'Admin': 0, 'User': 1}, - }; -});
\ No newline at end of file diff --git a/module/web/static/js/utils/dialogs.js b/module/web/static/js/utils/dialogs.js deleted file mode 100644 index 13478ff88..000000000 --- a/module/web/static/js/utils/dialogs.js +++ /dev/null @@ -1,15 +0,0 @@ -// Loads all helper and set own handlebars rules -define(['jquery', 'underscore', 'views/abstract/modalView'], function($, _, modal) { - - // Shows the confirm dialog for given context - // on success executes func with context - _.confirm = function(template, func, context) { - template = "text!tpl/" + template; - _.requireOnce([template], function(html) { - var template = _.compile(html); - var dialog = new modal(template, _.bind(func, context)); - dialog.show(); - }); - - }; -});
\ No newline at end of file diff --git a/module/web/static/js/utils/initHB.js b/module/web/static/js/utils/initHB.js deleted file mode 100644 index c977f063d..000000000 --- a/module/web/static/js/utils/initHB.js +++ /dev/null @@ -1,10 +0,0 @@ -// Loads all helper and set own handlebars rules -define(['underscore', 'handlebars', - 'helpers/formatSize', 'helpers/fileHelper', 'helpers/formatTime'], - function(_, Handlebars) { - // Replace with own lexer rules compiled from handlebars.l - Handlebars.Parser.lexer.rules = [/^(?:[^\x00]*?(?=(<%)))/, /^(?:[^\x00]+)/, /^(?:[^\x00]{2,}?(?=(\{\{|$)))/, /^(?:\{\{>)/, /^(?:<%=)/, /^(?:<%\/)/, /^(?:\{\{\^)/, /^(?:<%\s*else\b)/, /^(?:\{<%%)/, /^(?:\{\{&)/, /^(?:<%![\s\S]*?%>)/, /^(?:<%)/, /^(?:=)/, /^(?:\.(?=[%} ]))/, /^(?:\.\.)/, /^(?:[\/.])/, /^(?:\s+)/, /^(?:%%>)/, /^(?:%>)/, /^(?:"(\\["]|[^"])*")/, /^(?:'(\\[']|[^'])*')/, /^(?:@[a-zA-Z]+)/, /^(?:true(?=[%}\s]))/, /^(?:false(?=[%}\s]))/, /^(?:[0-9]+(?=[%}\s]))/, /^(?:[a-zA-Z0-9_$-]+(?=[=%}\s\/.]))/, /^(?:\[[^\]]*\])/, /^(?:.)/, /^(?:$)/]; - _.compile = Handlebars.compile; - - return Handlebars; - });
\ No newline at end of file diff --git a/module/web/static/js/utils/lazyRequire.js b/module/web/static/js/utils/lazyRequire.js deleted file mode 100644 index b381e0ce6..000000000 --- a/module/web/static/js/utils/lazyRequire.js +++ /dev/null @@ -1,96 +0,0 @@ -// Define the module. -define( - [ - "require", "underscore" - ], - function( require, _ ){ - - - // Define the states of loading for a given set of modules - // within a require() statement. - var states = { - unloaded: "UNLOADED", - loading: "LOADING", - loaded: "LOADED" - }; - - - // Define the top-level module container. Mostly, we're making - // the top-level container a non-Function so that users won't - // try to invoke this without calling the once() method below. - var lazyRequire = {}; - - - // I will return a new, unique instance of the requrieOnce() - // method. Each instance will only call the require() method - // once internally. - lazyRequire.once = function(){ - - // The modules start in an unloaded state before - // requireOnce() is invoked by the calling code. - var state = states.unloaded; - var args; - - var requireOnce = function(dependencies, loadCallback ){ - - // Use the module state to determine which method to - // invoke (or just to ignore the invocation). - if (state === states.loaded){ - loadCallback.apply(null, args); - - // The modules have not yet been requested - let's - // lazy load them. - } else if (state !== states.loading){ - - // We're about to load the modules asynchronously; - // flag the interim state. - state = states.loading; - - // Load the modules. - require( - dependencies, - function(){ - - args = arguments; - loadCallback.apply( null, args ); - state = states.loaded; - - - } - ); - - // RequireJS is currently loading the modules - // asynchronously, but they have not finished - // loading yet. - } else { - - // Simply ignore this call. - return; - - } - - }; - - // Return the new lazy loader. - return( requireOnce ); - - }; - - - // -------------------------------------------------- // - // -------------------------------------------------- // - - // Set up holder for underscore - var instances = {}; - _.requireOnce = function(dependencies, loadCallback) { - if (!_.has(instances, dependencies)) - instances[dependencies] = lazyRequire.once(); - - return instances[dependencies](dependencies, loadCallback) - }; - - - // Return the module definition. - return( lazyRequire ); - } -);
\ No newline at end of file diff --git a/module/web/static/js/utils/remaining.js b/module/web/static/js/utils/remaining.js deleted file mode 100644 index d66a2931a..000000000 --- a/module/web/static/js/utils/remaining.js +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Javascript Countdown - * Copyright (c) 2009 Markus Hedlund - * Version 1.1 - * Licensed under MIT license - * http://www.opensource.org/licenses/mit-license.php - * http://labs.mimmin.com/countdown - */ -define([], function() { - var remaining = { - /** - * Get the difference of the passed date, and now. The different formats of the taget parameter are: - * January 12, 2009 15:14:00 (Month dd, yyyy hh:mm:ss) - * January 12, 2009 (Month dd, yyyy) - * 09,00,12,15,14,00 (yy,mm,dd,hh,mm,ss) Months range from 0-11, not 1-12. - * 09,00,12 (yy,mm,dd) Months range from 0-11, not 1-12. - * 500 (milliseconds) - * 2009-01-12 15:14:00 (yyyy-mm-dd hh-mm-ss) - * 2009-01-12 15:14 (yyyy-mm-dd hh-mm) - * @param target Target date. Can be either a date object or a string (formated like '24 December, 2010 15:00:00') - * @return Difference in seconds - */ - getSeconds: function(target) { - var today = new Date(); - - if (typeof(target) == 'object') { - var targetDate = target; - } else { - var matches = target.match(/(\d{4})-(\d{2})-(\d{2}) (\d{2}):(\d{2})(:(\d{2}))?/); // YYYY-MM-DD HH-MM-SS - if (matches != null) { - matches[7] = typeof(matches[7]) == 'undefined' ? '00' : matches[7]; - var targetDate = new Date(matches[1], matches[2] - 1, matches[3], matches[4], matches[5], matches[7]); - } else { - var targetDate = new Date(target); - } - } - - return Math.floor((targetDate.getTime() - today.getTime()) / 1000); - }, - - /** - * @param seconds Difference in seconds - * @param i18n A language object (see code) - * @param onlyLargestUnit Return only the largest unit (see documentation) - * @param hideEmpty Hide empty units (see documentation) - * @return String formated something like '1 week, 1 hours, 1 second' - */ - getString: function(seconds, i18n, onlyLargestUnit, hideEmpty) { - if (seconds < 1) { - return ''; - } - - if (typeof(hideEmpty) == 'undefined' || hideEmpty == null) { - hideEmpty = true; - } - if (typeof(onlyLargestUnit) == 'undefined' || onlyLargestUnit == null) { - onlyLargestUnit = false; - } - if (typeof(i18n) == 'undefined' || i18n == null) { - i18n = { - weeks: ['week', 'weeks'], - days: ['day', 'days'], - hours: ['hour', 'hours'], - minutes: ['minute', 'minutes'], - seconds: ['second', 'seconds'] - }; - } - - var units = { - weeks: 7 * 24 * 60 * 60, - days: 24 * 60 * 60, - hours: 60 * 60, - minutes: 60, - seconds: 1 - }; - - var returnArray = []; - var value; - for (unit in units) { - value = units[unit]; - if (seconds / value >= 1 || unit == 'seconds' || !hideEmpty) { - secondsConverted = Math.floor(seconds / value); - var i18nUnit = i18n[unit][secondsConverted == 1 ? 0 : 1]; - returnArray.push(secondsConverted + ' ' + i18nUnit); - seconds -= secondsConverted * value; - - if (onlyLargestUnit) { - break; - } - } - } - ; - - return returnArray.join(', '); - }, - - /** - * @param seconds Difference in seconds - * @return String formated something like '169:00:01' - */ - getStringDigital: function(seconds) { - if (seconds < 1) { - return ''; - } - - remainingTime = remaining.getArray(seconds); - - for (index in remainingTime) { - remainingTime[index] = remaining.padNumber(remainingTime[index]); - } - ; - - return remainingTime.join(':'); - }, - - /** - * @param seconds Difference in seconds - * @return Array with hours, minutes and seconds - */ - getArray: function(seconds) { - if (seconds < 1) { - return []; - } - - var units = [60 * 60, 60, 1]; - - var returnArray = []; - var value; - for (index in units) { - value = units[index]; - secondsConverted = Math.floor(seconds / value); - returnArray.push(secondsConverted); - seconds -= secondsConverted * value; - } - ; - - return returnArray; - }, - - /** - * @param number An integer - * @return Integer padded with a 0 if necessary - */ - padNumber: function(number) { - return (number >= 0 && number < 10) ? '0' + number : number; - } - }; - return remaining; -});
\ No newline at end of file |