var DEV = false; var QA = false; var DEATHSTAR = 0; var BASE_DOMAIN = 'simplebooklet.com'; // Override console.log to suppress output in production. if (!DEV && !QA){ if (typeof(console) === 'object'){ console.log = function(){}; } else { console = {"log":function(){}}; } } // ************************************************************************************************************************************************ // NOTE: this file is parsed by php therefore there is php logic in here... // ************************************************************************************************************************************************ var DEV = parseInt(''); var DEATHSTAR = parseInt('0'); var BASE_DOMAIN = 'simplebooklet.com'; var HOME_KEY = 'zdBUWBx25SxJSo4DFLDlrQ'; var LOGIN_SUCCESS_KEY = 'zlflILCTf7ytRV08DJ2uvx'; var LOGIN_PLUS_SUCCESS_KEY = '2BFt6if4cP2mibOjRlcW7t'; var LOGIN_TEACHER_SUCCESS_KEY = 'xpZ0xXyFEsApkZKSC3Ekoz'; var LOGIN_TEAM_SUCCESS_KEY = 'ZTUjPZfryqJbwqzuDv4xXe'; var LOGIN_STUDENT_SUCCESS_KEY = 'UKXP5p4Ffbrn5PHvwUI6h9'; var FEATURED_KEYS = [HOME_KEY, LOGIN_SUCCESS_KEY, LOGIN_PLUS_SUCCESS_KEY,LOGIN_TEAM_SUCCESS_KEY, LOGIN_TEACHER_SUCCESS_KEY, LOGIN_STUDENT_SUCCESS_KEY]; var SESSION_LIFETIME = '14400'; var WP_MIN_WIDTH = "100"; var WP_MIN_HEIGHT = "50"; var WP_MAX_WIDTH = "3000"; var WP_MAX_HEIGHT = "6000"; var THUMB_SERVER_DOMAIN = 'middlespot.com'; var THUMB_SERVER_SUBDOMAIN = 'img'; var THUMB_SERVER_URI = '/getthumbnail.php'; var IS_IMAGE_SERVER = parseInt('0'); // currently NOT hacked to start with img8 as first server (rather than img0) to skip the liquid server var NUM_SERVERS = parseInt('1'); var NUM_IMAGES_PER_SERVER = parseInt('2'); var SKIP_SERVERS = parseInt('3'); var WORKPAD_SERVER_NUM = parseInt('0'); // defines image server number (1,2,...) to use. if 0 then any server, as defined by NUM_SERVERS, is used var BOOKLET = "book"; var LIVE = ""; var MODE_LABEL = "booklet"; var BOOKLET_LABEL = "simple"; //nh 2015-11-25 now first ad is on 3rd page followed by every 7 pages afterwards var AD_FIRST_OCCURENCE = "3"; var AD_FREQUENCY = "10"; var ACCOUNT_LABEL = $.parseJSON("{\"0\":\"Free\",\"1\":\"Plus\",\"2\":\"Teacher\",\"3\":\"Pro\",\"4\":\"Plus (Wix)\",\"5\":\"Student\",\"11\":\"Plus (Monthly)\"}"); var ACCOUNT_RENEWAL_LEAD_DAYS = "30"; var BOOKLET_TRIAL_DAYS = parseInt('365'); var DELETE_REMOVAL_DAYS = parseInt('90'); var currentDate = new Date(); var currentTime = currentDate.getTime(); // used for creating unique image urls to avoid browser cache. //alert(currentTime); var rdpResults = new Array(); var workpad_url = "workpad.php"; var validateEmail = /^([A-Za-z0-9\.\!\#\$\%\&\'\*\+\-\/\=\?\^\_\`\{\|\}\~])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/; var twitterRefreshIntervalId; var IOS = ''; var IPAD = ''; var MOBILE = ''; var ANDROID = ''; var BLACKBERRY = ''; var TABLET = ''; var HANDHELD = ''; var IPHONE = ''; var FB_APP_ID = '341981852533773'; var FB_WALL_APP_ID = '341981852533773'; var WIMPY_REG_CODE = 'Mm8xaiUyOHY5NG0lN0RGSSUzRGlGTUUlMjklMkFMJTNCV091RSUyQSUyNnZMJTJGWXZjZ052'; var popup_history = new Array(); var isOpera = !!(window.opera && window.opera.version); // Opera 8.0+ var isFirefox = testCSS('MozBoxSizing'); // FF 0.8+ var isSafari = Object.prototype.toString.call(window.HTMLElement).indexOf('Constructor') > 0; // At least Safari 3+: "[object HTMLElementConstructor]" var isChrome = !isSafari && testCSS('WebkitTransform'); // Chrome 1+ var isIE = /*@cc_on!@*/false || testCSS('msTransform'); // At least IE6 function testCSS(prop) { return prop in document.documentElement.style; } resultNum = 0; // get the thumbnail image url based on the website's url, the desired with of the image, and the result number to define which server to go to. // optionally the workpad flag tells the image server this is a workpad image and should be pulled from the workpad image cache, if possible. // optionally the refresh flag if set to true forces the image to be re-rendered from and not pulled from cache. function getThumbnailSrc (url, width, workpad, refresh) { if (url){ var searchType = parseQueryString('searchType'); var noCacheString = (refresh) ? "&noCache=1" : ""; var workpadString = (workpad) ? "&workpad=1" : ""; var serverNum = (workpad && WORKPAD_SERVER_NUM) ? WORKPAD_SERVER_NUM : resultNum++ % NUM_SERVERS + 1 + SKIP_SERVERS; var imageNum = parseInt(resultNum / NUM_SERVERS) % NUM_IMAGES_PER_SERVER; var serverNumStr = (serverNum < 10) ? "0"+serverNum : serverNum; var subdomain = THUMB_SERVER_SUBDOMAIN+serverNumStr; var hostname = 'img.'+THUMB_SERVER_DOMAIN; // most url characeters we want to have escaped but ampersands converted to & need to be converted back. var imgSrc = "http://"+hostname+THUMB_SERVER_URI+"?w="+getImageWidth(width)+"&searchType="+searchType+noCacheString+workpadString+"&url="+escape(url.replace('&','&'))+"#"+currentTime; return imgSrc; } else { return ''; } // end: if } // end: getThumbnailSrc // return the value from imageWidths array that is the next biggest from w, or the biggest entry in imageWidths. // assumes imageWidths is sorted from smallest to largest. function getImageWidth(w) { var imageWidths = new Array (160,320,640,800,1024); for (var i in imageWidths){ if (imageWidths[i] > w){ return imageWidths[i]; } // end: if } // end: for return imageWidths[imageWidths.length-1]; } // end: if // There are for the javascript for the popup windows function HideDIV(d, callback) { var selector = (typeof d == 'string') ? "#"+d : ((typeof d == 'object') ? d : ".popupOpen, .reveal-modal.open"); $(selector).each(function(){ if ($(this).hasClass('reveal-modal')){ $(this).trigger('reveal:close'); } else { $(this) .removeClass('popupOpen') .fadeOut(callback); } }); // clear the popup history popup_history= new Array(); } // if 'force' parameter is an object the parameters of the object will be passed as POST data to the popup. function DisplayDIV(d,noHide, no_history, closed, force) { // d (the intended div id of the modal) is an object then assume this is an existing jquery object // pointing to the modal and extract the id attribute from the modal and use that instead. if (typeof d == 'object') d = d.attr('id'); if (!d) return; if(!noHide) { $(".popupOpen,.animating").each(function(){ var $this = $(this); $this.css("display","none").removeClass('popupOpen'); if (!no_history){ popup_history.push($this.attr('id')); //alert("new: "+d+", old: "+$this.attr('id')+", num: "+popup_history.length); //$this.css("display","none"); $this.hide(); } }); } if (loadPopup(d, force, true)){ $popup = $("#"+d); // automatically initialize any input fields in the popup that have a field name // that matches a workpad attribute, as long as that input field does not have an existing value. $popup.find('input,textarea').each(function(){ var $this = $(this); var name = $this.attr('name'); if (!$this.hasClass('novalue') && typeof W != 'undefined' && W[name]) if ($this.is(':checkbox')) $this.prop('checked', (W[name] == '1')); else if (!$this.val()) $this.val(W[name]); }); // suppress normal popup behaviour for any div having the data-reveal-id attribute set as it should be handled by Foundation. if (!$popup.hasClass('reveal-modal')){ // KK [2014-01-21]: Some modals (like the CTAs in publish.php) still need this code. // add/replace popup close button with standard button toolset $popup.find('img.metrobarexit:not(.closecolorpicker)').closest('div').remove(); if ($popup.find("div.popup_buttons").length == 0) $popup.prepend( '' ); $popup.addClass('popupOpen').fadeIn(); } else { $popup.find('.close-reveal-modal:not(.keep)').remove(); if (!$popup.hasClass('noclose')) $popup.append("×"); $popup.reveal({closed : closed}); } // end: if } // end: if // Warning Duplicate IDs //console.clear(); if (DEV){ $('[id]').each(function(){ var ids = $('[id="'+this.id+'"]'); if(ids.length>1 && ids[0]==this) console.warn('Multiple IDs ('+ids.length+') #'+this.id); }); } return $popup; } // end: DisplayDIV /** * loadPopup : loads a popup modal from the /popups/ directory having filename /popups/popup_{id}.php, via the /popups.php script. * if 'force' parameter is an object the parameters of the object will be passed as POST data to the popup. * * returns the jquery object for the popup modal. */ function loadPopup (id, force, forDisplay, callback){ if (force) $("#"+id).remove(); if (! $("#"+id).length){ var workpad_id = typeof W != 'undefined' ? W['id'] : null; var page = typeof $global != 'undefined' ? $global.currentPage : null; var workpad_entry_id = $(".resultDiv.clicked").length = 1 ? $(".resultDiv.clicked").data('id') : null; var data = { id : id, workpad_id : workpad_id, page : page, workpad_entry_id : workpad_entry_id }; if (typeof force == 'object') for (var i in force) data[i] = force[i]; $.ajax({ url : "/popups.php", type : "POST", data : data, success : function(data){ $("body").append($(data)); if (typeof set_rdp_vars != 'undefined') set_rdp_vars(); if (typeof callback === 'function') callback(id, data); }, error : (typeof ajaxError === 'function') ? ajaxError : null, // beforeSend: (forDisplay && typeof ajaxComplete === 'function') ? ajaxBefore : null, // shows 'loading' indicator while loading popup complete: (typeof ajaxComplete === 'function') ? ajaxComplete : null, async: false // CRAP!!! this is deprecated in jquery. we will need to revisit making ajax calls asynchronous but right now that is a BIG LIFT! [KK: Dec 7th, 2015] }); // enable modal draggin, but prevent modal dragging for any that have a .nodrag class, and disable dragging for specific // child elements of any that may need to be interacted with the mouse pointer. if (typeof $("#"+id).draggable != 'undefined') $("#"+id+":not(.nodrag,.reveal-modal)").draggable({ cancel : '.dd-options, input, textarea, select, .popup_buttons, .tab, .metrobartools' }); if (typeof setAccountFeatures != 'undefined') setAccountFeatures(); } else { // populate variables and invoke callback even if modal is already loaded in memory. if (typeof set_rdp_vars != 'undefined') set_rdp_vars(); if (typeof callback === 'function') callback(id, data); } if ($("#"+id).length){ if (typeof $global != 'undefined' && $global.login && $global.login.accountType >= 1){ $(".hidePlus", "#"+id).css('opacity', '.4'); } else { $(".hidePlus", "#"+id).css('opacity', '1'); } } return $("#"+id); } // end: loadPopup function displayDivTab(pid, tab){ if (!pid) return; loadPopup(pid, true); if (tab){ $('#'+pid).find('dd,li').removeClass('active'); // close any open tabs. // activate the tab to open $('#'+pid).find("a[href=#"+tab+"]").closest('dd').addClass('active'); // activate the tab's contents $('#'+tab+'Tab').addClass('active').find('dd').first().addClass('active'); $('#'+tab+'Tab').addClass('active').find('li').first().addClass('active'); } DisplayDIV(pid); } function displayAccount(tab) { displayDivTab('modalaccountbox', tab); } function set_filestyle(){ // $("input.file_1").not('.filestyle').addClass('filestyle').filestyle({ // image: "/img/browse-button.png", // imageheight : 36, // imagewidth : 121, // width : 300 // }); } function isNumber(n) { return !isNaN(parseFloat(n)) && isFinite(n); } function parseQueryString( name ) { var url = window.location.href; url = url.replace(/\%23/,'#'); url = url.replace(/(\#.*)\%3d/, "$1="); name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]"); var regexS = "[\\?&\\#\\!]"+name+"=([^&#]*)"; var regex = new RegExp( regexS ); var results = regex.exec( url ); if( results == null ) return ""; else return results[1]; } // end: parseQueryString // jquery css will return some color values in rgb(aaa,bbb,ccc) mode, this will convert them to #aabbcc; function rgb2hex(cssColor) { function hex(x) { return ("0" + parseInt(x).toString(16)).slice(-2); } if (cssColor){ rgb = cssColor.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/); if (rgb){ return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]); } else { return cssColor; } // end: if } else { return ''; } } // end: rgb2hex function ajaxError(XMLHttpRequest, textStatus, errorThrown){ hideLoading(); // alert("ajaxError: text="+textStatus+", error="+errorThrown); if (DEV) console.log(XMLHttpRequest.responseText); } // end: ajaxError function ajaxBefore(xhr){ //console.log("ajaxBefore"); //alert('rdp_utils.js->ajaxBefore() showing Loading'); showLoading("working on it..."); } function ajaxComplete( xhr ){ //console.log("ajaxComplete"); var success = true; if (xhr && xhr.responseXML) success = !checkXmlError(xhr.responseXML); hideLoading(); //alert('rdp_utils.js->ajaxComplete() hid Loading'); return success; } // display error modal if an error tag (some err msg) is found in the xml response. // return true if there is an error, false otherwise. function checkXmlError(xmlResponse, noHide){ var $xml = $(xmlResponse); var $error = $xml.find('error'); if ($error && $error.text().length > 1){ // alert("error="+$error.get(0).nodeValue); DisplayDIV('messagePopup', noHide); $('#messagePopupContent').html($error.text()); return true; } return false; } function checkXmlFormError(xmlResponse){ var $xml = $(xmlResponse); var $error = $xml.find('formerror'); var $errorText = null; if ($error && $error.text().length > 0){ //alert($error.text()); $errorText = $error.text(); $xml.remove('formerror'); //return $errorText; return true; } return false; } function showLoading(message, match_id){ // suppress loading message if we're generating a screencapture if (typeof $global != 'undefined' && typeof $global.imageMode != 'undefined' && $global.imageMode) return; //NH 2015-10-14 the ! syntax seemed to be failing if (parseInt($("#loadingImg").length) == 0) $(document.body).append("


