From c8b276ba38cc5685b9ecf474984069204026b001 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Wed, 31 Oct 2012 09:29:43 +0100 Subject: [PATCH] Restructure of lib directory. --- app/assets/javascripts/app/lib/ajax.js.coffee | 66 - app/assets/javascripts/app/lib/auth.js.coffee | 108 - app/assets/javascripts/app/lib/ba-linkify.js | 179 - .../javascripts/app/lib/bootstrap-dropdown.js | 100 - .../javascripts/app/lib/bootstrap-modal.js | 218 - .../javascripts/app/lib/bootstrap-popover.js | 98 - .../javascripts/app/lib/bootstrap-tab.js | 135 - .../javascripts/app/lib/bootstrap-tooltip.js | 275 - .../app/lib/bootstrap-transition.js | 61 - .../javascripts/app/lib/clipboard.js.coffee | 181 - .../javascripts/app/lib/collection.js.coffee | 363 - .../javascripts/app/lib/event.js.coffee | 90 - .../javascripts/app/lib/fileuploader.js | 1251 --- app/assets/javascripts/app/lib/i18n.js.coffee | 169 - .../app/lib/interface_handle.js.coffee | 76 - .../javascripts/app/lib/jquery-1.7.2.min.js | 4 - .../javascripts/app/lib/jquery-1.8.1.js | 9301 ----------------- .../javascripts/app/lib/jquery-1.8.1.min.js | 2 - .../app/lib/jquery.elastic.source.js | 162 - app/assets/javascripts/app/lib/jquery.noty.js | 220 - .../javascripts/app/lib/jquery.tagsinput.js | 353 - .../javascripts/app/lib/store.js.coffee | 61 - .../javascripts/app/lib/underscore-1.3.3.js | 1059 -- app/assets/javascripts/app/lib/waypoints.js | 674 -- .../javascripts/app/lib/websocket.js.coffee | 163 - 25 files changed, 15369 deletions(-) delete mode 100644 app/assets/javascripts/app/lib/ajax.js.coffee delete mode 100644 app/assets/javascripts/app/lib/auth.js.coffee delete mode 100644 app/assets/javascripts/app/lib/ba-linkify.js delete mode 100644 app/assets/javascripts/app/lib/bootstrap-dropdown.js delete mode 100644 app/assets/javascripts/app/lib/bootstrap-modal.js delete mode 100644 app/assets/javascripts/app/lib/bootstrap-popover.js delete mode 100644 app/assets/javascripts/app/lib/bootstrap-tab.js delete mode 100644 app/assets/javascripts/app/lib/bootstrap-tooltip.js delete mode 100644 app/assets/javascripts/app/lib/bootstrap-transition.js delete mode 100644 app/assets/javascripts/app/lib/clipboard.js.coffee delete mode 100644 app/assets/javascripts/app/lib/collection.js.coffee delete mode 100644 app/assets/javascripts/app/lib/event.js.coffee delete mode 100644 app/assets/javascripts/app/lib/fileuploader.js delete mode 100644 app/assets/javascripts/app/lib/i18n.js.coffee delete mode 100644 app/assets/javascripts/app/lib/interface_handle.js.coffee delete mode 100644 app/assets/javascripts/app/lib/jquery-1.7.2.min.js delete mode 100644 app/assets/javascripts/app/lib/jquery-1.8.1.js delete mode 100644 app/assets/javascripts/app/lib/jquery-1.8.1.min.js delete mode 100644 app/assets/javascripts/app/lib/jquery.elastic.source.js delete mode 100644 app/assets/javascripts/app/lib/jquery.noty.js delete mode 100644 app/assets/javascripts/app/lib/jquery.tagsinput.js delete mode 100644 app/assets/javascripts/app/lib/store.js.coffee delete mode 100644 app/assets/javascripts/app/lib/underscore-1.3.3.js delete mode 100644 app/assets/javascripts/app/lib/waypoints.js delete mode 100644 app/assets/javascripts/app/lib/websocket.js.coffee diff --git a/app/assets/javascripts/app/lib/ajax.js.coffee b/app/assets/javascripts/app/lib/ajax.js.coffee deleted file mode 100644 index 531d2a371..000000000 --- a/app/assets/javascripts/app/lib/ajax.js.coffee +++ /dev/null @@ -1,66 +0,0 @@ -$ = jQuery.sub() - -class App.Com - _instance = undefined # Must be declared here to force the closure on the class - @ajax: (args) -> # Must be a static method - if _instance == undefined - _instance ?= new _Singleton - - _instance.ajax(args) - _instance - -# The actual Singleton class -class _Singleton - defaults: - contentType: 'application/json' - dataType: 'json' - processData: false - headers: {'X-Requested-With': 'XMLHttpRequest'} - cache: false - async: true - - queue_list: {} - count: 0 - - constructor: (@args) -> - - # bindings - $('body').bind( 'ajaxSend', => - @_show_spinner() - ).bind( 'ajaxComplete', => - @_hide_spinner() - ) - - # show error messages - $('body').bind( 'ajaxError', ( e, jqxhr, settings, exception ) -> - status = jqxhr.status - detail = jqxhr.responseText - if !status && !detail - detail = 'General communication error, maybe internet is not available!' - new App.ErrorModal( - message: 'StatusCode: ' + status - detail: detail - close: true - ) - ) - - ajax: (params, defaults) -> - data = $.extend({}, @defaults, defaults, params) - if params['id'] - if @queue_list[ params['id'] ] - @queue_list[ params['id'] ].abort() - @queue_list[ params['id'] ] = $.ajax( data ) - else - $.ajax( data ) - -# console.log('AJAX', params['url'] ) - - _show_spinner: => - @count++ - $('.spinner').show() - - _hide_spinner: => - @count-- - if @count == 0 - $('.spinner').hide() - diff --git a/app/assets/javascripts/app/lib/auth.js.coffee b/app/assets/javascripts/app/lib/auth.js.coffee deleted file mode 100644 index 5beec7d18..000000000 --- a/app/assets/javascripts/app/lib/auth.js.coffee +++ /dev/null @@ -1,108 +0,0 @@ -$ = jQuery.sub() - -class App.Auth - - @login: (params) -> - console.log 'login(...)', params - App.Com.ajax( - id: 'login', - type: 'POST', - url: '/signin', - data: JSON.stringify(params.data), - success: (data, status, xhr) => - - # clear store - App.Store.clear('all') - - # execute callback - params.success(data, status, xhr) - - error: (xhr, statusText, error) => - params.error(xhr, statusText, error) - ) - - @loginCheck: -> - console.log 'loginCheck(...)' - App.Com.ajax( - id: 'login_check', - async: false, - type: 'GET', - url: '/signshow', - success: (data, status, xhr) => - console.log 'logincheck:success', data - - # if session is not valid - if data.error - - # update config - for key, value of data.config - window.Config[key] = value - - # empty session - window.Session = {} - - # update websocked auth info - App.WebSocket.auth() - - # rebuild navbar with new navbar items - App.Event.trigger 'navrebuild' - - return false; - - # set avatar - if !data.session.image - data.session.image = 'http://placehold.it/48x48' - - # update config - for key, value of data.config - window.Config[key] = value - - # store user data - for key, value of data.session - window.Session[key] = value - - # update websocked auth info - App.WebSocket.auth() - - # refresh/load default collections - for key, value of data.default_collections - App.Collection.reset( type: key, data: value ) - - # rebuild navbar with new navbar items - App.Event.trigger 'navrebuild', data.session - - # rebuild navbar with updated ticket count of overviews - App.Event.trigger 'navupdate_remote' - - error: (xhr, statusText, error) => - console.log 'loginCheck:error'#, error, statusText, xhr.statusCode - - # empty session - window.Session = {} - - # clear store - App.Store.clear('all') - - # update websocked auth info - App.WebSocket.auth() - ) - - @logout: -> - console.log 'logout(...)' - App.Com.ajax( - id: 'logout', - type: 'DELETE', - url: '/signout', - success: => - - # update websocked auth info - App.WebSocket.auth() - - # clear store - App.Store.clear('all') - - error: (xhr, statusText, error) => - - # update websocked auth info - App.WebSocket.auth() - ) \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/ba-linkify.js b/app/assets/javascripts/app/lib/ba-linkify.js deleted file mode 100644 index 293dd67af..000000000 --- a/app/assets/javascripts/app/lib/ba-linkify.js +++ /dev/null @@ -1,179 +0,0 @@ -/*! - * linkify - v0.3 - 6/27/2009 - * http://benalman.com/code/test/js-linkify/ - * - * Copyright (c) 2009 "Cowboy" Ben Alman - * Licensed under the MIT license - * http://benalman.com/about/license/ - * - * Some regexps adapted from http://userscripts.org/scripts/review/7122 - */ - -// Turn text into linkified html. -// -// var html = linkify( text, options ); -// -// options: -// -// callback (Function) - default: undefined - if defined, this will be called -// for each link- or non-link-chunk with two arguments, text and href. If the -// chunk is non-link, href will be omitted. -// -// punct_regexp (RegExp | Boolean) - a RegExp that can be used to trim trailing -// punctuation from links, instead of the default. -// -// This is a work in progress, please let me know if (and how) it fails! - -window.linkify = (function(){ - var - SCHEME = "[a-z\\d.-]+://", - IPV4 = "(?:(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])\\.){3}(?:[0-9]|[1-9]\\d|1\\d{2}|2[0-4]\\d|25[0-5])", - HOSTNAME = "(?:(?:[^\\s!@#$%^&*()_=+[\\]{}\\\\|;:'\",.<>/?]+)\\.)+", - TLD = "(?:ac|ad|aero|ae|af|ag|ai|al|am|an|ao|aq|arpa|ar|asia|as|at|au|aw|ax|az|ba|bb|bd|be|bf|bg|bh|biz|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|cat|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|coop|com|co|cr|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|info|int|in|io|iq|ir|is|it|je|jm|jobs|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mil|mk|ml|mm|mn|mobi|mo|mp|mq|mr|ms|mt|museum|mu|mv|mw|mx|my|mz|name|na|nc|net|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pro|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tel|tf|tg|th|tj|tk|tl|tm|tn|to|tp|travel|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|xn--0zwm56d|xn--11b5bs3a9aj6g|xn--80akhbyknj4f|xn--9t4b11yi5a|xn--deba0ad|xn--g6w251d|xn--hgbk6aj7f53bba|xn--hlcj6aya9esc7a|xn--jxalpdlp|xn--kgbechtv|xn--zckzah|ye|yt|yu|za|zm|zw)", - HOST_OR_IP = "(?:" + HOSTNAME + TLD + "|" + IPV4 + ")", - PATH = "(?:[;/][^#?<>\\s]*)?", - QUERY_FRAG = "(?:\\?[^#<>\\s]*)?(?:#[^<>\\s]*)?", - URI1 = "\\b" + SCHEME + "[^<>\\s]+", - URI2 = "\\b" + HOST_OR_IP + PATH + QUERY_FRAG + "(?!\\w)", - - MAILTO = "mailto:", - EMAIL = "(?:" + MAILTO + ")?[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@" + HOST_OR_IP + QUERY_FRAG + "(?!\\w)", - - URI_RE = new RegExp( "(?:" + URI1 + "|" + URI2 + "|" + EMAIL + ")", "ig" ), - SCHEME_RE = new RegExp( "^" + SCHEME, "i" ), - - quotes = { - "'": "`", - '>': '<', - ')': '(', - ']': '[', - '}': '{', - '»': '«', - '›': '‹' - }, - - default_options = { - callback: function( text, href ) { -// return href ? '' + text + '<\/a>' : text; - return href ? '' + text + '<\/a>' : text; - }, - punct_regexp: /(?:[!?.,:;'"]|(?:&|&)(?:lt|gt|quot|apos|raquo|laquo|rsaquo|lsaquo);)$/ - }; - - return function( txt, options ) { - options = options || {}; - - // me - txt = txt - .replace(/&/g, '&') - .replace(/"/g, '"') - .replace(/'/g, ''') - .replace(//g, '>'); - // me - // Temp variables. - var arr, - i, - link, - href, - - // Output HTML. - html = '', - - // Store text / link parts, in order, for re-combination. - parts = [], - - // Used for keeping track of indices in the text. - idx_prev, - idx_last, - idx, - link_last, - - // Used for trimming trailing punctuation and quotes from links. - matches_begin, - matches_end, - quote_begin, - quote_end; - - // Initialize options. - for ( i in default_options ) { - if ( options[ i ] === undefined ) { - options[ i ] = default_options[ i ]; - } - } - - // Find links. - while ( arr = URI_RE.exec( txt ) ) { - - link = arr[0]; - idx_last = URI_RE.lastIndex; - idx = idx_last - link.length; - - // Not a link if preceded by certain characters. - if ( /[\/:]/.test( txt.charAt( idx - 1 ) ) ) { - continue; - } - - // Trim trailing punctuation. - do { - // If no changes are made, we don't want to loop forever! - link_last = link; - - quote_end = link.substr( -1 ) - quote_begin = quotes[ quote_end ]; - - // Ending quote character? - if ( quote_begin ) { - matches_begin = link.match( new RegExp( '\\' + quote_begin + '(?!$)', 'g' ) ); - matches_end = link.match( new RegExp( '\\' + quote_end, 'g' ) ); - - // If quotes are unbalanced, remove trailing quote character. - if ( ( matches_begin ? matches_begin.length : 0 ) < ( matches_end ? matches_end.length : 0 ) ) { - link = link.substr( 0, link.length - 1 ); - idx_last--; - } - } - - // Ending non-quote punctuation character? - if ( options.punct_regexp ) { - link = link.replace( options.punct_regexp, function(a){ - idx_last -= a.length; - return ''; - }); - } - } while ( link.length && link !== link_last ); - - href = link; - - // Add appropriate protocol to naked links. - if ( !SCHEME_RE.test( href ) ) { - href = ( href.indexOf( '@' ) !== -1 ? ( !href.indexOf( MAILTO ) ? '' : MAILTO ) - : !href.indexOf( 'irc.' ) ? 'irc://' - : !href.indexOf( 'ftp.' ) ? 'ftp://' - : 'http://' ) - + href; - } - - // Push preceding non-link text onto the array. - if ( idx_prev != idx ) { - parts.push([ txt.slice( idx_prev, idx ) ]); - idx_prev = idx_last; - } - - // Push massaged link onto the array - parts.push([ link, href ]); - }; - - // Push remaining non-link text onto the array. - parts.push([ txt.substr( idx_prev ) ]); - - // Process the array items. - for ( i = 0; i < parts.length; i++ ) { - html += options.callback.apply( window, parts[i] ); - } - - // In case of catastrophic failure, return the original text; - return html || txt; - }; - -})(); \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/bootstrap-dropdown.js b/app/assets/javascripts/app/lib/bootstrap-dropdown.js deleted file mode 100644 index 454a9684b..000000000 --- a/app/assets/javascripts/app/lib/bootstrap-dropdown.js +++ /dev/null @@ -1,100 +0,0 @@ -/* ============================================================ - * bootstrap-dropdown.js v2.0.4 - * http://twitter.github.com/bootstrap/javascript.html#dropdowns - * ============================================================ - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============================================================ */ - - -!function ($) { - - "use strict"; // jshint ;_; - - - /* DROPDOWN CLASS DEFINITION - * ========================= */ - - var toggle = '[data-toggle="dropdown"]' - , Dropdown = function (element) { - var $el = $(element).on('click.dropdown.data-api', this.toggle) - $('html').on('click.dropdown.data-api', function () { - $el.parent().removeClass('open') - }) - } - - Dropdown.prototype = { - - constructor: Dropdown - - , toggle: function (e) { - var $this = $(this) - , $parent - , selector - , isActive - - if ($this.is('.disabled, :disabled')) return - - selector = $this.attr('data-target') - - if (!selector) { - selector = $this.attr('href') - selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7 - } - - $parent = $(selector) - $parent.length || ($parent = $this.parent()) - - isActive = $parent.hasClass('open') - - clearMenus() - - if (!isActive) $parent.toggleClass('open') - - return false - } - - } - - function clearMenus() { - $(toggle).parent().removeClass('open') - } - - - /* DROPDOWN PLUGIN DEFINITION - * ========================== */ - - $.fn.dropdown = function (option) { - return this.each(function () { - var $this = $(this) - , data = $this.data('dropdown') - if (!data) $this.data('dropdown', (data = new Dropdown(this))) - if (typeof option == 'string') data[option].call($this) - }) - } - - $.fn.dropdown.Constructor = Dropdown - - - /* APPLY TO STANDARD DROPDOWN ELEMENTS - * =================================== */ - - $(function () { - $('html').on('click.dropdown.data-api', clearMenus) - $('body') - .on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() }) - .on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle) - }) - -}(window.jQuery); \ No newline at end of file diff --git a/app/assets/javascripts/app/lib/bootstrap-modal.js b/app/assets/javascripts/app/lib/bootstrap-modal.js deleted file mode 100644 index 38fd0c846..000000000 --- a/app/assets/javascripts/app/lib/bootstrap-modal.js +++ /dev/null @@ -1,218 +0,0 @@ -/* ========================================================= - * bootstrap-modal.js v2.0.4 - * http://twitter.github.com/bootstrap/javascript.html#modals - * ========================================================= - * Copyright 2012 Twitter, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ========================================================= */ - - -!function ($) { - - "use strict"; // jshint ;_; - - - /* MODAL CLASS DEFINITION - * ====================== */ - - var Modal = function (content, options) { - this.options = options - this.$element = $(content) - .delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this)) - } - - Modal.prototype = { - - constructor: Modal - - , toggle: function () { - return this[!this.isShown ? 'show' : 'hide']() - } - - , show: function () { - var that = this - , e = $.Event('show') - - this.$element.trigger(e) - - if (this.isShown || e.isDefaultPrevented()) return - - $('body').addClass('modal-open') - - this.isShown = true - - escape.call(this) - backdrop.call(this, function () { - var transition = $.support.transition && that.$element.hasClass('fade') - - if (!that.$element.parent().length) { - that.$element.appendTo(document.body) //don't move modals dom position - } - - that.$element - .show() - - if (transition) { - that.$element[0].offsetWidth // force reflow - } - - that.$element.addClass('in') - - transition ? - that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) : - that.$element.trigger('shown') - - }) - } - - , hide: function (e) { - e && e.preventDefault() - - var that = this - - e = $.Event('hide') - - this.$element.trigger(e) - - if (!this.isShown || e.isDefaultPrevented()) return - - this.isShown = false - - $('body').removeClass('modal-open') - - escape.call(this) - - this.$element.removeClass('in') - - $.support.transition && this.$element.hasClass('fade') ? - hideWithTransition.call(this) : - hideModal.call(this) - } - - } - - - /* MODAL PRIVATE METHODS - * ===================== */ - - function hideWithTransition() { - var that = this - , timeout = setTimeout(function () { - that.$element.off($.support.transition.end) - hideModal.call(that) - }, 500) - - this.$element.one($.support.transition.end, function () { - clearTimeout(timeout) - hideModal.call(that) - }) - } - - function hideModal(that) { - this.$element - .hide() - .trigger('hidden') - - backdrop.call(this) - } - - function backdrop(callback) { - var that = this - , animate = this.$element.hasClass('fade') ? 'fade' : '' - - if (this.isShown && this.options.backdrop) { - var doAnimate = $.support.transition && animate - - this.$backdrop = $('