2 lines
53 KiB
JavaScript
2 lines
53 KiB
JavaScript
|
function reloadCharts(){return-1===navigator.userAgent.toLowerCase().indexOf("firefox")?!1:($('.ui-widget-content [aria-expanded="false"]').find("iframe").each(function(){var e=$(this).attr("src");-1!==e.indexOf("charts")&&($(this).hide(),$(this).attr("src",e),$(this).show())}),void 0)}function openDialogCenter(e){e.dialog("open");var t=getDimensions(e.parent());e.dialog({position:[t[0],t[1]]})}function getDimensions(e){var t=new Array(2);return t[0]=$(window).width()/2-e.width()/2,t[1]=$(window).height()/2-e.height()/2,t}function updateChart(e,t,n,r,a,i){var n=n,r=r,o=$("#iframe"+e).attr("default_src");o||(o=$("#iframe"+e).attr("src")),src=o.split("?")[0],("bar"===$("#type_"+e).val()||"column"===$("#type_"+e).val())&&0==$("#timescale_"+e).val().length&&0==$("#average_"+e).val().length&&0==$("#median_"+e).val().length&&0==$("#sum_"+e).val().length&&$("#timescale_"+e).val(30);var s=[];$(".chart_options"+e).each(function(){var e=$(this).val(),t=$(this).attr("id"),n=t.split("_")[0];e.length>0&&s.push([n,e])});for(var l="";s.length>0;){var c=s.pop();"width"==c[0]&&(n=parseInt(c[1])),"height"==c[0]&&(r=parseInt(c[1])),("type"!=c[0]||"line"!=c[1])&&(l+="&"+c[0]+"="+encodeURIComponent(c[1]))}l.length>0&&(src+="?"+l.substring(1)),t&&e>0&&i?$.update("/channels/"+a+"/charts/"+e,{newOptions:{options:l}}):t&&e>0&&$.update("/channels/"+a+"/charts/"+e,{options:l}),$("#embed"+e).val('<iframe width="'+n+'" height="'+r+'" style="border: 1px solid #cccccc;" src="'+src+'"></iframe>'),$("#iframe"+e).attr("src",src),$("#iframe"+e).attr("width",n),$("#iframe"+e).attr("height",r)}function updateSelectValues(){selectedValue=$(this).val(),$(".mutuallyexclusive"+index).each(function(){$(this).val("")}),$(this).val(selectedValue)}function setupChartForm(e){return function(t,n){n.length>0&&$("#"+n.split("=")[0]+"_"+e).val(decodeURIComponent(n.split("=")[1]))}}function setupColumns(e,t){$(sortColumnSetup(e,t)),$(".column").disableSelection()}function createWindowsWithData(e,t,n,r){for(var a in e){for(var i in e[a])var o=i;if(e[a].chart_window&&(s=e[a].chart_window),e[a].plugin_window&&(s=e[a].plugin_window),e[a].portlet_window&&(s=e[a].portlet_window),"undefined"==s)var s=e[a].portlet_window?e[a].portlet_window:e[a].chart_window;colId=s.col,title=s.title;var l=s.html;if(e[a].chart_window){var c=s.id;$("body").append("<div id='chartConfig"+c+"'></div>")}var d=addWindow(r,colId,s.id,o,title,l);d.each(decoratePortlet(t)),d.find(".ui-toggle").click(uiToggleClick),d.find(".ui-view").click(uiViewClick(n)),d.find(".ui-edit").click(uiEditClick(n)),d.find(".ui-close").click(uiCloseClick(n))}}function addWindow(e,t,n,r,a,i){if($("#"+e+"_dialog"+t).append('<div class="portlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" id="portlet_'+n+'"><div class="portlet-header wtype wtype-'+r+' ui-widget-header ui-corner-all">'+a+'</div><div class="portlet-content">'+i+"</div>"),$("#portlet_"+n).length>1)throw"Portlet count doesn't match what's expected";return $("#portlet_"+n)}function sortColumnSetup(e,t){$(".column").sortable({opacity:.6,helper:function(){return $("<div class='ui-widget-header'>Drop to re-position</div>")},connectWith:".column",update:updatePortletPositions(e,t)})}function getPortletArray(e){var t=new Array,n=e.split("&");for(i in n)val=n[i].split("=")[1],t.push(val);return t}function uiToggleClick(){$(this).toggleClass("ui-icon-minusthick").toggleClass("ui-icon-plusthick"),$(this).parents(".portlet:first").find(".portlet-content").toggle()}!function(e,t){e.rails!==t&&e.error("jquery-ujs has already been loaded!");var n,r=e(document);e.rails=n={linkClickSelector:"a[data-confirm], a[data-method], a[data-remote], a[data-disable-with]",buttonClickSelector:"button[data-remote]",inputChangeSelector:"select[data-remote], input[data-remote], textarea[data-remote]",formSubmitSelector:"form",formInputClickSelector:"form input[type=submit], form input[type=image], form button[type=submit], form button:not([type])",disableSelector:"input[data-disable-with], button[data-disable-with], textarea[data-disable-with]",enableSelector:"input[data-disab
|
||
|
else{var i=e.value.split("\n"),o=new Array,s=0,l=0;for(var c in i)l=s+i[c].length,o.push({start:s,end:l,selected:r>=s&&l>r||l>=a&&a>s||s>r&&a>l}),s=l+1;var d=0;for(var c in o)if(o[c].selected){var u=o[c].start+d;t&&n.tabString==e.value.substring(u,u+n.tabString.length)?(e.value=e.value.substring(0,u)+e.value.substring(u+n.tabString.length),d-=n.tabString.length):t||(e.value=e.value.substring(0,u)+n.tabString+e.value.substring(u),d+=n.tabString.length)}e.focus();var f=r+(d>0?n.tabString.length:0>d?-n.tabString.length:0),h=a+d;e.setSelectionRange(f,h)}}function r(t,n,r){var a=document.selection.createRange();if(t==a.parentElement())if(""==a.text)if(n){var i=a.getBookmark();a.moveStart("character",-r.tabString.length),r.tabString==a.text?a.text="":(a.moveToBookmark(i),a.moveEnd("character",r.tabString.length),r.tabString==a.text&&(a.text="")),a.collapse(!0),a.select()}else a.text=r.tabString,a.collapse(!1),a.select();else{var o=a.text,s=o.length,l=o.split("\r\n"),c=document.body.createTextRange();c.moveToElementText(t),c.setEndPoint("EndToStart",a);var d=c.text,u=d.split("\r\n"),f=d.length,h=document.body.createTextRange();h.moveToElementText(t),h.setEndPoint("StartToEnd",a);var p=h.text,m=document.body.createTextRange();m.moveToElementText(t),m.setEndPoint("StartToEnd",c);var g=m.text,b=e(t).html();e("#r3").text(f+" + "+s+" + "+p.length+" = "+b.length),f+g.length<b.length?(u.push(""),f+=2,n&&r.tabString==l[0].substring(0,r.tabString.length)?l[0]=l[0].substring(r.tabString.length):n||(l[0]=r.tabString+l[0])):n&&r.tabString==u[u.length-1].substring(0,r.tabString.length)?u[u.length-1]=u[u.length-1].substring(r.tabString.length):n||(u[u.length-1]=r.tabString+u[u.length-1]);for(var v=1;v<l.length;v++)n&&r.tabString==l[v].substring(0,r.tabString.length)?l[v]=l[v].substring(r.tabString.length):n||(l[v]=r.tabString+l[v]);1==u.length&&0==f&&(n&&r.tabString==l[0].substring(0,r.tabString.length)?l[0]=l[0].substring(r.tabString.length):n||(l[0]=r.tabString+l[0])),f+s+p.length<b.length&&(l.push(""),s+=2),c.text=u.join("\r\n"),a.text=l.join("\r\n");var y=document.body.createTextRange();y.moveToElementText(t),f>0?y.setEndPoint("StartToEnd",c):y.setEndPoint("StartToStart",c),y.setEndPoint("EndToEnd",a),y.select()}}e.fn.tabby=function(n){var r=e.extend({},e.fn.tabby.defaults,n),a=e.fn.tabby.pressed;return this.each(function(){$this=e(this);var n=e.meta?e.extend({},r,$this.data()):r;$this.bind("keydown",function(r){var i=e.fn.tabby.catch_kc(r);return 16==i&&(a.shft=!0),17==i&&(a.ctrl=!0,setTimeout("$.fn.tabby.pressed.ctrl = false;",1e3)),18==i&&(a.alt=!0,setTimeout("$.fn.tabby.pressed.alt = false;",1e3)),9!=i||a.ctrl||a.alt?void 0:(r.preventDefault,a.last=i,setTimeout("$.fn.tabby.pressed.last = null;",0),t(e(r.target).get(0),a.shft,n),!1)}).bind("keyup",function(t){16==e.fn.tabby.catch_kc(t)&&(a.shft=!1)}).bind("blur",function(t){9==a.last&&e(t.target).one("focus",function(){a.last=null}).get(0).focus()})})},e.fn.tabby.catch_kc=function(e){return e.keyCode?e.keyCode:e.charCode?e.charCode:e.which},e.fn.tabby.pressed={shft:!1,ctrl:!1,alt:!1,last:null},e.fn.tabby.defaults={tabString:String.fromCharCode(9)}}(jQuery),function(e,t,n){var r={required:"The %s field is required.",matches:"The %s field does not match the %s field.",valid_email:"The %s field must contain a valid email address.",min_length:"The %s field must be at least %s characters in length.",max_length:"The %s field must not exceed %s characters in length.",exact_length:"The %s field must be exactly %s characters in length.",greater_than:"The %s field must contain a number greater than %s.",less_than:"The %s field must contain a number less than %s.",alpha:"The %s field must only contain alphabetical characters.",alpha_numeric:"The %s field must only contain alpha-numeric characters.",alpha_dash:"The %s field must only contain alpha-numeric characters, underscores, and dashes.",numeric:"The %s field must contain only numbers.",integer:"The %s field must contain an integer."},a=function(){},i=/^(.+)\[(.+)\]$/,o=/^[0-9]+$/,s=/^\-?[0-9]+$/,l=/^\-?[0-9]*\.?[0-9]+$/,c=/^[a-z0-9._%+-]+@
|