mirror of
https://github.com/monstra-cms/monstra.git
synced 2025-08-09 06:37:01 +02:00
Compare commits
3 Commits
v2.3.1
...
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) {
|
if(typeof Events.endpoints[name] != 'undefined'){
|
||||||
$('#shortcode').html('{snippet get="'+name+'"}');
|
if(!bound){
|
||||||
$('#phpcode').html('<?php echo Snippet::get("'+name+'"); ?>');
|
$this.attr('data-bound', 'true');
|
||||||
$('#embedCodes').modal();
|
$this.on(method, Events.endpoints[name]);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
init: function(){
|
||||||
|
Events.bindEvents();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
};
|
App = {
|
||||||
|
logic: {},
|
||||||
|
init: function() {
|
||||||
|
Events.init();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
Public = {
|
||||||
|
init: App.init
|
||||||
|
};
|
||||||
|
|
||||||
$(document).ready(function(){
|
return Public;
|
||||||
$.monstra.snippets.init();
|
|
||||||
});
|
})(window.jQuery);
|
||||||
|
|
||||||
|
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')); ?>
|
<?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>
|
<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">
|
<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>
|
</ul>
|
||||||
<?php echo Html::anchor(__('Delete', 'snippets'),
|
<?php echo Html::anchor(__('Delete', 'snippets'),
|
||||||
'index.php?id=snippets&action=delete_snippet&filename='.basename($snippet, '.snippet.php').'&token='.Security::token(),
|
'index.php?id=snippets&action=delete_snippet&filename='.basename($snippet, '.snippet.php').'&token='.Security::token(),
|
||||||
|
Reference in New Issue
Block a user