From 1976206e2cd552c59ad688881a4f732ca86698d1 Mon Sep 17 00:00:00 2001 From: brantje Date: Fri, 7 Oct 2016 23:50:16 +0200 Subject: [PATCH] Revert "Replace $ with jQuery" This reverts commit 62f1fffebdcafc3aa0fbf78dbe4f07878638276b. --- Gruntfile.js | 1 + js/app/app.js | 66 +++++++++++++++++++++++++-------------------------- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index 12149194..fe4ec67a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -42,6 +42,7 @@ module.exports = function (grunt) { "forge": true, "sjcl": true, "jQuery": true, + "$": true, "_": true, "oc_requesttoken": true } diff --git a/js/app/app.js b/js/app/app.js index ba534065..03bad227 100644 --- a/js/app/app.js +++ b/js/app/app.js @@ -26,8 +26,8 @@ 'ngTagsInput', 'angularjs-datetime-picker' ]) - .config(function (jQueryrouteProvider) { - jQueryrouteProvider + .config(function ($routeProvider) { + $routeProvider .when('/', { templateUrl: 'views/vaults.html', controller: 'VaultCtrl' @@ -57,8 +57,8 @@ .otherwise({ redirectTo: '/' }); - }).config(['jQueryhttpProvider', function (jQueryhttpProvider) { - jQueryhttpProvider.defaults.headers.common.requesttoken = oc_requesttoken; + }).config(['$httpProvider', function ($httpProvider) { + $httpProvider.defaults.headers.common.requesttoken = oc_requesttoken; }]).config(function (localStorageServiceProvider) { localStorageServiceProvider .setNotify(true, true); @@ -79,39 +79,39 @@ return foundItem; }; jQuery(document).on('click', '.undoDelete', function () { - var credential = findItemByID(jQuery(this).attr('data-item-id')); + var credential = findItemByID($(this).attr('data-item-id')); angular.element('#app-content-wrapper').scope().recoverCredential(credential); - //Outside anglular we need jQueryapply - angular.element('#app-content-wrapper').scope().jQueryapply(); + //Outside anglular we need $apply + angular.element('#app-content-wrapper').scope().$apply(); }); jQuery(document).on('click', '.undoRestore', function () { - var credential = findItemByID(jQuery(this).attr('data-item-id')); + var credential = findItemByID($(this).attr('data-item-id')); angular.element('#app-content-wrapper').scope().deleteCredential(credential); - //Outside anglular we need jQueryapply - angular.element('#app-content-wrapper').scope().jQueryapply(); + //Outside anglular we need $apply + angular.element('#app-content-wrapper').scope().$apply(); }); var adjustControlsWidth = function (r) { - if (jQuery('#controls').length) { + if ($('#controls').length) { var controlsWidth; // if there is a scrollbar … - if (jQuery('#app-content').get(0)) { - if (jQuery('#app-content').get(0).scrollHeight > jQuery('#app-content').height()) { - if (jQuery(window).width() > 768) { - controlsWidth = jQuery('#content').width() - jQuery('#app-navigation').width() - OC.Util.getScrollBarWidth(); - if (!jQuery('#app-sidebar').hasClass('hidden') && !jQuery('#app-sidebar').hasClass('disappear')) { - controlsWidth -= jQuery('#app-sidebar').width(); + if ($('#app-content').get(0)) { + if ($('#app-content').get(0).scrollHeight > $('#app-content').height()) { + if ($(window).width() > 768) { + controlsWidth = $('#content').width() - $('#app-navigation').width() - OC.Util.getScrollBarWidth(); + if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) { + controlsWidth -= $('#app-sidebar').width(); } } else { - controlsWidth = jQuery('#content').width() - OC.Util.getScrollBarWidth(); + controlsWidth = $('#content').width() - OC.Util.getScrollBarWidth(); } } else { // if there is none - if (jQuery(window).width() > 768) { - controlsWidth = jQuery('#content').width() - jQuery('#app-navigation').width(); - if (!jQuery('#app-sidebar').hasClass('hidden') && !jQuery('#app-sidebar').hasClass('disappear')) { - //controlsWidth -= jQuery('#app-sidebar').width(); + if ($(window).width() > 768) { + controlsWidth = $('#content').width() - $('#app-navigation').width(); + if (!$('#app-sidebar').hasClass('hidden') && !$('#app-sidebar').hasClass('disappear')) { + //controlsWidth -= $('#app-sidebar').width(); } } else { - controlsWidth = jQuery('#content').width(); + controlsWidth = $('#content').width(); } } } @@ -121,25 +121,25 @@ } else { magic = 85; } - jQuery('#controls').css('width', controlsWidth + magic); - jQuery('#controls').css('min-width', controlsWidth + magic); + $('#controls').css('width', controlsWidth + magic); + $('#controls').css('min-width', controlsWidth + magic); } }; - jQuery(window).resize(_.debounce(adjustControlsWidth, 400)); + $(window).resize(_.debounce(adjustControlsWidth, 400)); setTimeout(function () { adjustControlsWidth(true); }, 200); //@Fack this - jQuery(document).on('click', '#app-navigation-toggle', function () { + $(document).on('click', '#app-navigation-toggle', function () { setTimeout(function () { - if (jQuery('#app-content').css('transform').toString().indexOf('matrix') >= 0) { - jQuery('#passman-controls').css('width', 'calc( 100% - 245px)'); - jQuery('#passman-controls').css('top', '0'); + if ($('#app-content').css('transform').toString().indexOf('matrix') >= 0) { + $('#passman-controls').css('width', 'calc( 100% - 245px)'); + $('#passman-controls').css('top', '0'); } else { - jQuery('#passman-controls').css('left', 0); - jQuery('#passman-controls').css('top', '44px'); - jQuery('#passman-controls').css('width', '100%'); + $('#passman-controls').css('left', 0); + $('#passman-controls').css('top', '44px'); + $('#passman-controls').css('width', '100%'); } }, 350); });