1
0
mirror of https://github.com/monstra-cms/monstra.git synced 2025-08-06 21:26:58 +02:00

3 Commits

Author SHA1 Message Date
Sergey Romanenko
4b4b78e554 Update plugins/box/snippets/js/snippets.js 2013-01-16 09:20:47 +02:00
Sergey Romanenko
3f420f2406 Update plugins/box/snippets/views/backend/index.view.php 2013-01-14 16:38:36 +02:00
Sergey Romanenko
b499f2a1da Update plugins/box/snippets/js/snippets.js 2013-01-14 16:37:40 +02:00
2 changed files with 46 additions and 13 deletions

View File

@@ -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);

View File

@@ -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(),