formatHitCountResult = function(inRow) { return inRow[1]; } function getRandomColor() { var letters = '0123456789ABCDEF'.split(''); var color = '#'; for (var i = 0; i < 6; i++ ) { color += letters[Math.floor(Math.random() * 16)]; } return color; } uiload = function() { var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); var themeprefix = app.data("home") + app.data("themeprefix"); //https://github.com/select2/select2/issues/600 $.fn.modal.Constructor.prototype.enforceFocus = function() {}; $('#module-dropdown').livequery("click", function(e){ e.stopPropagation(); if ( $(this).hasClass('active') ) { $(this).removeClass('active'); $('#module-list').hide(); } else { $(this).addClass('active'); $('#module-list').show(); } }); jQuery("select.select2").livequery( function() { var input = jQuery(this); input.select2({ allowClear: true }); }); jQuery("select.listdropdown").livequery( function() { var theinput = jQuery(this); var dropdownParent = $("body"); var parent = theinput.closest(".modal-dialog"); if( parent.length ) { dropdownParent = parent; //console.log("found modal parent, skipping"); //https://github.com/select2/select2-bootstrap-theme/issues/41 } else { theinput = theinput.select2({ allowClear: true, minimumInputLength : 0, dropdownParent: dropdownParent, theme: "classic" // dropdownCssClass: 'custom-dropdown' // }).on("select2:opening", // function(){ // dropdownParent.removeAttr("tabindex"); // }).on("select2:close", // function(){ // //dropdownParent.attr("tabindex", "-1"); // }); }); // theinput.on('select2:open', function(e){ // $('.custom-dropdown').parent().css('z-index', 99999); // }); // dropdownParent.removeAttr("tabindex"); } }); jQuery("input.select2editable").livequery( function() { var input = jQuery(this); var arr = new Array(); //[{id: 0, text: 'story'},{id: 1, text: 'bug'},{id: 2, text: 'task'}] var ulid = input.data("optionsul"); var options = jQuery("#" + ulid + " li"); if( !options.length ) { return; } options.each(function() { var id = $(this).data('value'); var text = $(this).text(); //console.log(id + " " + text); arr.push({id: id, text: text}); }); //Be aware: calling select2 forces livequery to filter again input.select2({ createSearchChoice: function(term, data) { if ($(data).filter(function() { return this.text.localeCompare(term)===0; } ).length===0) { //console.log("picking" + term ); return {id:term, text:term}; } } , multiple: false , data: arr }); }); jQuery(".force-validate-inputs").livequery( function() { /* jQuery(".required",this).each(function() { //jQuery(this).attr("required","true"); }); */ var theform = jQuery(this).closest("form"); theform.on("click", function() { theform.valid(); }); $.validator.setDefaults({ignore: [".ignore"]}); theform.validate({ ignore: [".ignore"] }); } ); jQuery("select.ajax").livequery('change', function(e) { var inlink = jQuery(this); var nextpage= inlink.data('href'); nextpage = nextpage + inlink.val(); var targetDiv = inlink.data("targetdiv"); if(!targetDiv){ targetDiv = inlink.attr("targetdiv"); } targetDiv = targetDiv.replace(/\//g, "\\/"); jQuery.get(nextpage, {}, function(data) { var cell = jQuery("#" + targetDiv); cell.replaceWith(data); $(window).trigger( "resize" ); }); } ); jQuery("a.toggle-visible").livequery('click', function(e) { e.preventDefault(); var div = jQuery(this).data("targetdiv"); var target = jQuery("#" + div ); if(target.is(":hidden")) { var hidelable = jQuery(this).data("hidelabel"); jQuery(this).find("span").text(hidelable); target.show(); } else { var showlabel = jQuery(this).data("showlabel"); jQuery(this).find("span").text(showlabel); target.hide(); } } ); if( jQuery.fn.selectmenu ) { jQuery('.uidropdown select').livequery( function() { jQuery(this).selectmenu({style:'dropdown'}); } ); } var browserlanguage = app.data("browserlanguage"); if( browserlanguage == undefined ) { browserlanguage = ""; } if( jQuery.datepicker ) { jQuery.datepicker.setDefaults(jQuery.extend({ showOn: 'button', buttonImage: themeprefix + '/entermedia/images/cal.gif', buttonImageOnly: true, changeMonth: true, changeYear: true, yearRange: '1900:2050' }, jQuery.datepicker.regional[browserlanguage])); //Move this to the layout? jQuery("input.datepicker").livequery( function() { var targetid = jQuery(this).data("targetid"); jQuery(this).datepicker( { altField: "#"+ targetid, altFormat: "yy-mm-dd", yearRange: '1900:2050' }); var current = jQuery("#" + targetid).val(); if(current != undefined) { //alert(current); var date; if( current.indexOf("-") > 0) //this is the standard { current = current.substring(0,10); //2012-09-17 09:32:28 -0400 date = jQuery.datepicker.parseDate('yy-mm-dd', current); } else { date = jQuery.datepicker.parseDate('mm/dd/yy', current); //legacy support } jQuery(this).datepicker("setDate", date ); } jQuery(this).blur(function() { var val = jQuery(this).val(); if( val == "") { jQuery("#" + targetid).val(""); } }); }); } //deprecated, use data-confirm jQuery(".confirm").livequery('click', function(e) { var inText = jQuery(this).attr("confirm"); if( !inText ) { inText = jQuery(this).data("confirm"); } if(confirm(inText) ) { return; } else { e.preventDefault(); } } ); jQuery(".uibutton").livequery( function() { jQuery(this).button(); } ); jQuery(".fader").livequery( function() { jQuery(this).fadeOut(1600, "linear"); } ); jQuery(".uipanel").livequery( function() { jQuery(this).addClass("ui-widget"); var header = jQuery(this).attr("header"); if(header != undefined) { //http://dev.jquery.it/ticket/9134 jQuery(this).wrapInner('
'); jQuery(this).prepend('
' + header + '
'); } } ); if( jQuery.fn.tablesorter ) { jQuery("#tablesorter").tablesorter(); } jQuery(".ajaxchange select").livequery( function() { var select = jQuery(this); var div = select.parent(".ajaxchange") var url = div.attr("targetpath"); var divid = div.attr("targetdiv"); select.change( function() { var url2 = url + $(this).val(); $("#" + divid).load(url2); } ); } ); jQuery("form.ajaxform").livequery('submit', //Make sure you use $(this).closest("form").trigger("submit") function(e) { e.preventDefault(); var form = jQuery(this); if( form.validate ) { form.validate({ ignore: [".ignore"] }); var isvalidate = form.valid(); if(!isvalidate) { e.preventDefault(); //show message return; } } var targetdiv = form.data("targetdiv"); if(!targetdiv){ targetdiv = form.attr("targetdiv"); } targetdiv = targetdiv.replace(/\//g, "\\/"); // allows for posting to a div in the parent from a fancybox. // closes the fancybox after submitting //Refreshing... if( form.hasClass("showwaiting") ) { var app = jQuery("#application"); var apphome = app.data("home") + app.data("apphome"); $("#" + targetdiv).append(''); } var oemaxlevel = form.data("oemaxlevel"); if( !oemaxlevel) { oemaxlevel= 1; } //TODO: Use closest div and success data form.ajaxSubmit({ target:"#" + targetdiv, error: function(data ) { alert("error"); $("#" + targetdiv).html(data); }, data: { oemaxlevel: oemaxlevel } }); var findmodal = form.closest(".modal"); if( findmodal && findmodal.modal ) { findmodal.modal("hide"); } var reset = form.data("reset") if( reset == true){ form.get(0).reset(); } return false; } ); jQuery("form.autosubmit").livequery( function() { var form = $(this); var targetdiv = form.data('targetdiv'); jQuery("form.autosubmit select").change(function() { jQuery(form).ajaxSubmit( {target:"#" + targetdiv} ); }); jQuery("form.autosubmit input").on("keyup",function() { jQuery(form).ajaxSubmit( {target:"#" + targetdiv} ); }); }); jQuery("form.ajaxautosubmit").livequery( function() { var theform = jQuery(this); theform.find("select").change( function() { theform.submit(); }); }); jQuery(".submitform").livequery("click", function() { var theform = $(this).closest('form'); theform.submit(); }); jQuery("a.emdialog").livequery("click", function(event) { event.stopPropagation(); var dialog = jQuery(this); var hidescrolling = dialog.data("hidescrolling"); var width = dialog.data("width"); if( !width ) { width = "800"; } var id = "modals"; var modaldialog = $( "#" + id ); if( modaldialog.length == 0 ) { $("body").append(''); modaldialog = $("#" + id ); } var link = dialog.attr("href"); var options = dialog.data(); var param = dialog.data("parameterdata"); if( param ) { var element = $("#" + param ); var name = element.prop("name"); options[name] = element.val(); } modaldialog.load(link, options, function() { $(".modal-lg").css("min-width",width + "px" ); //$(".modal-lg").css("min-height",height + "px" ); modaldialog.modal({keyboard: true,backdrop:true, "show":true}); //fix submit button var justok = dialog.data("cancelsubmit"); if( justok != null) { $(".modal-footer #submitbutton",modaldialog).hide(); } else { var id = $("form",modaldialog).attr("id"); $("#submitbutton",modaldialog).attr("form",id); } var title = dialog.attr("title"); if( title == null) { title = dialog.text(); } $(".modal-title",modaldialog).text(title); var hidefooter = dialog.data("hidefooter"); if( hidefooter != null) { $(".modal-footer",modaldialog).hide(); } $('form', modaldialog).find('*').filter(':input:visible:first').focus(); }); event.preventDefault(); return false; }); jQuery('.emrowpicker table td' ).livequery("click", function(event) { event.preventDefault(); var clicked = jQuery(this); var row = clicked.closest("tr"); var existing = row.hasClass("emrowselected"); row.toggleClass("emrowselected"); var id = row.data("id"); var form = $(clicked.closest("form")); $('.emselectedrow',form ).each(function() { if( form.hasClass("emmultivalue" ) ) { var old = $(this).val(); if( old ) { if( existing ) //removing the value { old = old.replace(id, ""); old = old.replace("||", "|"); } else { old = old +"|"+id; } } else { old = id; } $(this).val(old); } else { $(this).val(id); } }); var targetdiv = form.data("targetdiv"); if( (typeof targetdiv) != "undefined" ) { jQuery(form).ajaxSubmit( {target:"#" + targetdiv} ); } else { jQuery(form).trigger("submit"); } if( form.hasClass("autoclose" ) ) { form.closest(".modal").modal("hide"); } }); jQuery('#emselectable table td' ).livequery("click", function(event) { var clicked = jQuery(this); if(clicked.attr("noclick") =="true") { return true; } if( $(event.target).is("input") ) { return true; } var emselectable = clicked.closest("#emselectable"); var row = $(clicked.closest("tr")); var data = row.data(); if ( row.hasClass("thickbox") ) { var href = row.data("href"); openFancybox(href); } else { emselectable.find('table tr' ).each(function(index) { clicked.removeClass("emhighlight"); }); row.addClass('emhighlight'); row.removeClass("emborderhover"); var table = row.closest("table"); var id = row.attr("rowid"); //var url = emselectable.data("clickpath"); var url = table.data("clickpath"); var form = emselectable.find("form"); if( form.length > 0 ) { emselectable.find( '#emselectedrow' ).val(id); emselectable.find( '.emneedselection').each( function() { clicked.removeAttr('disabled'); }); form.submit(); } else if( url != undefined ) { if (url=="") { return true; } var link = url; var post = table.data("viewpostfix"); if( post != undefined ) { link = link + id + post; } else { link = link + id; } if( emselectable.hasClass("showmodal") ) { showmodal(emselectable,link); } else { parent.document.location.href = link; } } else { parent.document.location.href = id; } } } ); showmodal = function(emselecttable,url) { var id = "modals"; var modaldialog = $( "#" + id ); var width = emselecttable.data("dialogwidth"); if( modaldialog.length == 0 ) { $("#emcontainer").append(''); modaldialog = $("#" + id ); } var options = emselecttable.data(); modaldialog.load(url, options, function() { $(".modal-lg").css("min-width",width + "px" ); modaldialog.modal({keyboard: true,backdrop:true, "show":true}); var title = emselecttable.data("dialogtitle"); if( title) { $(".modal-title",modaldialog).text(title); } $('form', modaldialog).find('*').filter(':input:visible:first').focus(); }); } jQuery('#emselectable table tr' ).livequery( function() { jQuery(this).hover( function () { var row = jQuery(this).closest("tr"); var id = jQuery(row).attr("rowid"); if( id != null ) { jQuery(this).addClass("emborderhover"); } }, function () { jQuery(this).removeClass("emborderhover"); } ); }); jQuery("img.framerotator").livequery( function() { jQuery(this).hover( function() { jQuery(this).data("frame", 0); var path = this.sr$('select#speedC').selectmenu({style:'dropdown'});c.split("?")[0]; var intval = setInterval("nextFrame('" + this.id + "', '" + path + "')", 1000); jQuery(this).data("intval", intval); }, function() { var path = this.src.split("?")[0]; this.src = path + '?frame=0'; var intval = jQuery(this).data("intval"); clearInterval(intval); } ); }); jQuery(".jp-play").livequery("click", function(){ // alert("Found a player, setting it up"); var player = jQuery(this).closest(".jp-audio").find(".jp-jplayer"); var url = player.data("url"); var containerid = player.data("container"); var container = jQuery("#" + containerid); player.jPlayer({ ready: function (event) { player.jPlayer("setMedia", { mp3:url }).jPlayer("play"); }, play: function() { // To avoid both jPlayers playing together. player.jPlayer("pauseOthers"); }, swfPath: apphome + '/components/javascript', supplied: "mp3", wmode: "window", cssSelectorAncestor: "#" + containerid }); //player.jPlayer("play"); }); $('.select-dropdown-open').livequery("click",function(){ if ($(this).hasClass('down')) { $(this).removeClass('down'); $(this).addClass('up'); $(this).siblings('.select-dropdown').show(); } else { $(this).removeClass('up'); $(this).addClass('down'); $(this).siblings('.select-dropdown').hide(); } }); $('.select-dropdown li a').livequery("click",function(){ $(this).closest('.select-dropdown').siblings('.select-dropdown-open').removeClass('up'); $(this).closest('.select-dropdown').siblings('.select-dropdown-open').addClass('down'); $(this).closest('.select-dropdown').hide(); //console.log("Clicked"); }); function select2formatResult(emdata) { /* var element = $(this.element); var showicon = element.data("showicon"); if( showicon ) { var type = element.data("searchtype"); var html = "" + emdata.name; return html; } else { return emdata.name; } */ return emdata.name; } function select2Selected(selectedoption) { //"#list-" + foreignkeyid // var id = container.closest(".select2-container").attr("id"); // id = "list-" + id.substring(5); //remove sid2_ // container.closest("form").find("#" + id ).val(emdata.id); return selectedoption.name || selectedoption.text; } jQuery(".suggestsearchinput").livequery( function() { var theinput = jQuery(this); if( theinput && theinput.autocomplete ) { theinput.autocomplete({ source: apphome + '/components/autocomplete/assetsuggestions.txt', select: function(event, ui) { //set input that's just for display purposes theinput.val(ui.item.value); $("#search_form").submit(); return false; } }); } //console.log(theinput); if( theinput.data("quicksearched") == true ) { var strLength = theinput.val().length * 2; theinput.focus(); theinput[0].setSelectionRange(strLength, strLength); } }); jQuery("input.defaulttext").livequery("click", function() { var theinput = $(this); var startingtext = theinput.data('startingtext'); if( theinput.val() == startingtext ) { theinput.val(""); } }); jQuery("select.listtags").livequery( function() { var theinput = jQuery(this); var searchtype = theinput.data('searchtype'); var searchfield = theinput.data('searchfield'); var catalogid = theinput.data('listcatalogid'); var sortby = theinput.data('sortby'); var defaulttext = theinput.data('showdefault'); if( !defaulttext ) { defaulttext = "Search"; } var url = apphome + "/components/xml/types/autocomplete/tagsearch.txt?catalogid=" + catalogid + "&field=" + searchfield + "&operation=contains&searchtype=" + searchtype; theinput.select2({ tags: true, placeholder : defaulttext, allowClear: true, selectOnBlur: true, delay: 250, minimumInputLength : 1, ajax : { // instead of writing the function to execute the request we use Select2's convenient helper url : url, dataType : 'json', data : function(params) { var search = { page_limit : 15, page: params.page }; search[searchfield+ ".value"] = params.term; //search term search["sortby"] = sortby; //search term return search; }, processResults: function(data, params) { // parse the results into the format expected by Select2. params.page = params.page || 1; return { results: data.rows, pagination: { more: false //(params.page * 30) < data.total_count } }; } }, escapeMarkup: function(m) { return m; }, templateResult : select2formatResult, templateSelection : select2Selected, tokenSeparators: ["|"], separator: '|' }).change(function() { if( $(this).parents(".ignore").length == 0 ) { $(this).valid(); } }); //is this still needed? }); jQuery("input.grabfocus").livequery( function() { var theinput = jQuery(this); theinput.css("color","#666"); if( theinput.val() == "" ) { var newval = theinput.data("initialtext"); theinput.val( newval); } theinput.click(function() { theinput.css("color","#000"); var initial = theinput.data("initialtext"); //console.log(initial,theinput.val()); if( theinput.val() === initial) { theinput.val(''); theinput.unbind('click'); } }); theinput.focus(); }); $(".emtabs").livequery( function() { var tabs = $(this); var tabcontent = $("#" + tabs.data("targetdiv")); //active the right tab var hash = window.location.hash; if( hash ) { var activelink = $(hash,tabs); if( activelink.length == 0) { hash = false; } } if( !hash ) { hash = "#" + tabs.data("defaulttab"); } var activelink = $(hash,tabs); var loadedpanel = $(hash + "panel",tabcontent); if( loadedpanel.length == 0) { loadedpanel = $("#loadedpanel",tabcontent); loadedpanel.attr("id",activelink.attr("id") + "panel"); activelink.data("tabloaded",true); } activelink.parent("li").addClass("emtabselected"); activelink.data("loadpageonce",false); $("a:first-child",tabs).on("click", function (e) { e.preventDefault(); var link = $(this); // activated tab $("li",tabs).removeClass("emtabselected"); link.parent("li").addClass("emtabselected"); var id = link.attr("id"); var url = link.attr("href"); var panelid = id + "panel"; var tab = $( "#" + panelid); if( tab.length == 0) { tab = tabcontent.append('
'); tab = $( "#" + panelid); } var reloadpage = link.data("loadpageonce"); var alwaysreloadpage = link.data("alwaysreloadpage"); if( reloadpage || alwaysreloadpage ) { if( window.location.href.endsWith( url ) ) { window.location.reload(); } else { window.location.href = url; } } else { url = url + "#" + id; var loaded = link.data("tabloaded"); if( link.data("allwaysloadpage") ) { loaded = false; } if( !loaded ) { var levels = link.data("layouts"); if( !levels) { levels = "1"; } jQuery.get(url , {oemaxlevel:levels}, function(data) { tab.html(data); link.data("tabloaded",true); $(">.tab-pane",tabcontent).hide(); tab.show(); $(window).trigger( "resize" ); }); } else { $(">.tab-pane",tabcontent).hide(); tab.show(); $(window).trigger( "resize" ); } } }); }); jQuery(".closetab").livequery('click', function(e) { e.preventDefault(); var tab = $(this); var nextpage = tab.data("closetab"); jQuery.get(nextpage, {oemaxlayout:1}, function(data) { var prevtab = tab.closest('li').prev(); prevtab.find('a').click(); if (prevtab.hasClass('firstab')) { tab.closest('li').remove(); } }); return false; } ); jQuery(".collectionclose").livequery('click', function(e) { e.preventDefault(); var collection = $(this); var nextpage = collection.data("closecollection"); jQuery.get(nextpage, {oemaxlayout:1}, function(data) { collection.closest('li').remove(); }); return false; } ); jQuery("select.listautocomplete").livequery(function() //select2 { var theinput = $(this); var searchtype = theinput.data('searchtype'); if (searchtype != undefined) // called twice due to // the way it reinserts // components { var searchfield = theinput.data('searchfield'); var catalogid = theinput.data('listcatalogid'); var foreignkeyid = theinput.data('foreignkeyid'); var sortby = theinput.data('sortby'); var defaulttext = theinput.data('showdefault'); if (!defaulttext) { defaulttext = "Search"; } var defaultvalue = theinput.data('defaultvalue'); var defaultvalueid = theinput .data('defaultvalueid'); var url = apphome + "/components/xml/types/autocomplete/datasearch.txt?catalogid=" + catalogid + "&field=" + searchfield + "&operation=contains&searchtype=" + searchtype; if (defaultvalue != undefined) { url = url + "&defaultvalue=" + defaultvalue + "&defaultvalueid=" + defaultvalueid; } var dropdownParent = $("body"); var parent = theinput.closest(".modal-content"); //var parent = theinput.parent(); if (parent.length) { dropdownParent = parent; // console.log("found modal parent"); } else { // console.log("use body parent"); } // var value = theinput.val(); var allowClear = theinput.data('allowclear'); if (allowClear == undefined) { allowClear = true; } theinput .select2({ theme : "classic", placeholder : defaulttext, allowClear : allowClear, minimumInputLength : 0, dropdownParent : dropdownParent, ajax : { // instead of writing the // function to execute the // request we use Select2's // convenient helper url : url, dataType : 'json', data : function(params) { var fkv = theinput.closest( "form").find( "#list-" + foreignkeyid + "value") .val(); if (fkv == undefined) { fkv = theinput .closest("form") .find( "#list-" + foreignkeyid) .val(); } var search = { page_limit : 15, page : params.page }; search[searchfield + ".value"] = params.term; // search // term if (fkv) { search["field"] = foreignkeyid; // search // term search["operation"] = "matches"; // search // term search[foreignkeyid + ".value"] = fkv; // search // term } if (sortby) { search["sortby"] = sortby; // search // term } return search; }, processResults : function(data, params) { // parse the // results into // the format // expected by // Select2. var rows = data.rows; if (theinput .hasClass("selectaddnew")) { if (params.page == 1 || !params.page) { var addnewlabel = theinput .data('addnewlabel'); var addnewdata = { name : addnewlabel, id : "_addnew_" }; rows .unshift(addnewdata); } } // addnew params.page = params.page || 1; return { results : rows, pagination : { more : false // (params.page * 30) < // data.total_count } }; } }, escapeMarkup : function(m) { return m; }, templateResult : select2formatResult, templateSelection : select2Selected }); // TODO: Remove this? theinput.on("change", function(e) { if (e.val == "") // Work around for a bug // with the select2 code { var id = "#list-" + theinput.attr("id"); $(id).val(""); } else { // Check for "_addnew_" show ajax form var selectedid = theinput.val(); if (selectedid == "_addnew_") { var clicklink = $("#" + theinput.attr("id") + "add"); clicklink.trigger("click"); e.preventDefault(); theinput.select2("val", ""); return false; } // Check for "_addnew_" show ajax form if (theinput.hasClass("selectautosubmit")) { if (selectedid) { //var theform = $(this).closest("form"); var theform =$(this).parents("form") if (theform.hasClass("autosubmitform")) { theform.trigger("submit"); } } } } }); } }); if( jQuery.fn.minicolors ) { $(".color-picker").minicolors({ defaultValue: '', letterCase: 'uppercase' }); } jQuery(".sidebarsubmenu").livequery("click", function(e){ e.stopPropagation(); }); jQuery("#mainimageholder").livequery( function(e) { // Zooming code, only makes sense to run this when we // actually have the DOM if ($(this).position() == undefined) { // check if the // element isn't // there (best // practice // is...?) return; } var clickspot; var imageposition; var zoom = 30; var mainholder = $(this); var mainimage = $("#mainimage", mainholder); mainimage.width(mainholder.width()); $(window) .bind( 'mousewheel DOMMouseScroll', function(event) { var mainimage = $("#mainimage"); if ($("#hiddenoverlay").css( "display") == "none") { return true; } if (event.originalEvent.wheelDelta > 0 || event.originalEvent.detail < 0) { // scroll up var w = mainimage.width(); mainimage.width(w + zoom); var left = mainimage.position().left - zoom / 2; mainimage.css({ "left" : left + "px" }); return false; } else { // scroll down var w = mainimage.width(); if (w>100) { mainimage.width(w - zoom); var left = mainimage.position().left + zoom / 2; mainimage.css({ "left" : left + "px" }); } return false; } }); mainimage.on("mousedown", function(event) { console.log($(event.target)); if ($(event.target).is(".zoomable")) { clickspot = event; imageposition = mainimage.position(); } return false; }); mainimage.on("mouseup", function(event) { clickspot = false; var mainimage = $("#mainimage"); mainimage.removeClass('imagezooming'); return false; }); $(document).on("contextmenu", function(event){ clickspot = false; }); mainimage.on("mousemove", function(event) { // if( isMouseDown() ) if (clickspot) { console.log(clickspot.pageX); var changetop = clickspot.pageY - event.pageY; var changeleft = clickspot.pageX - event.pageX; var left = imageposition.left - changeleft; var top = imageposition.top - changetop; var mainimage = $("#mainimage"); mainimage.css({ "left" : left + "px", "top" : top + "px" }); mainimage.addClass('imagezooming'); } }); }); document.addEventListener('touchstart', function(e) { var touch = e.touches[0]; var div = $(e.target) div.data("touchstartx",touch.pageX); div.data("touchstarty",touch.pageY); }); document.addEventListener('touchend', function(e) { var touch = e.touches[0]; var div = $(e.target) div.removeData("touchstartx"); div.removeData("touchstarty"); }); document.addEventListener('touchmove', function(e) { var touch = e.touches[0]; var div = $(e.target); var startingx = div.data("touchstartx"); var startingy = div.data("touchstarty"); var diffx = touch.pageX - startingx; var diffy = touch.pageY - startingy; var swipe = false; if( Math.abs(diffx) > Math.abs(diffy) ) { var change = Math.abs(diffx) / div.width(); if( change > .2 ) { if(diffx > 0 ) { swipe = "swiperight"; } else { swipe = "swipeleft"; } } } else { //do swipeup and swipedown var change = Math.abs(diffy) / div.height(); if( change > .2 ) { if(diffy > 0 ) { swipe = "swipedown"; } else { swipe = "swipeup"; } } } if( swipe ) { //console.log(div); var event = {}; event.originalEvent = e; event.preventDefault = function() {}; //TODO: Find out why I can't trigger on $(e.target).trigger it ignores us $("#" + div.attr("id") ).trigger(swipe); } }, false); } jQuery(document).ready(function() { var resizecss = function() { //Old stuff? /* w1 = ( $('#main').width() - $('#left-col').width() - 41 ); $('#right-col .liquid-sizer').width(w1); w2 = ( $('#data').width() - 40 ); $('#asset-data').width(w2); */ var body = $("body"); //TODO: use bootrap css? body.removeClass("widthless100").removeClass("widthless500").removeClass("widthless1000"); var width = $(window).width(); if( width < 100 ) { body.addClass("widthless100"); } else if( width < 500 ) { body.addClass("widthless500"); } else if( width < 1000 ) { body.addClass("widthless1000"); } var height = $(window).height(); $(".autoheightless40").height(height - 40) }; $(window).on('resize', resizecss ); resizecss(); uiload(); });