require.config({ baseUrl: '/assets/js', paths: { jquery: 'jquery-1.10.2.min', bootstrap: 'bootstrap.min' }, shim: { 'bootstrap': ['jquery'] } }); stogram = function(){ var self = this; self.init = function(container){ $('[data-selected]').each(function(idx){ var v = $(this).data('selected'); $('option', this).each(function(){ if ($(this).val()==v) { $(this).prop('selected', 1); } }) }); require(['bootstrap'], function() { $('[data-toggle="tooltip"]').tooltip(); $('[data-spy="affix"]').affix(); }); $('[data-plugin]', container).each(function(idx){ var plugin = $(this).attr('data-plugin'); var opts = $(this).data(); opts.el = $(this); opts.id = 'st-plugin-'+plugin+'-'+idx; self.plugin(plugin, opts); }); } self.plugin = function(plugin, opts, callback) { var fa = plugin.match(/\-(\w)/g); if (fa) { for(var x in fa) { func = plugin.replace(fa[x], fa[x].toUpperCase()).replace('-',''); } } var func = eval('self.'+func); if (func) { func(el, opts); } else { require(['stogram/plugins/'+plugin], function(plugin) { plugin = new plugin(opts); if (callback) { callback(plugin); } }); } } self.init('body'); return self; } var stogram = new stogram(); window.stogram = stogram;