mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-06 21:26:58 +02:00
Compare commits
3 Commits
monstra-mu
...
sparky-js-
Author | SHA1 | Date | |
---|---|---|---|
|
4b4b78e554 | ||
|
3f420f2406 | ||
|
b499f2a1da |
@@ -1,18 +1,51 @@
|
||||
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() {
|
||||
Events.init();
|
||||
}
|
||||
};
|
||||
|
||||
Public = {
|
||||
init: App.init
|
||||
};
|
||||
|
||||
};
|
||||
return Public;
|
||||
|
||||
})(window.jQuery);
|
||||
|
||||
$(document).ready(function(){
|
||||
$.monstra.snippets.init();
|
||||
});
|
||||
jQuery(document).ready(Snippents.init);
|
||||
|
@@ -30,7 +30,7 @@
|
||||
<?php echo Html::anchor(__('Edit', 'snippets'), 'index.php?id=snippets&action=edit_snippet&filename='.basename($snippet, '.snippet.php'), array('class' => 'btn btn-actions btn-small')); ?>
|
||||
<a class="btn dropdown-toggle btn-actions btn-small" data-toggle="dropdown" href="#" style="font-family:arial;"><span class="caret"></span></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><?php echo Html::anchor(__('View Embed Code', 'snippets'), 'javascript:;', array('title' => __('View Embed Code', 'snippets'), 'onclick' => '$.monstra.snippets.showEmbedCodes("'.basename($snippet, '.snippet.php').'");')); ?></li>
|
||||
<li><?php echo Html::anchor(__('View Embed Code', 'snippets'), 'javascript:;', array('title' => __('View Embed Code', 'snippets'), 'data-event' => 'viewEmbedCode', 'data-method' => 'click', 'data-value' => basename($snippet, '.snippet.php'))); ?></li>
|
||||
</ul>
|
||||
<?php echo Html::anchor(__('Delete', 'snippets'),
|
||||
'index.php?id=snippets&action=delete_snippet&filename='.basename($snippet, '.snippet.php').'&token='.Security::token(),
|
||||
|
Reference in New Issue
Block a user