templates/js.rb in prologue-0.3.11 vs templates/js.rb in prologue-0.4.0

- old
+ new

@@ -5,55 +5,68 @@ run 'rm public/javascripts/application.js' create_file 'public/javascripts/core.js' do <<-FILE (function($){ - var QL = QL || {}; + var Ql = Ql || {}; - QL = { - init: function QL_init(){ + Ql = { + init: function Ql_init(){ // some code that needs to be executed after doc ready - QL.bindEvents(); + Ql.bindEvents(); }, - bindEvents: function QL_liveEvents(){ + bindEvents: function Ql_liveEvents(){ $('a[rel*=external]').live('click',function(){ window.open(this.href); return false; }); // more globally bound events - }, - helpers: function QL_helpers(){ + }, + submit: function(ajax_url,ajax_data,ajax_type,callback){ + $.ajax({ + type: ajax_type, + url: ajax_url, + data: ajax_data, + success: function(data) { + if(typeof callback.onSuccess == 'function'){ + callback.onSuccess.call(this, data); + } + }, + error: function(data,status){ + if(typeof callback.onError == 'function'){ + if(data.status == '403') { + return callback.onDenied.call(this, data); + } + callback.onError.call(this, data); + } + }, + complete: function(data){ + if(typeof callback.onComplete == 'function'){ + callback.onComplete.call(this, data); + } + }, + denied: function(data){ + if(typeof callback.onDenied == 'function'){ + callback.onDenied.call(this, data); + } + } + }); + }, + helpers: { // helper for searching through arrays - QL.helpers.arraySearch = function(a){ + arraySearch: function(a){ var o = {}; for(var i=0;i<a.length;i++){ o[a[i]]=''; } return o; - }; - //j. resigs array remove overload - Array.prototype.remove = function(from, to) { - var rest = this.slice((to || from) + 1 || this.length); - this.length = from < 0 ? this.length + from : from; - return this.push.apply(this, rest); - }; - // duck punch Array.indexOf into IE browsers - if(!Array.indexOf){ - Array.prototype.indexOf = function(obj){ - for(var i=0; i<this.length; i++){ - if(this[i]==obj){ - return i; - } - } - return -1; } } } -}; - window.QL = QL; - $(document).ready(QL.init); + window.Ql = Ql; + $(document).ready(Ql.init); })(jQuery); FILE end