// handle secured json string - the Prototype implementation / $.ajaxSetup({ dataFilter: function(data, type) { if(type != 'json' || !data) return data; return data.replace(/^\/\*-secure-([\s\S]*)\*\/\s*$/, '$1'); }, cache: false // Was Really NEeded! }); $(document).ready(function() { $(".e-hideme").hide(); $(".e-expandit").show(); // $(".e-spinner").spinner(); //FIXME breaks tooltips //check all $("#check-all").click(function(event){ var val = $(this).val(), selector = '.field-spacer'; event.preventDefault(); // e.g. - match all checkboxes with attribute 'name="perms[]" if(val && val.match(/^jstarget\:/)) { selector = 'input:checkbox[name^=' + val.split(':')[1] + ']'; $(selector).each( function() { $(this).attr("checked",true); }); return; } // checkboxes children of .field-spacer else { $(selector).each( function() { $(this).children(":checkbox").attr("checked",true); }) } }) $("#uncheck-all").click(function(event) { var val = $(this).val(), selector = '.field-spacer'; event.preventDefault(); // e.g. - match all checkboxes with attribute 'name="perms[]" if(val && val.match(/^jstarget\:/)) { selector = 'input:checkbox[name^=' + val.split(':')[1] + ']'; $(selector).each( function() { $(this).attr("checked",false); }) } // checkboxes children of .field-spacer else { $(".field-spacer").each( function() { $(this).children(":checkbox").attr("checked",false); }); } }) // default 'toggle'. $(".e-expandit").click(function () { var href = ($(this).is("a")) ? $(this).attr("href") : ''; if(href == '' && $(this).attr("data-target")) { href = '#' + $(this).attr("data-target"); } if(href === "#" || href == "") { idt = $(this).nextAll("div"); $(idt).toggle("slow"); return true; } //var id = $(this).attr("href"); $(href).toggle("slow"); return false; }); // On $(".e-expandit-on").click(function () { if($(this).is("input") && $(this).attr("type")=='radio') { idt = $(this).parent().nextAll("div.e-expandit-container"); $(idt).show("slow"); return true; } var href = ($(this).is("a")) ? $(this).attr("href") : ''; if(href === "#" || href == "") { idt = $(this).nextAll("div.e-expandit-container"); $(idt).show("slow"); return true; // must be true or radio buttons etc. won't work } if($(this).attr("data-expandit")) { var id = $(this).attr("data-expandit"); } else { var id = $(this).attr("href"); } $(id).show("slow"); return false; }); // Off. $(".e-expandit-off").click(function () { if($(this).is("input") && $(this).attr("type")=='radio') { idt = $(this).parent().nextAll("div.e-expandit-container"); $(idt).hide("slow"); return true; } var href = ($(this).is("a")) ? $(this).attr("href") : ''; if(href === "#" || href == "") { idt = $(this).nextAll("div.e-expandit-container"); $(idt).hide("slow"); return true; // must be true or radio buttons etc. won't work } if($(this).attr("data-expandit")) { var id = $(this).attr("data-expandit"); } else { var id = $(this).attr("href"); } $(id).hide("slow"); return false; }); // Dates -------------------------------------------------- // https://github.com/smalot/bootstrap-datetimepicker $("input.e-date").each(function() { $(this).datepicker({ format: $(this).attr("data-date-format"), weekStart: $(this).attr("data-date-firstday") }); }); /* $("input.e-date").each(function() { $(this).datepicker({ dateFormat: $(this).attr("data-date-format"), ampm: $(this).attr("data-date-ampm"), firstDay: $(this).attr("data-date-firstday"), showButtonPanel: true }); }); $("input.e-datetime").each(function() { // var name = $(this).attr("name"); // var val = $(this).val(); // alert(name + ': ' + val); $(this).datetimepicker({ dateFormat: $(this).attr("data-date-format"), timeFormat: $(this).attr("data-time-format"), defaultDate: $(this).val(), defaultValue: $(this).val(), setDate: $(this).val(), ampm: $(this).attr("data-date-ampm"), // firstDay: $(this).attr("data-date-firstday"), showButtonPanel: true }); }); // Inline versions $("div.e-date").each(function() { var id = $(this).attr("id"); var newid = id.replace("inline-", ""); $(this).datepicker({ dateFormat: $(this).attr("data-date-format"), ampm: $(this).attr("data-date-ampm"), firstDay: $(this).attr("data-date-firstday"), defaultDate: $("#"+newid).val(), onSelect: function(dateText, inst) { $("#"+newid).val(dateText); } }); }); $("div.e-datetime").each(function() { var id = $(this).attr("id"); var newid = id.replace("inline-", ""); $(this).datetimepicker({ dateFormat: $(this).attr("data-date-format"), ampm: $(this).attr("data-date-ampm"), showButtonPanel: false, onSelect: function(dateText, inst) { $("#"+newid).val(dateText); } }); $(this).datetimepicker('setDate', $("#"+newid).val()); }); */ // Tabs ----------------------------------------------------- $(function() { $( "#tab-container" ).tabs({cache: true}); }); // Tabs $(function() { $( ".e-tabs" ).tabs(); }); $('.e-tabs-add').on("click", function(){ var url = $(this).attr('data-url'); var ct = parseInt($("#e-tab-count").val()); var count = ct + 1; // alert(count); //return false; if($("#tab-container").tabs("add",url +'&count='+count,"Page "+count)) { $("#tab-container").tabs('select', ct); $("#e-tab-count").val(count); } return false; }); // --------------- Email ---------------------------------------- $('.e-email').on('blur', function() { // alert('hello'); $(this).mailcheck({ suggested: function(element, suggestion) { var id = $(element); var hint = $(element).next('div').attr('data-hint'); var mes = hint.replace('[x]',suggestion.full); $(element).next('div').html(mes); $(element).next('div').show('slow'); }, empty: function(element) { $(element).next('div').hide('slow'); } }); }); // --------------- Passwords ----------------------------- // front-end $('.e-password').on('keyup', function() { // var len = $(this).val().length; //data-minlength }); // Tooltips for bbarea. $(".bbcode_buttons").tooltip({placement: 'top',opacity: 1.0, fade: true,html: true}); // $("a.e-tip").tipsy({gravity: 'w',opacity: 1.0, fade: true,html: true}); // var tabs = $('#tab-container').clone(true); // $('#htmlEditor').append(tabs); $('e-clone').click(function(){ var copy = $(this).attr('id'); duplicateHTML(copy,paste,baseid); }); /* $("a.e-bb").click(function(){ var add = $(this).attr('data-bbcode'); var func = $(this).attr('data-function'); var diz = $(this).attr('title'); id = $(this).attr('href'); var tmp = id.replace('#',''); //alert(tmp); if(func == 'insert') { addtext(add,true); return false; } if(func == 'input') { addinput(add,diz); return false; } if(func == 'show') { $('#'+add).show('slow'); // addinput(add,diz); return false; } if(func == 'add') { addtext(add); return false; } return false; }); $("select.e-bb").change(function(){ var add = $(this).val(); addtext(add); $(this).val(''); return false; }); $(".e-bb").mouseover(function(){ var id = $(this).attr('id'); var diz = $(this).attr('title'); // alert(id); var tmp = id.split('--'); // alert('#'+tmp[0]); $('#'+tmp[0]).val(diz); return false; }); $(".e-bb").mouseout(function(){ var id = $(this).attr('id'); var tmp = id.split('--') $('#'+tmp[0]).val(''); return false; }); */ // $(".e-multiselect").chosen(); // Character Counter // $("textarea").before("
"); $("textarea").keyup(function(){ // var max=$(this).attr("maxlength"); var max = 100; var el = "#" + $(this).attr("name") + "-remainingCharacters"; var valLen=$(this).val().length; $(el).text( valLen + " characters") }); // Dialog $("a.e-dialog").colorbox({ iframe:true, width:"60%", height:"70%", preloading:false, speed:10, opacity: 0.7, fastIframe: false, onComplete: function() { // $("iframe").contents().find("body").addClass("mediaBody"); } }); $(".e-dialog-close").live("click", function(){ parent.$('.modal').modal('hide'); // parent.$.colorbox.close() }); /* $("input.e-dialog").live('click',function() { var link = $(this).attr("data-target"); $(this).dialog({ modal: true, open: function () { $(this).load(link); }, height: 600, iframe: true, width: 700, title: 'Dynamically Loaded Page' }); return false; }); */ // Modal Box - uses inline hidden content /* $(".e-modal").click(function () { var id = $(this).attr("href"); $(id).dialog({ minWidth: 800, maxHeight: 700, modal: true }); }); */ $(".e-shake" ).effect("shake","",100); $('.e-rate').each(function() { var path = $(this).attr("data-path"); var script = $(this).attr("data-url"); var score = $(this).attr("data-score"); var readonly = parseInt($(this).attr("data-readonly")); var tmp = $(this).attr('id'); var hint = $(this).attr("data-hint"); var hintArray = hint.split(',') var t = tmp.split('-'); var table = t[0]; var id = t[1]; $('.e-rate').raty({ path : path, half : true, score : score, readOnly : readonly, hints : hintArray, // starOff : 'star_off_16.png', // starOn : 'star_on_16.png', // starHalf : 'star_half_16.png', // cancelOff : 'cancel-off-big.png', // cancelOn : 'cancel-on-big.png', // size : 16, target : '#e-rate-'+tmp, // targetType : 'number', targetText : $('#e-rate-'+tmp).text(), // cancel : true, // css : 'e-rate-star', click: function(score, evt) { $(this).find('img').unbind('click'); $(this).find('img').unbind(); $.ajax({ type: "POST", url: script + "?ajax_used=1", data: { table: table, id: id, score: score } }).done(function( msg ) { alert(msg); bla = msg.split('|'); $('#e-rate-'+tmp).text(bla[0]); if(bla[1]) { $('#e-rate-votes-'+tmp).text(bla[1]); } }); } }); }); // $( ".field-help" ).tooltip(); // Allow Tabs to be used inside textareas. $( 'textarea' ).keypress( function( e ) { if ( e.keyCode == 9 ) { e.preventDefault(); $( this ).val( $( this ).val() + '\t' ); } }); // Text-area AutoGrow // $("textarea.e-autoheight").elastic(); // ajax next/prev mechanism - updates url from value. $(".e-nav").click(function(){ // should be run before ajax. /* var src = $(this).attr("data-src"); var inc = parseInt($(this).attr("data-nav-inc")); var dir = $(this).attr("data-nav-dir"); var tot = parseInt($(this).attr("data-nav-total")); var val = src.match(/from=(\d+)/); var amt = parseInt(val[1]); var oldVal = 'from='+ amt; var sub = amt - inc; var add = amt + inc; $(this).show(); if(add > tot) { add = amt; } if(sub < 0) { sub = 0 } if(dir == 'down') { var newVal = 'from='+ sub; } else { var newVal = 'from='+ add; } alert('nav'); src = src.replace(oldVal, newVal); $(".e-nav").attr("data-src",src); */ }); $(".e-ajax").click(function(){ var id = $(this).attr("href"); var target = $(this).attr("data-target"); // support for input buttons etc. var loading = $(this).attr('data-loading'); // image to show loading. var nav = $(this).attr('data-nav-inc'); if(nav != null) { eNav(this,'.e-ajax'); //modify data-src value for next/prev. 'from=' } var src = $(this).attr("data-src"); if(target != null) { id = '#' + target; } if(loading != null) { $(id).html("