working on it...
"); if (message) $("#loadingImg").find('span').html(message); if (typeof $global != 'undefined' && !$global.embed) //NH 2015-10-14 changed to window height b/cs some docs are long so you weren't seeing the msg //$('#loadingImg').height($(document).height()).show(); $('#loadingImg').height($(window).height()).show(); else $('#loadingImg').show(); if (match_id) $('#loadingImg').data('match_id',match_id); } // hide the loading lightbox and restore the message to it's default function hideLoading(match_id){ var $loading = $("#loadingImg"); if (!$loading.data('match_id') || $loading.data('match_id') == match_id) $loading.hide().data('match_id','').find('span').html("working on it..."); } function set_rdp_vars(caller_id) { if (typeof W == 'undefined') return; // set all rdp_var content using loaded workpad data $('.rdp_var').each(function(){ var $this=$(this); if ($this.attr('field') && W[$this.attr('field')] != undefined) $this.text(W[$this.attr('field')]); }); } function is_upgraded(){ if (typeof $global !== 'undefined') if (typeof $global.login !== 'undefined') if (parseInt($global.login.accountType) > 0) return true; //NH 2015-12-01 emergency fix for monthly paypal accounts if (typeof W !== 'undefined') { if (typeof W['plus'] !== 'undefined') if (W['plus'] > 0) return true; if (typeof W['expiration_days'] !== 'undefined') if (W['expiration_days'] > 0) return true; } return false; } //Ken Kwasnicki's generic jQuery utility methods //add $.visible function to make the css visbility property 'visible' for the selected object (function( $ ){ $.fn.visible = function() { this.css('visibility', 'visible'); return this; };})( jQuery ); //add $.hidden function to make the css visbility property 'hidden' for the selected object (function( $ ){ $.fn.hidden = function() { this.css('visibility', 'hidden'); return this;};})( jQuery ); //css 'left' setter if val is defined, or getter if val is not. (function( $ ){ $.fn.left = function(val) { if(val != null){ this.css('left',val+'px'); return this; } else { return parseInt(this.css('left')); } };})( jQuery ); //css 'top' setter if val is defined, or getter if val is not. (function( $ ){ $.fn.top = function(val) { if(val != null){ this.css('top',val+'px'); return this; } else { return parseInt(this.css('top')); } };})( jQuery ); $.fn.serializeObject = function() { var o = {}; var a = this.serializeArray(); $.each(a, function() { if (o[this.name] !== undefined) { if (!o[this.name].push) { o[this.name] = [o[this.name]]; } o[this.name].push(this.value || ''); } else { o[this.name] = this.value || ''; } }); return o; }; // implement a generic select_button handler to enable select buttons to work // like radio buttons having the same name attribute. // the data value associated with the button (value attribute) will be // transfered to a hidden form element having the same name. $(document).on('click', ".select_button", function(){ // alert($(this).attr('size')); var $this = $(this); var $form = $this.closest('form'); var name = $this.data('name'); $form.find(".select_button[data-name="+name+"]").removeClass('selected'); $this.addClass('selected'); var $input_field = $form.find("input[name="+name+"]").length ? $form.find("input[name="+name+"]") : $("").appendTo($form); $input_field.val($this.data('value')).trigger('change'); if ($this.hasClass('autonext')) $form.find('.next').trigger('click'); return false; }); $(document).on('click', ".select_button_container", function(){ $(this).find('.select_button').trigger('click'); return false; }); function displayMessage(message){ DisplayDIV('messagePopup'); $('#messagePopupContent').html(message); } function displayConfirm(message, okFunction, cancelFunction){ $popup = loadPopup('messageConfirm', true); $('#messageConfirmContent').html(message); $('.button.ok',$popup).click(function(){ if (typeof okFunction ==='function') okFunction(); HideDIV(); }); $('.button.cancel',$popup).click(function(){ if (typeof cancelFunction ==='function') cancelFunction(); HideDIV(); }); DisplayDIV('messageConfirm'); } $(document).on('click', '.close-reveal-modal, .custom-reveal-close', function(){ $(this).closest('.reveal-modal').trigger('reveal:close').trigger('close').trigger('closed'); console.log("trying to close. modal="+$(this).closest('.reveal-modal').prop('id')); }); ;(function ($, window, undefined){ 'use strict'; $.fn.foundationAccordion = function (options) { var $accordion = $('.accordion'); if ($accordion.hasClass('hover') && !Modernizr.touch) { $('.accordion li', this).on({ mouseenter : function () { console.log('due'); var p = $(this).parent(), flyout = $(this).children('.content').first(); $('.content', p).not(flyout).slideUp('fast').parent('li').removeClass('active'); //changed this flyout.slideDown('fast', function () { flyout.parent('li').addClass('active'); }); } }); } else { $('.accordion li .title', this).on('click.fndtn', function () { var p = $(this).closest('.accordion'); var flyout = $(this).closest('li').find('.content').first(); var wasActive = flyout.parent('li').hasClass('active'); $('.content', p).slideUp('fast').parent('li').removeClass('active'); //changed this if (!wasActive) flyout.slideDown('fast', function () { flyout.parent('li').addClass('active'); }); }); } }; })( jQuery, this ); ;(function ($, window, undefined) { 'use strict'; $.fn.foundationAlerts = function (options) { var settings = $.extend({ callback: $.noop }, options); $(document).on("click", ".alert-box a.close", function (e) { e.preventDefault(); $(this).closest(".alert-box").fadeOut(function () { $(this).remove(); // Do something else after the alert closes settings.callback(); }); }); }; })(jQuery, this); ;(function ($, window, undefined) { 'use strict'; $.fn.foundationButtons = function (options) { var $doc = $(document), config = $.extend({ dropdownAsToggle:true, activeClass:'active' }, options), // close all dropdowns except for the dropdown passed closeDropdowns = function (dropdown) { $('.button.dropdown').find('ul').not(dropdown).removeClass('show-dropdown'); }, // reset all toggle states except for the button passed resetToggles = function (button) { var buttons = $('.button.dropdown').not(button); buttons.add($('> span.' + config.activeClass, buttons)).removeClass(config.activeClass); }; // Prevent event propagation on disabled buttons $doc.on('click.fndtn', '.button.disabled', function (e) { e.preventDefault(); }); $('.button.dropdown > ul', this).addClass('no-hover'); // reset other active states $doc.on('click.fndtn', '.button.dropdown:not(.split), .button.dropdown.split span', function (e) { var $el = $(this), button = $el.closest('.button.dropdown'), dropdown = $('> ul', button); e.preventDefault(); // close other dropdowns closeDropdowns(config.dropdownAsToggle ? dropdown : ''); dropdown.toggleClass('show-dropdown'); if (config.dropdownAsToggle) { resetToggles(button); $el.toggleClass(config.activeClass); } }); // close all dropdowns and deactivate all buttons $doc.on('click.fndtn', 'body, html', function (e) { // check original target instead of stopping event propagation to play nice with other events // KK [2013-12-17]: for some reason e.originalEvent is sometimes not defined, so suppress errors by checking if (typeof e !== 'undefined' && typeof e.originalEvent !== 'undefined') if (!$(e.originalEvent.target).is('.button.dropdown:not(.split), .button.dropdown.split span')) { closeDropdowns(); if (config.dropdownAsToggle) { resetToggles(); } } }); // Positioning the Flyout List var normalButtonHeight = $('.button.dropdown:not(.large):not(.small):not(.tiny)', this).outerHeight() - 1, largeButtonHeight = $('.button.large.dropdown', this).outerHeight() - 1, smallButtonHeight = $('.button.small.dropdown', this).outerHeight() - 1, tinyButtonHeight = $('.button.tiny.dropdown', this).outerHeight() - 1; $('.button.dropdown:not(.large):not(.small):not(.tiny) > ul', this).css('top', normalButtonHeight); $('.button.dropdown.large > ul', this).css('top', largeButtonHeight); $('.button.dropdown.small > ul', this).css('top', smallButtonHeight); $('.button.dropdown.tiny > ul', this).css('top', tinyButtonHeight); $('.button.dropdown.up:not(.large):not(.small):not(.tiny) > ul', this).css('top', 'auto').css('bottom', normalButtonHeight - 2); $('.button.dropdown.up.large > ul', this).css('top', 'auto').css('bottom', largeButtonHeight - 2); $('.button.dropdown.up.small > ul', this).css('top', 'auto').css('bottom', smallButtonHeight - 2); $('.button.dropdown.up.tiny > ul', this).css('top', 'auto').css('bottom', tinyButtonHeight - 2); }; })( jQuery, this ); /* * jQuery Foundation Clearing 1.0 * http://foundation.zurb.com * Copyright 2012, ZURB * Free to use under the MIT license. * http://www.opensource.org/licenses/mit-license.php */ /*jslint unparam: true, browser: true, indent: 2 */ ;(function ($, window, undefined) { 'use strict'; var defaults = { templates : { viewing : '×' + '' }, locked : false }, superMethods = {}, methods = { init : function (options, extendMethods) { return this.find('ul[data-clearing]').each(function () { var doc = $(document), $el = $(this), options = options || {}, extendMethods = extendMethods || {}, settings = $el.data('fndtn.clearing.settings'); if (!settings) { options.$parent = $el.parent(); $el.data('fndtn.clearing.settings', $.extend({}, defaults, options)); // developer goodness experiment methods.extend(methods, extendMethods); // if the gallery hasn't been built yet...build it methods.assemble($el.find('li')); methods.events(); } }); }, events : function () { var doc = $(document); doc.on('click.fndtn.clearing', 'ul[data-clearing] li', function (e, current, target) { var current = current || $(this), target = target || current; e.preventDefault(); // set current and target to the clicked li if not otherwise defined. methods.open($(e.target), current, target); methods.update_paddles(target); }); $(window).on('resize.fndtn.clearing', function () { var image = $('.clearing-blackout .visible-img').find('img'); if (image.length > 0) { methods.center(image); } }); doc.on('click.fndtn.clearing', '.clearing-main-right', function (e) { var clearing = $('.clearing-blackout').find('ul[data-clearing]'); e.preventDefault(); methods.go(clearing, 'next'); }); doc.on('click.fndtn.clearing', '.clearing-main-left', function (e) { var clearing = $('.clearing-blackout').find('ul[data-clearing]'); e.preventDefault(); methods.go(clearing, 'prev'); }); doc.on('click.fndtn.clearing', 'a.clearing-close, div.clearing-blackout', function (e) { var root = (function (target) { if (/blackout/.test(target.selector)) { return target; } else { return target.closest('.clearing-blackout'); } }($(this))), container, visible_image; if (this === e.target && root) { container = root.find('div:first'), visible_image = container.find('.visible-img'); defaults.prev_index = 0; root.find('ul[data-clearing]').attr('style', '') root.removeClass('clearing-blackout'); container.removeClass('clearing-container'); visible_image.hide(); } return false; }); // should specify a target selector doc.on('keydown.fndtn.clearing', function (e) { var clearing = $('.clearing-blackout').find('ul[data-clearing]'); // right if (e.which === 39) { methods.go(clearing, 'next'); } // left if (e.which === 37) { methods.go(clearing, 'prev'); } }); doc.on('movestart', function(e) { // If the movestart is heading off in an upwards or downwards // direction, prevent it so that the browser scrolls normally. if ((e.distX > e.distY && e.distX < -e.distY) || (e.distX < e.distY && e.distX > -e.distY)) { e.preventDefault(); } }); doc.bind('swipeleft', 'ul[data-clearing] li', function () { var clearing = $('.clearing-blackout').find('ul[data-clearing]'); methods.go(clearing, 'next'); }); doc.bind('swiperight', 'ul[data-clearing] li', function () { var clearing = $('.clearing-blackout').find('ul[data-clearing]'); methods.go(clearing, 'prev'); }); }, assemble : function ($li, target) { var $el = $li.parent(), settings = $el.data('fndtn.clearing.settings'), grid = $el.detach(), data = { grid: '', viewing: settings.templates.viewing }, wrapper = '
' + data.viewing + data.grid + '
'; return settings.$parent.append(wrapper); }, open : function ($image, current, target) { var root = target.closest('.clearing-assembled'), container = root.find('div:first'), visible_image = container.find('.visible-img'), image = visible_image.find('img').not($image); if (!methods.locked()) { // set the image to the selected thumbnail image.attr('src', this.load($image)); image.is_good(function () { // toggle the gallery if not visible root.addClass('clearing-blackout'); container.addClass('clearing-container'); methods.caption(visible_image.find('.clearing-caption'), $image); visible_image.show(); methods.fix_height(target); methods.center(image); // shift the thumbnails if necessary methods.shift(current, target, function () { target.siblings().removeClass('visible'); target.addClass('visible'); }); }); } }, fix_height : function (target) { var lis = target.siblings(); lis.each(function () { var li = $(this), image = li.find('img'); if (li.height() > image.outerHeight()) { li.addClass('fix-height'); } }); lis.closest('ul').width(lis.length * 100 + '%'); }, update_paddles : function (target) { var visible_image = target.closest('.carousel').siblings('.visible-img'); if (target.next().length > 0) { visible_image.find('.clearing-main-right').removeClass('disabled'); } else { visible_image.find('.clearing-main-right').addClass('disabled'); } if (target.prev().length > 0) { visible_image.find('.clearing-main-left').removeClass('disabled'); } else { visible_image.find('.clearing-main-left').addClass('disabled'); } }, load : function ($image) { var href = $image.parent().attr('href'); // preload next and previous this.preload($image); if (href) { return href; } return $image.attr('src'); }, preload : function ($image) { var next = $image.closest('li').next(), prev = $image.closest('li').prev(), next_a, prev_a, next_img, prev_img; if (next.length > 0) { next_img = new Image(); next_a = next.find('a'); if (next_a.length > 0) { next_img.src = next_a.attr('href'); } else { next_img.src = next.find('img').attr('src'); } } if (prev.length > 0) { prev_img = new Image(); prev_a = prev.find('a'); if (prev_a.length > 0) { prev_img.src = prev_a.attr('href'); } else { prev_img.src = prev.find('img').attr('src'); } } }, caption : function (container, $image) { var caption = $image.data('caption'); if (caption) { container.text(caption).show(); } else { container.text('').hide(); } }, go : function ($ul, direction) { var current = $ul.find('.visible'), target = current[direction](); if (target.length > 0) { target.find('img').trigger('click', [current, target]); } }, shift : function (current, target, callback) { var clearing = target.parent(), container = clearing.closest('.clearing-container'), target_offset = target.position().left, thumbs_offset = clearing.position().left, old_index = defaults.prev_index, direction = this.direction(clearing, current, target), left = parseInt(clearing.css('left'), 10), width = target.outerWidth(), skip_shift; // we use jQuery animate instead of CSS transitions because we // need a callback to unlock the next animation if (target.index() !== old_index && !/skip/.test(direction)){ if (/left/.test(direction)) { methods.lock(); clearing.animate({left : left + width}, 300, methods.unlock); } else if (/right/.test(direction)) { methods.lock(); clearing.animate({left : left - width}, 300, methods.unlock); } } else if (/skip/.test(direction)) { // the target image is not adjacent to the current image, so // do we scroll right or not skip_shift = target.index() - defaults.up_count; methods.lock(); if (skip_shift > 0) { clearing.animate({left : -(skip_shift * width)}, 300, methods.unlock); } else { clearing.animate({left : 0}, 300, methods.unlock); } } callback(); }, lock : function () { defaults.locked = true; }, unlock : function () { defaults.locked = false; }, locked : function () { return defaults.locked; }, direction : function ($el, current, target) { var lis = $el.find('li'), li_width = lis.outerWidth() + (lis.outerWidth() / 4), container = $('.clearing-container'), up_count = Math.floor(container.outerWidth() / li_width) - 1, shift_count = lis.length - up_count, target_index = lis.index(target), current_index = lis.index(current), response; defaults.up_count = up_count; if (this.adjacent(defaults.prev_index, target_index)) { if ((target_index > up_count) && target_index > defaults.prev_index) { response = 'right'; } else if ((target_index > up_count - 1) && target_index <= defaults.prev_index) { response = 'left'; } else { response = false; } } else { response = 'skip'; } defaults.prev_index = target_index; return response; }, adjacent : function (current_index, target_index) { if (target_index - 1 === current_index) { return true; } else if (target_index + 1 === current_index) { return true; } else if (target_index === current_index) { return true; } return false; }, center : function (target) { target.css({ marginLeft : -(target.outerWidth() / 2), marginTop : -(target.outerHeight() / 2) }); }, outerHTML : function (el) { // support FireFox < 11 return el.outerHTML || new XMLSerializer().serializeToString(el); }, // experimental functionality for overwriting or extending // clearing methods during initialization. // // ex $doc.foundationClearing({}, { // shift : function (current, target, callback) { // // modify arguments, etc. // this._super('shift', [current, target, callback]); // // do something else here. // } // }); extend : function (supers, extendMethods) { $.each(supers, function (name, method) { if (extendMethods.hasOwnProperty(name)) { superMethods[name] = method; } }); $.extend(methods, extendMethods); }, // you can call this._super('methodName', [args]) to call // the original method and wrap it in your own code _super : function (method, args) { return superMethods[method].apply(this, args); } }; $.fn.foundationClearing = function (method) { if (methods[method]) { return methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return methods.init.apply(this, arguments); } else { $.error('Method ' + method + ' does not exist on jQuery.foundationClearing'); } }; // jquery.imageready.js // @weblinc, @jsantell, (c) 2012 (function( $ ) { $.fn.is_good = function ( callback, userSettings ) { var options = $.extend( {}, $.fn.is_good.defaults, userSettings ), $images = this.find( 'img' ).add( this.filter( 'img' ) ), unloadedImages = $images.length; function loaded () { unloadedImages -= 1; !unloadedImages && callback(); } function bindLoad () { this.one( 'load', loaded ); if ( $.browser.msie ) { var src = this.attr( 'src' ), param = src.match( /\?/ ) ? '&' : '?'; param += options.cachePrefix + '=' + ( new Date() ).getTime(); this.attr( 'src', src + param ); } } return $images.each(function () { var $this = $( this ); if ( !$this.attr( 'src' ) ) { loaded(); return; } this.complete || this.readyState === 4 ? loaded() : bindLoad.call( $this ); }); }; $.fn.is_good.defaults = { cachePrefix: 'random' }; }(jQuery)); }(jQuery, this)); /* * jQuery Custom Forms Plugin 1.0 * www.ZURB.com * Copyright 2010, ZURB * Free to use under the MIT license. * http://www.opensource.org/licenses/mit-license.php */ (function( $ ){ /** * Helper object used to quickly adjust all hidden parent element's, display and visibility properties. * This is currently used for the custom drop downs. When the dropdowns are contained within a reveal modal * we cannot accurately determine the list-item elements width property, since the modal's display property is set * to 'none'. * * This object will help us work around that problem. * * NOTE: This could also be plugin. * * @function hiddenFix */ var hiddenFix = function() { return { /** * Sets all hidden parent elements and self to visibile. * * @method adjust * @param {jQuery Object} $child */ // We'll use this to temporarily store style properties. tmp : [], // We'll use this to set hidden parent elements. hidden : null, adjust : function( $child ) { // Internal reference. var _self = this; // Set all hidden parent elements, including this element. _self.hidden = $child.parents().andSelf().filter( ":hidden" ); // Loop through all hidden elements. _self.hidden.each( function() { // Cache the element. var $elem = $( this ); // Store the style attribute. // Undefined if element doesn't have a style attribute. _self.tmp.push( $elem.attr( 'style' ) ); // Set the element's display property to block, // but ensure it's visibility is hidden. $elem.css( { 'visibility' : 'hidden', 'display' : 'block' } ); }); }, // end adjust /** * Resets the elements previous state. * * @method reset */ reset : function() { // Internal reference. var _self = this; // Loop through our hidden element collection. _self.hidden.each( function( i ) { // Cache this element. var $elem = $( this ), _tmp = _self.tmp[ i ]; // Get the stored 'style' value for this element. // If the stored value is undefined. if( _tmp === undefined ) // Remove the style attribute. $elem.removeAttr( 'style' ); else // Otherwise, reset the element style attribute. $elem.attr( 'style', _tmp ); }); // Reset the tmp array. _self.tmp = []; // Reset the hidden elements variable. _self.hidden = null; } // end reset }; // end return }; jQuery.foundation = jQuery.foundation || {}; jQuery.foundation.customForms = jQuery.foundation.customForms || {}; $.foundation.customForms.appendCustomMarkup = function ( options ) { var defaults = { disable_class: "js-disable-custom" }; options = $.extend( defaults, options ); function appendCustomMarkup(idx, sel) { var $this = $(sel).hide(), type = $this.attr('type'), $span = $this.next('span.custom.' + type); if ($span.length === 0) { $span = $('').insertAfter($this); } $span.toggleClass('checked', $this.is(':checked')); $span.toggleClass('disabled', $this.is(':disabled')); } function appendCustomSelect(idx, sel) { var hiddenFixObj = hiddenFix(); // // jQueryify the element. // $options = $this.find( 'option' ), // // Filter down the selected options // $selectedOption = $options.filter( ':selected' ), // // Initial max width. // maxWidth = 0, // // We'll use this variable to create the
  • elements for our custom select. // liHtml = '', // // We'll use this to cache the created
  • elements within our custom select. // $listItems ; var $currentSelect = false; // // Should we not create a custom list? // if ( $this.hasClass( 'no-custom' ) ) return; // // Did we not create a custom select element yet? // if ( $customSelect.length === 0 ) { // // Let's create our custom select element! // // // Determine what select size to use. // var customSelectSize = $this.hasClass( 'small' ) ? 'small' : $this.hasClass( 'medium' ) ? 'medium' : $this.hasClass( 'large' ) ? 'large' : $this.hasClass( 'expand' ) ? 'expand' : '' ; // // Build our custom list. // $customSelect = $('
    "'); // // Grab the selector element // $selector = $customSelect.find( ".selector" ); // // Grab the unordered list element from the custom list. // $customList = $customSelect.find( "ul" ); // // Build our
  • elements. // liHtml = $options.map( function() { return "
  • " + $( this ).html() + "
  • "; } ).get().join( '' ); // // Append our
  • elements to the custom list (