From b499f2a1daaaaacaebc7511653a42774e6e93675 Mon Sep 17 00:00:00 2001 From: Sergey Romanenko Date: Mon, 14 Jan 2013 16:37:40 +0200 Subject: [PATCH 1/3] Update plugins/box/snippets/js/snippets.js --- plugins/box/snippets/js/snippets.js | 58 +++++++++++++++++++++++------ 1 file changed, 46 insertions(+), 12 deletions(-) diff --git a/plugins/box/snippets/js/snippets.js b/plugins/box/snippets/js/snippets.js index 6cdf9d35..4c730c59 100644 --- a/plugins/box/snippets/js/snippets.js +++ b/plugins/box/snippets/js/snippets.js @@ -1,18 +1,52 @@ -if (typeof $.monstra == 'undefined') $.monstra = {}; +var Snippents = Snippents || (function($) { -$.monstra.snippets = { + var Events = {}, // Event-based Actions + App = {}, // Global Logic and Initializer + Public = {}; // Public Functions - init: function() { }, + Events = { + endpoints: { + viewEmbedCode: function(){ + var name = $(this).attr("data-value"); + $('#shortcode').html('{snippet get="'+name+'"}'); + $('#phpcode').html('<?php echo Snippet::get("'+name+'"); ?>'); + $('#embedCodes').modal(); + } + }, + bindEvents: function(){ + $('[data-event]').each(function(){ + var $this = $(this), + method = $this.attr('data-method') || 'click', + name = $this.attr('data-event'), + bound = $this.attr('data-bound')=='true'; - showEmbedCodes: function(name) { - $('#shortcode').html('{snippet get="'+name+'"}'); - $('#phpcode').html('<?php echo Snippet::get("'+name+'"); ?>'); - $('#embedCodes').modal(); - } + if(typeof Events.endpoints[name] != 'undefined'){ + if(!bound){ + $this.attr('data-bound', 'true'); + $this.on(method, Events.endpoints[name]); + } + } + }); + }, + init: function(){ + Events.bindEvents(); + } + }; + + App = { + logic: {}, + init: function() { + Utils.settings.init(); + Events.init(); + } + }; + + Public = { + init: App.init + }; -}; + return Public; +})(window.jQuery); -$(document).ready(function(){ - $.monstra.snippets.init(); -}); \ No newline at end of file +jQuery(document).ready(Snippents.init); From 3f420f24065893191b7d9aa682da02f09df24e11 Mon Sep 17 00:00:00 2001 From: Sergey Romanenko Date: Mon, 14 Jan 2013 16:38:36 +0200 Subject: [PATCH 2/3] Update plugins/box/snippets/views/backend/index.view.php --- plugins/box/snippets/views/backend/index.view.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/box/snippets/views/backend/index.view.php b/plugins/box/snippets/views/backend/index.view.php index e8f7b936..24b7d5c4 100755 --- a/plugins/box/snippets/views/backend/index.view.php +++ b/plugins/box/snippets/views/backend/index.view.php @@ -30,7 +30,7 @@ 'btn btn-actions btn-small')); ?> Date: Wed, 16 Jan 2013 09:20:47 +0200 Subject: [PATCH 3/3] Update plugins/box/snippets/js/snippets.js --- plugins/box/snippets/js/snippets.js | 1 - 1 file changed, 1 deletion(-) diff --git a/plugins/box/snippets/js/snippets.js b/plugins/box/snippets/js/snippets.js index 4c730c59..0dea82f3 100644 --- a/plugins/box/snippets/js/snippets.js +++ b/plugins/box/snippets/js/snippets.js @@ -36,7 +36,6 @@ var Snippents = Snippents || (function($) { App = { logic: {}, init: function() { - Utils.settings.init(); Events.init(); } };