Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added , attributes

  • Loading branch information...
commit ce7dee94219b3476db05cc1d7ba039764c0188ef 1 parent 5bf7a48
@jfragoulis authored
Showing with 3 additions and 1 deletion.
  1. +2 −0  assets/jquery.metabox.js
  2. +1 −1  assets/jquery.metabox.min.js
View
2  assets/jquery.metabox.js
@@ -13,6 +13,8 @@
this.options = $.extend({}, $.fn.metabox.defaults, options);
this.$element = $(element);
this.$content = $('.' + this.options.cssClass + '-content', element);
+ this.$header = $('.' + this.options.cssClass + '-header', element);
+ this.$footer = $('.' + this.options.cssClass + '-footer', element);
this.options.errorText = this.options.errorText.replace('{url}', this.options.url);
View
2  assets/jquery.metabox.min.js
@@ -1 +1 @@
-!function(e){"use strict";var t=function(t,n){this.options=e.extend({},e.fn.metabox.defaults,n);this.$element=e(t);this.$content=e("."+this.options.cssClass+"-content",t);this.options.errorText=this.options.errorText.replace("{url}",this.options.url);if(this.options.loadingContainer)this.options.loadingContainer=e(this.options.loadingContainer);else this.options.loadingContainer=this.$content;if(this.options.refreshTimeout>0)this.createTimeout();else if(this.options.refreshInterval>0)this.createInterval();if(this.options.refreshOnInit)this.refresh()};t.prototype={constructor:t,createTimeout:function(){var e=this;setTimeout(function(){e.refresh()},this.options.refreshTimeout)},createInterval:function(){var e=this;setInterval(function(){e.refresh()},this.options.refreshInterval)},refresh:function(t){var n;if(t&&t.error!==undefined){n=t.error;delete t.error}var r=this;t=e.extend({type:this.options.type,url:this.options.url,data:this.options.data,beforeSend:function(){r.$element.addClass(r.options.loadingClass);r.options.loadingContainer.html(r.options.loadingText);r.options.beforeRefresh.apply(r)},success:function(e){r.$element.removeClass(r.options.loadingClass);r.options.loadingContainer.html("");r.options.handleResponse.apply(r,[e]);r.options.afterRefresh.apply(r,[e])},error:function(e,t,i){var s,o;r.$element.removeClass(r.options.loadingClass);r.options.loadingContainer.html(r.options.errorText);if(e.readyState===0||e.status===0){return}if(n!==undefined){s=n(e);if(s!==undefined&&!s){return}}switch(t){case"timeout":o="The request timed out!";break;case"parsererror":o="Parser error!";break;case"error":if(e.status&&!/^\s*$/.test(e.status)){o="Error "+e.status}else{o="Error"}if(e.responseText&&!/^\s*$/.test(e.responseText)){o=o+": "+e.responseText}break}if(o)alert(o)}},t||{});if(t.data!==undefined&&t.type==="GET"){t.url=e.param.querystring(t.url,t.data);t.data={}}e.ajax(t)}};e.fn.metabox=function(n,r){return this.each(function(){var i=e(this),s=i.data("metabox"),o=typeof n=="object"&&n;if(!s)i.data("metabox",s=new t(this,o));if(n=="refresh")s.refresh(r)})};e.fn.metabox.defaults={loadingText:"loading...",loadingClass:"metabox-loading",loadingContainer:null,errorText:"Error loading {url}",cssClass:"metabox",url:null,data:{},type:"GET",refreshOnInit:false,refreshTimeout:0,refreshInterval:0,beforeRefresh:function(){},handleResponse:function(e){this.$content.html(e)},afterRefresh:function(e){},debug:true};e.fn.metabox.Constructor=t}(window.jQuery)
+!function($){"use strict";var Metabox=function(element,options){this.options=$.extend({},$.fn.metabox.defaults,options);this.$element=$(element);this.$content=$('.'+this.options.cssClass+'-content',element);this.$header=$('.'+this.options.cssClass+'-header',element);this.$footer=$('.'+this.options.cssClass+'-footer',element);this.options.errorText=this.options.errorText.replace('{url}',this.options.url);if(this.options.loadingContainer)this.options.loadingContainer=$(this.options.loadingContainer);else this.options.loadingContainer=this.$content;if(this.options.refreshTimeout>0)this.createTimeout();else if(this.options.refreshInterval>0)this.createInterval();if(this.options.refreshOnInit)this.refresh()};Metabox.prototype={constructor:Metabox,createTimeout:function(){var $this=this;setTimeout(function(){$this.refresh()},this.options.refreshTimeout)},createInterval:function(){var $this=this;setInterval(function(){$this.refresh()},this.options.refreshInterval)},refresh:function(options){var customError;if(options&&options.error!==undefined){customError=options.error;delete options.error}var $box=this;options=$.extend({type:this.options.type,url:this.options.url,data:this.options.data,beforeSend:function(){$box.$element.addClass($box.options.loadingClass);$box.options.loadingContainer.html($box.options.loadingText);$box.options.beforeRefresh.apply($box)},success:function(data){$box.$element.removeClass($box.options.loadingClass);$box.options.loadingContainer.html('');$box.options.handleResponse.apply($box,[data]);$box.options.afterRefresh.apply($box,[data])},error:function(XHR,textStatus,errorThrown){var ret,err;$box.$element.removeClass($box.options.loadingClass);$box.options.loadingContainer.html($box.options.errorText);if(XHR.readyState===0||XHR.status===0){return}if(customError!==undefined){ret=customError(XHR);if(ret!==undefined&&!ret){return}}switch(textStatus){case'timeout':err='The request timed out!';break;case'parsererror':err='Parser error!';break;case'error':if(XHR.status&&!/^\s*$/.test(XHR.status)){err='Error '+XHR.status}else{err='Error'}if(XHR.responseText&&!/^\s*$/.test(XHR.responseText)){err=err+': '+XHR.responseText}break}if(err)alert(err)}},options||{});if(options.data!==undefined&&options.type==='GET'){options.url=$.param.querystring(options.url,options.data);options.data={}}$.ajax(options)}};$.fn.metabox=function(option,ajaxoptions){return this.each(function(){var $this=$(this),data=$this.data('metabox'),options=typeof option=='object'&&option;if(!data)$this.data('metabox',(data=new Metabox(this,options)));if(option=='refresh')data.refresh(ajaxoptions)})};$.fn.metabox.defaults={loadingText:'loading...',loadingClass:'metabox-loading',loadingContainer:null,errorText:'Error loading {url}',cssClass:'metabox',url:null,data:{},type:'GET',refreshOnInit:false,refreshTimeout:0,refreshInterval:0,beforeRefresh:function(){},handleResponse:function(data){this.$content.html(data)},afterRefresh:function(data){},debug:true};$.fn.metabox.Constructor=Metabox}(window.jQuery);
Please sign in to comment.
Something went wrong with that request. Please try again.