From b46dd9bae4e61a6e2b3f3d7cb7edef661e5994af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jannis=20Mo=C3=9Fhammer?= Date: Mon, 17 Jun 2013 12:40:10 +0200 Subject: [PATCH] Remove behaviour files These files are not required anymore as they are now renamed to 'modules' and may affect testting refs #3753 refs #4303 --- public/js/icinga/behaviour.js | 86 ---------------- public/js/icinga/behaviour/actionTable.js | 118 ---------------------- public/js/icinga/behaviour/mainDetail.js | 94 ----------------- 3 files changed, 298 deletions(-) delete mode 100644 public/js/icinga/behaviour.js delete mode 100644 public/js/icinga/behaviour/actionTable.js delete mode 100755 public/js/icinga/behaviour/mainDetail.js diff --git a/public/js/icinga/behaviour.js b/public/js/icinga/behaviour.js deleted file mode 100644 index 6a432d00f..000000000 --- a/public/js/icinga/behaviour.js +++ /dev/null @@ -1,86 +0,0 @@ -/*global Icinga:false, $: false, document: false, define:false require:false base_url:false console:false */ - - -/** - This prototype encapsulates the behaviours registered in the behaviour folder - **/ -(function() { - "use strict"; - - var loaded = {}; - - define(['logging'],function(log) { - - var registerBehaviourFunctions = function(behaviour) { - var enableFn = behaviour.enable, disableFn = behaviour.disable; - - behaviour.enable = (function(root) { - root = root || document; - for (var jqMatcher in this.eventHandler) { - for (var event in this.eventHandler[jqMatcher]) { - log.debug("Registered behaviour: ","'"+event+"'", jqMatcher); - $(root).on(event,jqMatcher,this.eventHandler[jqMatcher][event]); - } - } - if(enableFn) { - enableFn.apply(this,arguments); - } - }).bind(behaviour); - - behaviour.disable = (function(root) { - for (var jqMatcher in this.eventHandler) { - for (var event in this.eventHandler[jqMatcher]) { - log.debug("Unregistered behaviour: ","'"+event+"'", jqMatcher); - $(root).off(event,jqMatcher,this.eventHandler[jqMatcher][event]); - } - } - if (disableFn) { - disableFn.apply(this,arguments); - } - }).bind(behaviour); - - - }; - - var CallInterface = function() { - - /** - * Loads a behaviour and calls successCallback with the behaviour as the parameter on success, otherwise - * the errorCallback with the errorstring as the first parameter - * - * @param name - * @param errorCallback - * @param successCallback - */ - this.enableBehaviour = function(name,errorCallback,successCallback) { - require([name],function(behaviour) { - if (typeof behaviour.eventHandler === "object") { - registerBehaviourFunctions(behaviour); - } - if (typeof behaviour.enable === "function") { - behaviour.enable(); - } - loaded[name] = { - behaviour: behaviour, - active: true - }; - if (typeof successCallback === "function") { - successCallback(behaviour); - } - },function(err) { - errorCallback("Could not load behaviour "+name+" "+err,err); - }); - }; - - this.disableBehaviour = function(name) { - if(loaded[name] && loaded[name].active) { - loaded[name].disable(); - } - }; - - }; - - return new CallInterface(); - }); - -})(); \ No newline at end of file diff --git a/public/js/icinga/behaviour/actionTable.js b/public/js/icinga/behaviour/actionTable.js deleted file mode 100644 index e8e61952b..000000000 --- a/public/js/icinga/behaviour/actionTable.js +++ /dev/null @@ -1,118 +0,0 @@ -/*global Icinga:false, document: false, define:false require:false base_url:false console:false */ - -/** - * ActionTable behaviour as described in - * https://wiki.icinga.org/display/cranberry/Frontend+Components#FrontendComponents-ActionTable - * - * @TODO: Row selection - */ -define(['jquery','logging','icinga/util/async'],function($,log,async) { - "use strict"; - - var ActionTableBehaviour = function() { - var onTableHeaderClick; - - var TABLE_BASE_MATCHER = '.icinga-container table.action'; - var linksInActionTable = TABLE_BASE_MATCHER+" tbody tr > a"; - var actionTableRow = TABLE_BASE_MATCHER+" tbody tr"; - var headerRow = TABLE_BASE_MATCHER+" > th a"; - var searchField = ".icinga-container .actiontable.controls input[type=search]"; - - - onTableHeaderClick = function (ev) { - var target = ev.currentTarget, - href = $(target).attr('href'), - destination; - if ($(target).parents('.layout-main-detail').length) { - if ($(target).parents("#icinga-main").length) { - destination = 'icinga-main'; - } - else { - destination = 'icinga-detail'; - } - - } else { - destination = 'icinga-main'; - } - async.loadToTarget(destination, href); - ev.preventDefault(); - ev.stopImmediatePropagation(); - return false; - }; - - var onLinkTagClick = function(ev) { - - var target = ev.currentTarget, - href = $(target).attr('href'), - destination; - if ($(target).parents('.layout-main-detail').length) { - destination = 'icinga-detail'; - } else { - destination = 'icinga-main'; - } - async.loadToTarget(destination,href); - ev.preventDefault(); - ev.stopImmediatePropagation(); - return false; - - }; - - var onTableRowClick = function(ev) { - ev.stopImmediatePropagation(); - - var target = $(ev.currentTarget), - href = target.attr('href'), - destination; - $('tr.active',target.parent('tbody').first()).removeClass("active"); - target.addClass('active'); - - // When the tr has a href, act like it is a link - if(href) { - ev.currentTarget = target.first(); - return onLinkTagClick(ev); - } - // Try to find a designated row action - var links = $("a.row-action",target); - if(links.length) { - ev.currentTarget = links.first(); - return onLinkTagClick(ev); - } - - // otherwise use the first anchor tag - links = $("a",target); - if(links.length) { - ev.currentTarget = links.first(); - return onLinkTagClick(ev); - } - - log.debug("No target for this table row found"); - return false; - }; - - var onSearchInput = function(ev) { - ev.stopImmediatePropagation(); - var txt = $(this).val(); - }; - - this.eventHandler = {}; - this.eventHandler[linksInActionTable] = { - 'click' : onLinkTagClick - }; - this.eventHandler[actionTableRow] = { - 'click' : onTableRowClick - }; - this.eventHandler[headerRow] = { - 'click' : onTableHeaderClick - }; - this.eventHandler[searchField] = { - 'keyup' : onSearchInput - }; - - this.enable = function() { - - }; - }; - - return new ActionTableBehaviour(); - -}); \ No newline at end of file diff --git a/public/js/icinga/behaviour/mainDetail.js b/public/js/icinga/behaviour/mainDetail.js deleted file mode 100755 index 9a207c933..000000000 --- a/public/js/icinga/behaviour/mainDetail.js +++ /dev/null @@ -1,94 +0,0 @@ -/*global Icinga:false, document: false, define:false require:false base_url:false console:false */ - -/** - * Main-Detail layout behaviour as described in - * https://wiki.icinga.org/display/cranberry/Frontend+Components#FrontendComponents-Behaviour - * - */ -define(['jquery','logging','icinga/util/async'],function($,log,async) { - "use strict"; - - var MainDetailBehaviour = function() { - - var onOuterLinkClick = function(ev) { - var a = $(ev.currentTarget), - target = a.attr("target"), - href = a.attr("href"); - ev.stopImmediatePropagation(); - collapseDetailView(); - async.loadToTarget("icinga-main",href); - return false; - }; - - var onLinkTagClick = function(ev) { - - var a = $(ev.currentTarget), - target = a.attr("target"), - href = a.attr("href"); - - // check for protocol:// - if(/^[A-Z]{2,10}\:\/\//i.test(href)) { - window.open(href); - ev.stopImmediatePropagation(); - return false; - } - - // check for link in table header - if(a.parents('th').length > 0) { - ev.stopImmediatePropagation(); - return false; - } - - if(typeof target === "undefined") { - if(a.parents("#icinga-detail").length) { - async.loadToTarget("icinga-detail",href); - } else { - async.loadToTarget("icinga-main",href); - } - } else { - switch(target) { - case "main": - async.loadToTarget("icinga-main",href); - collapseDetailView(); - break; - case "detail": - async.loadToTarget("icinga-detail",href); - break; - case "popup": - async.loadToTarget(null,href); - break; - default: - return true; - } - } - ev.stopImmediatePropagation(); - return false; - }; - - var expandDetailView = function() { - $("#icinga-detail").parents(".collapsed").removeClass('collapsed'); - }; - - var collapseDetailView = function(elementInDetailView) { - $("#icinga-detail").parents(".layout-main-detail").addClass('collapsed'); - }; - - this.expandDetailView = expandDetailView; - this.collapseDetailView = collapseDetailView; - - this.eventHandler = { - '.layout-main-detail * a' : { - 'click' : onLinkTagClick - }, - 'a' : { - 'click' : onOuterLinkClick - }, - '.layout-main-detail .icinga-container#icinga-detail' : { - 'focus' : expandDetailView - } - }; - }; - - return new MainDetailBehaviour(); -}); -