From e9cf4e9aff00ac64afe024f95ed701d9516f6bf4 Mon Sep 17 00:00:00 2001 From: kbparagua Date: Tue, 1 Mar 2016 19:07:36 +0800 Subject: [PATCH] Remove jQuery dependency --- test_app/Gemfile | 3 ++- test_app/app/assets/javascripts/application.js | 3 +++ .../javascripts/paloma/controller_factory.js | 5 +---- vendor/assets/javascripts/paloma/init.js | 15 +++++---------- vendor/assets/javascripts/paloma/paloma.js | 12 ++++++------ 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/test_app/Gemfile b/test_app/Gemfile index 03ecbee..1346e54 100644 --- a/test_app/Gemfile +++ b/test_app/Gemfile @@ -2,4 +2,5 @@ source 'https://rubygems.org' gem 'selenium-webdriver' gem 'jquery-turbolinks' -gemspec :path => '../' \ No newline at end of file +gem 'test-unit' +gemspec :path => '../' diff --git a/test_app/app/assets/javascripts/application.js b/test_app/app/assets/javascripts/application.js index f6a7d06..208e6dc 100644 --- a/test_app/app/assets/javascripts/application.js +++ b/test_app/app/assets/javascripts/application.js @@ -56,6 +56,9 @@ NotFoos.prototype.otherAction = function(){}; $(document).ready(function(){ + + Paloma.engine.start(); + $('#js-ajax-link').on('click', function(e){ e.preventDefault(); diff --git a/vendor/assets/javascripts/paloma/controller_factory.js b/vendor/assets/javascripts/paloma/controller_factory.js index 23c34b0..8e78602 100644 --- a/vendor/assets/javascripts/paloma/controller_factory.js +++ b/vendor/assets/javascripts/paloma/controller_factory.js @@ -40,9 +40,6 @@ var createConstructor = function(){ var constructor = function(params){ this.params = params; } - $.extend(constructor, Paloma.Controller); - $.extend(constructor.prototype, Paloma.Controller.prototype); - return constructor; }; @@ -52,4 +49,4 @@ Paloma.ControllerFactory = ControllerFactory; -})(window.Paloma); \ No newline at end of file +})(window.Paloma); diff --git a/vendor/assets/javascripts/paloma/init.js b/vendor/assets/javascripts/paloma/init.js index 83dae06..f964077 100644 --- a/vendor/assets/javascripts/paloma/init.js +++ b/vendor/assets/javascripts/paloma/init.js @@ -18,14 +18,9 @@ else { }; } -$(document).ready(function(){ - // Do not continue if Paloma not found. - if (window['Paloma'] === undefined) { - if (window['console'] !== undefined) { - console.warn("Paloma not found. Require it in your application.js."); - } - return true; - } - Paloma.engine.start(); -}); \ No newline at end of file +if ( !window['Paloma'] ){ + if (window['console'] !== undefined){ + console.warn("Paloma not found. Require it in your application.js."); + } +} diff --git a/vendor/assets/javascripts/paloma/paloma.js b/vendor/assets/javascripts/paloma/paloma.js index 0bbb42e..c329c61 100644 --- a/vendor/assets/javascripts/paloma/paloma.js +++ b/vendor/assets/javascripts/paloma/paloma.js @@ -16,15 +16,15 @@ Paloma.engine = new Paloma.Engine({factory: Paloma._controllerFactory}); - Paloma.executeHook = function(){ - var $hook = $('.js-paloma-hook:first script:first'); + var hook = document.getElementsByClassName('js-paloma-hook')[0]; + if (!hook) return; - if ($hook.length == 0){ return; } + var script = hook.getElementsByTagName('script')[0]; + if (!script) return; - var hook = $hook.html(); - eval(hook); + eval(script.innerHTML); }; -})(window.Paloma); \ No newline at end of file +})(window.Paloma);