mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-01 10:50:37 +02:00
Update plugins/box/snippets/js/snippets.js
This commit is contained in:
@@ -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: {
|
||||||
showEmbedCodes: function(name) {
|
viewEmbedCode: function(){
|
||||||
|
var name = $(this).attr("data-value");
|
||||||
$('#shortcode').html('{snippet get="'+name+'"}');
|
$('#shortcode').html('{snippet get="'+name+'"}');
|
||||||
$('#phpcode').html('<?php echo Snippet::get("'+name+'"); ?>');
|
$('#phpcode').html('<?php echo Snippet::get("'+name+'"); ?>');
|
||||||
$('#embedCodes').modal();
|
$('#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';
|
||||||
|
|
||||||
};
|
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();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function(){
|
Public = {
|
||||||
$.monstra.snippets.init();
|
init: App.init
|
||||||
});
|
};
|
||||||
|
|
||||||
|
return Public;
|
||||||
|
|
||||||
|
})(window.jQuery);
|
||||||
|
|
||||||
|
jQuery(document).ready(Snippents.init);
|
||||||
|
Reference in New Issue
Block a user