diff --git a/demo/bundle.js b/demo/bundle.js index 911fe84b46..22f7a4a110 100644 --- a/demo/bundle.js +++ b/demo/bundle.js @@ -45,7 +45,7 @@ define([ "representers": [ { "implementation": DemoConductorRepresenter, - "depends": ["$q", "$compile", "conductorService", "views[]", "throttle"] + "depends": ["$q", "$compile", "conductorService", "views[]", "throttle", "navigationService"] } ], "components": [ @@ -71,6 +71,7 @@ define([ { "implementation": DemoInitializer, "depends": [ + "$timeout", "representers[]" ] } @@ -104,6 +105,16 @@ define([ ] } } + ], + "stylesheets": [ + { + "stylesheetUrl": "css/hopscotch.css", + priority: "fallback" + + }, + { + "stylesheetUrl": "css/tour.css" + } ] } }); diff --git a/demo/lib/hopscotch/hopscotch.min.js b/demo/lib/hopscotch/hopscotch.min.js new file mode 100755 index 0000000000..40cb26cffb --- /dev/null +++ b/demo/lib/hopscotch/hopscotch.min.js @@ -0,0 +1,17 @@ +/**! hopscotch - v0.2.5 +* +* Copyright 2015 LinkedIn Corp. All rights reserved. +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ +!function(a,b){"use strict";if("function"==typeof define&&define.amd)define([],b);else if("object"==typeof exports)module.exports=b();else{var c="hopscotch";if(a[c])return;a[c]=b()}}(this,function(){var Hopscotch,HopscotchBubble,HopscotchCalloutManager,HopscotchI18N,customI18N,customRenderer,customEscape,utils,callbacks,helpers,winLoadHandler,defaultOpts,winHopscotch,templateToUse="bubble_default",Sizzle=window.Sizzle||null,undefinedStr="undefined",waitingToStart=!1,hasJquery=typeof jQuery!==undefinedStr,hasSessionStorage=!1,isStorageWritable=!1,document=window.document,validIdRegEx=/^[a-zA-Z]+[a-zA-Z0-9_-]*$/,rtlMatches={left:"right",right:"left"};try{typeof window.sessionStorage!==undefinedStr&&(hasSessionStorage=!0,sessionStorage.setItem("hopscotch.test.storage","ok"),sessionStorage.removeItem("hopscotch.test.storage"),isStorageWritable=!0)}catch(err){}return defaultOpts={smoothScroll:!0,scrollDuration:1e3,scrollTopMargin:200,showCloseButton:!0,showPrevButton:!1,showNextButton:!0,bubbleWidth:280,bubblePadding:15,arrowWidth:20,skipIfNoElement:!0,isRtl:!1,cookieName:"hopscotch.tour.state"},Array.isArray||(Array.isArray=function(a){return"[object Array]"===Object.prototype.toString.call(a)}),winLoadHandler=function(){waitingToStart&&winHopscotch.startTour()},utils={addClass:function(a,b){var c,d,e,f;if(a.className){for(d=b.split(/\s+/),c=" "+a.className+" ",e=0,f=d.length;f>e;++e)c.indexOf(" "+d[e]+" ")<0&&(c+=d[e]+" ");a.className=c.replace(/^\s+|\s+$/g,"")}else a.className=b},removeClass:function(a,b){var c,d,e,f;for(d=b.split(/\s+/),c=" "+a.className+" ",e=0,f=d.length;f>e;++e)c=c.replace(" "+d[e]+" "," ");a.className=c.replace(/^\s+|\s+$/g,"")},hasClass:function(a,b){var c;return a.className?(c=" "+a.className+" ",-1!==c.indexOf(" "+b+" ")):!1},getPixelValue:function(a){var b=typeof a;return"number"===b?a:"string"===b?parseInt(a,10):0},valOrDefault:function(a,b){return typeof a!==undefinedStr?a:b},invokeCallbackArrayHelper:function(a){var b;return Array.isArray(a)&&(b=helpers[a[0]],"function"==typeof b)?b.apply(this,a.slice(1)):void 0},invokeCallbackArray:function(a){var b,c;if(Array.isArray(a)){if("string"==typeof a[0])return utils.invokeCallbackArrayHelper(a);for(b=0,c=a.length;c>b;++b)utils.invokeCallback(a[b])}},invokeCallback:function(a){return"function"==typeof a?a():"string"==typeof a&&helpers[a]?helpers[a]():utils.invokeCallbackArray(a)},invokeEventCallbacks:function(a,b){var c,d,e=callbacks[a];if(b)return this.invokeCallback(b);for(c=0,d=e.length;d>c;++c)this.invokeCallback(e[c].cb)},getScrollTop:function(){var a;return a=typeof window.pageYOffset!==undefinedStr?window.pageYOffset:document.documentElement.scrollTop},getScrollLeft:function(){var a;return a=typeof window.pageXOffset!==undefinedStr?window.pageXOffset:document.documentElement.scrollLeft},getWindowHeight:function(){return window.innerHeight||document.documentElement.clientHeight},addEvtListener:function(a,b,c){return a?a.addEventListener?a.addEventListener(b,c,!1):a.attachEvent("on"+b,c):void 0},removeEvtListener:function(a,b,c){return a?a.removeEventListener?a.removeEventListener(b,c,!1):a.detachEvent("on"+b,c):void 0},documentIsReady:function(){return"complete"===document.readyState},evtPreventDefault:function(a){a.preventDefault?a.preventDefault():event&&(event.returnValue=!1)},extend:function(a,b){var c;for(c in b)b.hasOwnProperty(c)&&(a[c]=b[c])},getStepTargetHelper:function(a){var b=document.getElementById(a);if(b)return b;if(hasJquery)return b=jQuery(a),b.length?b[0]:null;if(Sizzle)return b=new Sizzle(a),b.length?b[0]:null;if(document.querySelector)try{return document.querySelector(a)}catch(c){}return/^#[a-zA-Z][\w-_:.]*$/.test(a)?document.getElementById(a.substring(1)):null},getStepTarget:function(a){var b;if(!a||!a.target)return null;if("string"==typeof a.target)return utils.getStepTargetHelper(a.target);if(Array.isArray(a.target)){var c,d;for(c=0,d=a.target.length;d>c;c++)if("string"==typeof a.target[c]&&(b=utils.getStepTargetHelper(a.target[c])))return b;return null}return a.target},getI18NString:function(a){return customI18N[a]||HopscotchI18N[a]},setState:function(a,b,c){var d,e="";if(hasSessionStorage&&isStorageWritable)try{sessionStorage.setItem(a,b)}catch(f){isStorageWritable=!1,this.setState(a,b,c)}else hasSessionStorage&&sessionStorage.removeItem(a),c&&(d=new Date,d.setTime(d.getTime()+24*c*60*60*1e3),e="; expires="+d.toGMTString()),document.cookie=a+"="+b+e+"; path=/"},getState:function(a){var b,c,d,e=a+"=",f=document.cookie.split(";");if(hasSessionStorage&&(d=sessionStorage.getItem(a)))return d;for(b=0;b0,showNext:utils.valOrDefault(a.showNextButton,this.opt.showNextButton),showCTA:utils.valOrDefault(a.showCTAButton&&a.ctaLabel,!1),ctaLabel:a.ctaLabel,showClose:utils.valOrDefault(this.opt.showCloseButton,!0)},step:{num:b,isLast:utils.valOrDefault(l,!1),title:a.title||"",content:a.content||"",isRtl:a.isRtl,placement:a.placement,padding:utils.valOrDefault(a.padding,this.opt.bubblePadding),width:utils.getPixelValue(a.width)||this.opt.bubbleWidth,customData:a.customData||{}},tour:{isTour:this.opt.isTourBubble,numSteps:h,unsafe:utils.valOrDefault(f,!1),customData:e||{}}},"function"==typeof d)n.innerHTML=d(m);else if("string"==typeof d){if(!winHopscotch.templates||"function"!=typeof winHopscotch.templates[d])throw new Error('Bubble rendering failed - template "'+d+'" is not a function.');n.innerHTML=winHopscotch.templates[d](m)}else if(customRenderer)n.innerHTML=customRenderer(m);else{if(!winHopscotch.templates||"function"!=typeof winHopscotch.templates[templateToUse])throw new Error('Bubble rendering failed - template "'+templateToUse+'" is not a function.');n.innerHTML=winHopscotch.templates[templateToUse](m)}for(children=n.children,numChildren=children.length,i=0;ic;c++)b=e[c],a>b&&d++;return a-d},_getStepI18nNum:function(a){var b=utils.getI18NString("stepNums");return b&&af||f>=e.steps.length?null:e.steps[f]},q=function(){j.nextStep()},r=function(a){var b,c,d,e,f,g,h=m(),i=h.element,j=utils.getPixelValue(i.style.top),k=j+utils.getPixelValue(i.offsetHeight),l=utils.getStepTarget(p()),n=l.getBoundingClientRect(),q=n.top+utils.getScrollTop(),r=n.bottom+utils.getScrollTop(),s=q>j?j:q,t=k>r?k:r,u=utils.getScrollTop(),v=u+utils.getWindowHeight(),w=s-o("scrollTopMargin");s>=u&&(s<=u+o("scrollTopMargin")||v>=t)?a&&a():o("smoothScroll")?typeof YAHOO!==undefinedStr&&typeof YAHOO.env!==undefinedStr&&typeof YAHOO.env.ua!==undefinedStr&&typeof YAHOO.util!==undefinedStr&&typeof YAHOO.util.Scroll!==undefinedStr?(b=YAHOO.env.ua.webkit?document.body:document.documentElement,d=YAHOO.util.Easing?YAHOO.util.Easing.easeOut:void 0,c=new YAHOO.util.Scroll(b,{scroll:{to:[0,w]}},o("scrollDuration")/1e3,d),c.onComplete.subscribe(a),c.animate()):hasJquery?jQuery("body, html").animate({scrollTop:w},o("scrollDuration"),a):(0>w&&(w=0),e=u>s?-1:1,f=Math.abs(u-w)/(o("scrollDuration")/10),(g=function(){var b=utils.getScrollTop(),c=b+e*f;return e>0&&c>=w||0>e&&w>=c?(c=w,a&&a(),void window.scrollTo(0,c)):(window.scrollTo(0,c),utils.getScrollTop()===b?void(a&&a()):void setTimeout(g,10))})()):(window.scrollTo(0,w),a&&a())},s=function(a,b){var c,d,g;f+a>=0&&f+a0?d.multipage:f>0&&e.steps[f-1].multipage,h=function(c){var e;if(-1===c)return this.endTour(!0);if(a&&(e=b>0?utils.invokeEventCallbacks("next",d.onNext):utils.invokeEventCallbacks("prev",d.onPrev)),c===f){if(g)return void x();e=utils.valOrDefault(e,!0),e?this.showStep(c):this.endTour(!1)}},!g&&o("skipIfNoElement"))s(b,function(a){h.call(j,a)});else if(f+b>=0&&f+b2&&(l=d[2].split(",")),h=parseInt(h,10)),this},v=function(a,b,c){var d,e;if(f=a||0,k=b||{},d=p(),e=utils.getStepTarget(d))return void c(f);if(!e){if(utils.invokeEventCallbacks("error"),k[f]=!0,o("skipIfNoElement"))return void s(1,c);f=-1,c(f)}},w=function(a){function b(){d.show(),utils.invokeEventCallbacks("show",c.onShow)}var c=e.steps[a],d=m(),g=utils.getStepTarget(c);f!==a&&p().nextOnTargetClick&&utils.removeEvtListener(utils.getStepTarget(p()),"click",q),f=a,d.hide(!1),d.render(c,a,function(a){a?r(b):b(),c.nextOnTargetClick&&utils.addEvtListener(g,"click",q)}),x()},x=function(){var a=e.id+":"+f,b=winHopscotch.getSkippedStepsIndexes();b&&b.length>0&&(a+=":"+b.join(",")),utils.setState(o("cookieName"),a,1)},y=function(a){a&&this.configure(a)};this.getCalloutManager=function(){return typeof c===undefinedStr&&(c=new HopscotchCalloutManager),c},this.startTour=function(a,b){var c,d,f={},i=this;if(!e){if(!a)throw new Error("Tour data is required for startTour.");if(!a.id||!validIdRegEx.test(a.id))throw new Error("Tour ID is using an invalid format. Use alphanumeric, underscores, and/or hyphens only. First character must be a letter.");e=a,u.call(this,a)}if(typeof b!==undefinedStr){if(b>=e.steps.length)throw new Error("Specified step number out of bounds.");d=b}if(!utils.documentIsReady())return waitingToStart=!0,this;if("undefined"==typeof d&&e.id===g&&typeof h!==undefinedStr){if(d=h,l.length>0)for(var j=0,k=l.length;k>j;j++)f[l[j]]=!0}else d||(d=0);return v(d,f,function(a){var b=-1!==a&&utils.getStepTarget(e.steps[a]);return b?(utils.invokeEventCallbacks("start"),c=m(),c.hide(!1),i.isActive=!0,void(utils.getStepTarget(p())?i.showStep(a):(utils.invokeEventCallbacks("error"),o("skipIfNoElement")&&i.nextStep(!1)))):void i.endTour(!1,!1)}),this},this.showStep=function(a){var b=e.steps[a];if(utils.getStepTarget(b))return b.delay?setTimeout(function(){w(a)},b.delay):w(a),this},this.prevStep=function(a){return t.call(this,a,-1),this},this.nextStep=function(a){return t.call(this,a,1),this},this.endTour=function(a,b){var c,d=m();return a=utils.valOrDefault(a,!0),b=utils.valOrDefault(b,!0),e&&(c=p(),c&&c.nextOnTargetClick&&utils.removeEvtListener(utils.getStepTarget(c),"click",q)),f=0,h=void 0,d.hide(),a&&utils.clearState(o("cookieName")),this.isActive&&(this.isActive=!1,e&&b&&utils.invokeEventCallbacks("end")),this.removeCallbacks(null,!0),this.resetDefaultOptions(),n(),e=null,this},this.getCurrTour=function(){return e},this.getCurrTarget=function(){return utils.getStepTarget(p())},this.getCurrStepNum=function(){return f},this.getSkippedStepsIndexes=function(){var a,b=[];for(a in k)b.push(a);return b},this.refreshBubblePosition=function(){var a=p();return a&&m().setPosition(a),this.getCalloutManager().refreshCalloutPositions(),this},this.listen=function(a,b,c){return a&&callbacks[a].push({cb:b,fromTour:c}),this},this.unlisten=function(a,b){var c,d,e=callbacks[a];for(c=0,d=e.length;d>c;++c)e[c]===b&&e.splice(c,1);return this},this.removeCallbacks=function(a,b){var c,d,e,f;for(f in callbacks)if(!a||a===f)if(b)for(c=callbacks[f],d=0,e=c.length;e>d;++d)c[d].fromTour&&(c.splice(d--,1),--e);else callbacks[f]=[];return this},this.registerHelper=function(a,b){"string"==typeof a&&"function"==typeof b&&(helpers[a]=b)},this.unregisterHelper=function(a){helpers[a]=null},this.invokeHelper=function(a){var b,c,d=[];for(b=1,c=arguments.length;c>b;++b)d.push(arguments[b]);helpers[a]&&helpers[a].call(null,d)},this.setCookieName=function(a){return d.cookieName=a,this},this.resetDefaultOptions=function(){return d={},this},this.resetDefaultI18N=function(){return customI18N={},this},this.getState=function(){return utils.getState(o("cookieName"))},i=function(a,b){var c,e,f,g,h=["next","prev","start","end","show","error","close"];for(d||this.resetDefaultOptions(),utils.extend(d,a),a&&utils.extend(customI18N,a.i18n),f=0,g=h.length;g>f;++f)e="on"+h[f].charAt(0).toUpperCase()+h[f].substring(1),a[e]&&this.listen(h[f],a[e],b);return c=m(!0),this},this.configure=function(a){return i.call(this,a,!1)},this.setRenderer=function(a){var b=typeof a;return"string"===b?(templateToUse=a,customRenderer=void 0):"function"===b&&(customRenderer=a),this},this.setEscaper=function(a){return"function"==typeof a&&(customEscape=a),this},y.call(this,a)},winHopscotch=new Hopscotch,function(){var _={};_.escape=function(a){return customEscape?customEscape(a):null==a?"":(""+a).replace(new RegExp("[&<>\"']","g"),function(a){return"&"==a?"&":"<"==a?"<":">"==a?">":'"'==a?""":"'"==a?"'":void 0})},this.templates=this.templates||{},this.templates.bubble_default=function(obj){function optEscape(a,b){return b?_.escape(a):a}obj||(obj={});var __t,__p="";_.escape,Array.prototype.join;with(obj)__p+='\n
\n ',tour.isTour&&(__p+=''+(null==(__t=i18n.stepNum)?"":__t)+""),__p+='\n
\n ',""!==step.title&&(__p+='

'+(null==(__t=optEscape(step.title,tour.unsafe))?"":__t)+"

"),__p+="\n ",""!==step.content&&(__p+='
'+(null==(__t=optEscape(step.content,tour.unsafe))?"":__t)+"
"),__p+='\n
\n
\n ',buttons.showPrev&&(__p+='"),__p+="\n ",buttons.showCTA&&(__p+='"),__p+="\n ",buttons.showNext&&(__p+='"),__p+="\n
\n ",buttons.showClose&&(__p+='"),__p+='\n
\n
\n
\n
\n
';return __p}}.call(winHopscotch),winHopscotch}); \ No newline at end of file diff --git a/demo/lib/shepherd/shepherd.min.js b/demo/lib/shepherd/shepherd.min.js new file mode 100755 index 0000000000..3b446ec61c --- /dev/null +++ b/demo/lib/shepherd/shepherd.min.js @@ -0,0 +1 @@ +!function(n,i){"function"==typeof define&&define.amd?define(["tether"],i):"object"==typeof exports?module.exports=i(require("tether")):n.Shepherd=i(n.Tether)}(this,function(Tether){"use strict";function n(n,i){if(!(n instanceof i))throw new TypeError("Cannot call a class as a function")}function i(n,i){if("function"!=typeof i&&null!==i)throw new TypeError("Super expression must either be null or a function, not "+typeof i);n.prototype=Object.create(i&&i.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),i&&(Object.setPrototypeOf?Object.setPrototypeOf(n,i):n.__proto__=i)}function s(n){return"undefined"==typeof n}function o(n){return n&&n.constructor===Array}function c(n){return n&&n.constructor===Object}function a(n){return"object"==typeof n}function u(n){var i=document.createElement("div");return i.innerHTML=n,i.children[0]}function l(n,i){var o=void 0;return s(n.matches)?s(n.matchesSelector)?s(n.msMatchesSelector)?s(n.webkitMatchesSelector)?s(n.mozMatchesSelector)?s(n.oMatchesSelector)||(o=n.oMatchesSelector):o=n.mozMatchesSelector:o=n.webkitMatchesSelector:o=n.msMatchesSelector:o=n.matchesSelector:o=n.matches,o.call(n,i)}function p(n){if(a(n))return n.hasOwnProperty("element")&&n.hasOwnProperty("on")?n:null;var i=C.exec(n);if(!i)return null;var s=i[2];return"["===s[0]&&(s=s.substring(1,s.length-1)),{element:i[1],on:s}}function d(n,i){if(null===n||s(n))return n;if(a(n))return n;for(var o=n.split(" "),c={},u=i.length-1,l=o.length-1;l>=0;l--){if(0===u){c[i[u]]=o.slice(0,l+1).join(" ");break}c[i[u]]=o[l],u--}return c}var f=function(){function n(n,i){for(var s=0;s");var i=document.createElement("div");i.className="shepherd-content",this.el.appendChild(i);var o=document.createElement("header");if(i.appendChild(o),this.options.title&&(o.innerHTML+="

"+this.options.title+"

",this.el.className+=" shepherd-has-title"),this.options.showCancelLink){var c=u("");o.appendChild(c),this.el.className+=" shepherd-has-cancel-link",this.bindCancelLink(c)}s(this.options.text)||!function(){var s=u("
"),o=n.options.text;"function"==typeof o&&(o=o.call(n,s)),o instanceof HTMLElement?s.appendChild(o):("string"==typeof o&&(o=[o]),o.map(function(n){s.innerHTML+="

"+n+"

"})),i.appendChild(s)}(),this.options.buttons&&!function(){var s=document.createElement("footer"),o=u("
    ");n.options.buttons.map(function(i){var s=u("
  • "+i.text+"");o.appendChild(s),n.bindButtonEvents(i,s.querySelector("a"))}),s.appendChild(o),i.appendChild(s)}(),document.body.appendChild(this.el),this.setupTether(),this.options.advanceOn&&this.bindAdvance()}},{key:"bindCancelLink",value:function(n){var i=this;n.addEventListener("click",function(e){e.preventDefault(),i.cancel()})}},{key:"bindButtonEvents",value:function(n,i){var o=this;n.events=n.events||{},s(n.action)||(n.events.click=n.action);for(var c in n.events)if({}.hasOwnProperty.call(n.events,c)){var a=n.events[c];"string"==typeof a&&!function(){var n=a;a=function(){return o.tour.show(n)}}(),i.addEventListener(c,a)}this.on("destroy",function(){for(var s in n.events)if({}.hasOwnProperty.call(n.events,s)){var o=n.events[s];i.removeEventListener(s,o)}})}}]),m}(y),M=function(o){function c(){var i=this,s=arguments.length<=0||void 0===arguments[0]?{}:arguments[0];n(this,c),v(Object.getPrototypeOf(c.prototype),"constructor",this).call(this,s),this.bindMethods(),this.options=s,this.steps=this.options.steps||[];var o=["complete","cancel","hide","start","show","active","inactive"];return o.map(function(n){!function(e){i.on(e,function(n){n=n||{},n.tour=i,O.trigger(e,n)})}(n)}),this}return i(c,o),f(c,[{key:"bindMethods",value:function(){var n=this,i=["next","back","cancel","complete","hide"];i.map(function(i){n[i]=n[i].bind(n)})}},{key:"addStep",value:function(n,i){return s(i)&&(i=n),i instanceof E?i.tour=this:(("string"==typeof n||"number"==typeof n)&&(i.id=n.toString()),i=b({},this.options.defaults,i),i=new E(this,i)),this.steps.push(i),this}},{key:"removeStep",value:function(n){for(var i=this.getCurrentStep(),s=0;s= b && b >= a - diff); + }; + + transformKey = (function() { + var el, key, _i, _len, _ref1; + el = document.createElement('div'); + _ref1 = ['transform', 'webkitTransform', 'OTransform', 'MozTransform', 'msTransform']; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + key = _ref1[_i]; + if (el.style[key] !== void 0) { + return key; + } + } + })(); + + tethers = []; + + position = function() { + var tether, _i, _len; + for (_i = 0, _len = tethers.length; _i < _len; _i++) { + tether = tethers[_i]; + tether.position(false); + } + return flush(); + }; + + now = function() { + var _ref1; + return (_ref1 = typeof performance !== "undefined" && performance !== null ? typeof performance.now === "function" ? performance.now() : void 0 : void 0) != null ? _ref1 : +(new Date); + }; + + (function() { + var event, lastCall, lastDuration, pendingTimeout, tick, _i, _len, _ref1, _results; + lastCall = null; + lastDuration = null; + pendingTimeout = null; + tick = function() { + if ((lastDuration != null) && lastDuration > 16) { + lastDuration = Math.min(lastDuration - 16, 250); + pendingTimeout = setTimeout(tick, 250); + return; + } + if ((lastCall != null) && (now() - lastCall) < 10) { + return; + } + if (pendingTimeout != null) { + clearTimeout(pendingTimeout); + pendingTimeout = null; + } + lastCall = now(); + position(); + return lastDuration = now() - lastCall; + }; + _ref1 = ['resize', 'scroll', 'touchmove']; + _results = []; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + event = _ref1[_i]; + _results.push(window.addEventListener(event, tick)); + } + return _results; + })(); + + MIRROR_LR = { + center: 'center', + left: 'right', + right: 'left' + }; + + MIRROR_TB = { + middle: 'middle', + top: 'bottom', + bottom: 'top' + }; + + OFFSET_MAP = { + top: 0, + left: 0, + middle: '50%', + center: '50%', + bottom: '100%', + right: '100%' + }; + + autoToFixedAttachment = function(attachment, relativeToAttachment) { + var left, top; + left = attachment.left, top = attachment.top; + if (left === 'auto') { + left = MIRROR_LR[relativeToAttachment.left]; + } + if (top === 'auto') { + top = MIRROR_TB[relativeToAttachment.top]; + } + return { + left: left, + top: top + }; + }; + + attachmentToOffset = function(attachment) { + var _ref1, _ref2; + return { + left: (_ref1 = OFFSET_MAP[attachment.left]) != null ? _ref1 : attachment.left, + top: (_ref2 = OFFSET_MAP[attachment.top]) != null ? _ref2 : attachment.top + }; + }; + + addOffset = function() { + var left, offsets, out, top, _i, _len, _ref1; + offsets = 1 <= arguments.length ? __slice.call(arguments, 0) : []; + out = { + top: 0, + left: 0 + }; + for (_i = 0, _len = offsets.length; _i < _len; _i++) { + _ref1 = offsets[_i], top = _ref1.top, left = _ref1.left; + if (typeof top === 'string') { + top = parseFloat(top, 10); + } + if (typeof left === 'string') { + left = parseFloat(left, 10); + } + out.top += top; + out.left += left; + } + return out; + }; + + offsetToPx = function(offset, size) { + if (typeof offset.left === 'string' && offset.left.indexOf('%') !== -1) { + offset.left = parseFloat(offset.left, 10) / 100 * size.width; + } + if (typeof offset.top === 'string' && offset.top.indexOf('%') !== -1) { + offset.top = parseFloat(offset.top, 10) / 100 * size.height; + } + return offset; + }; + + parseAttachment = parseOffset = function(value) { + var left, top, _ref1; + _ref1 = value.split(' '), top = _ref1[0], left = _ref1[1]; + return { + top: top, + left: left + }; + }; + + _Tether = (function() { + _Tether.modules = []; + + function _Tether(options) { + this.position = __bind(this.position, this); + var module, _i, _len, _ref1, _ref2; + tethers.push(this); + this.history = []; + this.setOptions(options, false); + _ref1 = Tether.modules; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + module = _ref1[_i]; + if ((_ref2 = module.initialize) != null) { + _ref2.call(this); + } + } + this.position(); + } + + _Tether.prototype.getClass = function(key) { + var _ref1, _ref2; + if ((_ref1 = this.options.classes) != null ? _ref1[key] : void 0) { + return this.options.classes[key]; + } else if (((_ref2 = this.options.classes) != null ? _ref2[key] : void 0) !== false) { + if (this.options.classPrefix) { + return "" + this.options.classPrefix + "-" + key; + } else { + return key; + } + } else { + return ''; + } + }; + + _Tether.prototype.setOptions = function(options, position) { + var defaults, key, _i, _len, _ref1, _ref2; + this.options = options; + if (position == null) { + position = true; + } + defaults = { + offset: '0 0', + targetOffset: '0 0', + targetAttachment: 'auto auto', + classPrefix: 'tether' + }; + this.options = extend(defaults, this.options); + _ref1 = this.options, this.element = _ref1.element, this.target = _ref1.target, this.targetModifier = _ref1.targetModifier; + if (this.target === 'viewport') { + this.target = document.body; + this.targetModifier = 'visible'; + } else if (this.target === 'scroll-handle') { + this.target = document.body; + this.targetModifier = 'scroll-handle'; + } + _ref2 = ['element', 'target']; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + key = _ref2[_i]; + if (this[key] == null) { + throw new Error("Tether Error: Both element and target must be defined"); + } + if (this[key].jquery != null) { + this[key] = this[key][0]; + } else if (typeof this[key] === 'string') { + this[key] = document.querySelector(this[key]); + } + } + addClass(this.element, this.getClass('element')); + addClass(this.target, this.getClass('target')); + if (!this.options.attachment) { + throw new Error("Tether Error: You must provide an attachment"); + } + this.targetAttachment = parseAttachment(this.options.targetAttachment); + this.attachment = parseAttachment(this.options.attachment); + this.offset = parseOffset(this.options.offset); + this.targetOffset = parseOffset(this.options.targetOffset); + if (this.scrollParent != null) { + this.disable(); + } + if (this.targetModifier === 'scroll-handle') { + this.scrollParent = this.target; + } else { + this.scrollParent = getScrollParent(this.target); + } + if (this.options.enabled !== false) { + return this.enable(position); + } + }; + + _Tether.prototype.getTargetBounds = function() { + var bounds, fitAdj, hasBottomScroll, height, out, scrollBottom, scrollPercentage, style, target; + if (this.targetModifier != null) { + switch (this.targetModifier) { + case 'visible': + if (this.target === document.body) { + return { + top: pageYOffset, + left: pageXOffset, + height: innerHeight, + width: innerWidth + }; + } else { + bounds = getBounds(this.target); + out = { + height: bounds.height, + width: bounds.width, + top: bounds.top, + left: bounds.left + }; + out.height = Math.min(out.height, bounds.height - (pageYOffset - bounds.top)); + out.height = Math.min(out.height, bounds.height - ((bounds.top + bounds.height) - (pageYOffset + innerHeight))); + out.height = Math.min(innerHeight, out.height); + out.height -= 2; + out.width = Math.min(out.width, bounds.width - (pageXOffset - bounds.left)); + out.width = Math.min(out.width, bounds.width - ((bounds.left + bounds.width) - (pageXOffset + innerWidth))); + out.width = Math.min(innerWidth, out.width); + out.width -= 2; + if (out.top < pageYOffset) { + out.top = pageYOffset; + } + if (out.left < pageXOffset) { + out.left = pageXOffset; + } + return out; + } + break; + case 'scroll-handle': + target = this.target; + if (target === document.body) { + target = document.documentElement; + bounds = { + left: pageXOffset, + top: pageYOffset, + height: innerHeight, + width: innerWidth + }; + } else { + bounds = getBounds(target); + } + style = getComputedStyle(target); + hasBottomScroll = target.scrollWidth > target.clientWidth || 'scroll' === [style.overflow, style.overflowX] || this.target !== document.body; + scrollBottom = 0; + if (hasBottomScroll) { + scrollBottom = 15; + } + height = bounds.height - parseFloat(style.borderTopWidth) - parseFloat(style.borderBottomWidth) - scrollBottom; + out = { + width: 15, + height: height * 0.975 * (height / target.scrollHeight), + left: bounds.left + bounds.width - parseFloat(style.borderLeftWidth) - 15 + }; + fitAdj = 0; + if (height < 408 && this.target === document.body) { + fitAdj = -0.00011 * Math.pow(height, 2) - 0.00727 * height + 22.58; + } + if (this.target !== document.body) { + out.height = Math.max(out.height, 24); + } + scrollPercentage = this.target.scrollTop / (target.scrollHeight - height); + out.top = scrollPercentage * (height - out.height - fitAdj) + bounds.top + parseFloat(style.borderTopWidth); + if (this.target === document.body) { + out.height = Math.max(out.height, 24); + } + return out; + } + } else { + return getBounds(this.target); + } + }; + + _Tether.prototype.clearCache = function() { + return this._cache = {}; + }; + + _Tether.prototype.cache = function(k, getter) { + if (this._cache == null) { + this._cache = {}; + } + if (this._cache[k] == null) { + this._cache[k] = getter.call(this); + } + return this._cache[k]; + }; + + _Tether.prototype.enable = function(position) { + if (position == null) { + position = true; + } + addClass(this.target, this.getClass('enabled')); + addClass(this.element, this.getClass('enabled')); + this.enabled = true; + if (this.scrollParent !== document) { + this.scrollParent.addEventListener('scroll', this.position); + } + if (position) { + return this.position(); + } + }; + + _Tether.prototype.disable = function() { + removeClass(this.target, this.getClass('enabled')); + removeClass(this.element, this.getClass('enabled')); + this.enabled = false; + if (this.scrollParent != null) { + return this.scrollParent.removeEventListener('scroll', this.position); + } + }; + + _Tether.prototype.destroy = function() { + var i, tether, _i, _len, _results; + this.disable(); + _results = []; + for (i = _i = 0, _len = tethers.length; _i < _len; i = ++_i) { + tether = tethers[i]; + if (tether === this) { + tethers.splice(i, 1); + break; + } else { + _results.push(void 0); + } + } + return _results; + }; + + _Tether.prototype.updateAttachClasses = function(elementAttach, targetAttach) { + var add, all, side, sides, _i, _j, _len, _len1, _ref1, + _this = this; + if (elementAttach == null) { + elementAttach = this.attachment; + } + if (targetAttach == null) { + targetAttach = this.targetAttachment; + } + sides = ['left', 'top', 'bottom', 'right', 'middle', 'center']; + if ((_ref1 = this._addAttachClasses) != null ? _ref1.length : void 0) { + this._addAttachClasses.splice(0, this._addAttachClasses.length); + } + add = this._addAttachClasses != null ? this._addAttachClasses : this._addAttachClasses = []; + if (elementAttach.top) { + add.push("" + (this.getClass('element-attached')) + "-" + elementAttach.top); + } + if (elementAttach.left) { + add.push("" + (this.getClass('element-attached')) + "-" + elementAttach.left); + } + if (targetAttach.top) { + add.push("" + (this.getClass('target-attached')) + "-" + targetAttach.top); + } + if (targetAttach.left) { + add.push("" + (this.getClass('target-attached')) + "-" + targetAttach.left); + } + all = []; + for (_i = 0, _len = sides.length; _i < _len; _i++) { + side = sides[_i]; + all.push("" + (this.getClass('element-attached')) + "-" + side); + } + for (_j = 0, _len1 = sides.length; _j < _len1; _j++) { + side = sides[_j]; + all.push("" + (this.getClass('target-attached')) + "-" + side); + } + return defer(function() { + if (_this._addAttachClasses == null) { + return; + } + updateClasses(_this.element, _this._addAttachClasses, all); + updateClasses(_this.target, _this._addAttachClasses, all); + return _this._addAttachClasses = void 0; + }); + }; + + _Tether.prototype.position = function(flushChanges) { + var elementPos, elementStyle, height, left, manualOffset, manualTargetOffset, module, next, offset, offsetBorder, offsetParent, offsetParentSize, offsetParentStyle, offsetPosition, ret, scrollLeft, scrollTop, scrollbarSize, side, targetAttachment, targetOffset, targetPos, targetSize, top, width, _i, _j, _len, _len1, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, + _this = this; + if (flushChanges == null) { + flushChanges = true; + } + if (!this.enabled) { + return; + } + this.clearCache(); + targetAttachment = autoToFixedAttachment(this.targetAttachment, this.attachment); + this.updateAttachClasses(this.attachment, targetAttachment); + elementPos = this.cache('element-bounds', function() { + return getBounds(_this.element); + }); + width = elementPos.width, height = elementPos.height; + if (width === 0 && height === 0 && (this.lastSize != null)) { + _ref1 = this.lastSize, width = _ref1.width, height = _ref1.height; + } else { + this.lastSize = { + width: width, + height: height + }; + } + targetSize = targetPos = this.cache('target-bounds', function() { + return _this.getTargetBounds(); + }); + offset = offsetToPx(attachmentToOffset(this.attachment), { + width: width, + height: height + }); + targetOffset = offsetToPx(attachmentToOffset(targetAttachment), targetSize); + manualOffset = offsetToPx(this.offset, { + width: width, + height: height + }); + manualTargetOffset = offsetToPx(this.targetOffset, targetSize); + offset = addOffset(offset, manualOffset); + targetOffset = addOffset(targetOffset, manualTargetOffset); + left = targetPos.left + targetOffset.left - offset.left; + top = targetPos.top + targetOffset.top - offset.top; + _ref2 = Tether.modules; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + module = _ref2[_i]; + ret = module.position.call(this, { + left: left, + top: top, + targetAttachment: targetAttachment, + targetPos: targetPos, + attachment: this.attachment, + elementPos: elementPos, + offset: offset, + targetOffset: targetOffset, + manualOffset: manualOffset, + manualTargetOffset: manualTargetOffset, + scrollbarSize: scrollbarSize + }); + if ((ret == null) || typeof ret !== 'object') { + continue; + } else if (ret === false) { + return false; + } else { + top = ret.top, left = ret.left; + } + } + next = { + page: { + top: top, + left: left + }, + viewport: { + top: top - pageYOffset, + bottom: pageYOffset - top - height + innerHeight, + left: left - pageXOffset, + right: pageXOffset - left - width + innerWidth + } + }; + if (document.body.scrollWidth > window.innerWidth) { + scrollbarSize = this.cache('scrollbar-size', getScrollBarSize); + next.viewport.bottom -= scrollbarSize.height; + } + if (document.body.scrollHeight > window.innerHeight) { + scrollbarSize = this.cache('scrollbar-size', getScrollBarSize); + next.viewport.right -= scrollbarSize.width; + } + if (((_ref3 = document.body.style.position) !== '' && _ref3 !== 'static') || ((_ref4 = document.body.parentElement.style.position) !== '' && _ref4 !== 'static')) { + next.page.bottom = document.body.scrollHeight - top - height; + next.page.right = document.body.scrollWidth - left - width; + } + if (((_ref5 = this.options.optimizations) != null ? _ref5.moveElement : void 0) !== false && (this.targetModifier == null)) { + offsetParent = this.cache('target-offsetparent', function() { + return getOffsetParent(_this.target); + }); + offsetPosition = this.cache('target-offsetparent-bounds', function() { + return getBounds(offsetParent); + }); + offsetParentStyle = getComputedStyle(offsetParent); + elementStyle = getComputedStyle(this.element); + offsetParentSize = offsetPosition; + offsetBorder = {}; + _ref6 = ['Top', 'Left', 'Bottom', 'Right']; + for (_j = 0, _len1 = _ref6.length; _j < _len1; _j++) { + side = _ref6[_j]; + offsetBorder[side.toLowerCase()] = parseFloat(offsetParentStyle["border" + side + "Width"]); + } + offsetPosition.right = document.body.scrollWidth - offsetPosition.left - offsetParentSize.width + offsetBorder.right; + offsetPosition.bottom = document.body.scrollHeight - offsetPosition.top - offsetParentSize.height + offsetBorder.bottom; + if (next.page.top >= (offsetPosition.top + offsetBorder.top) && next.page.bottom >= offsetPosition.bottom) { + if (next.page.left >= (offsetPosition.left + offsetBorder.left) && next.page.right >= offsetPosition.right) { + scrollTop = offsetParent.scrollTop; + scrollLeft = offsetParent.scrollLeft; + next.offset = { + top: next.page.top - offsetPosition.top + scrollTop - offsetBorder.top, + left: next.page.left - offsetPosition.left + scrollLeft - offsetBorder.left + }; + } + } + } + this.move(next); + this.history.unshift(next); + if (this.history.length > 3) { + this.history.pop(); + } + if (flushChanges) { + flush(); + } + return true; + }; + + _Tether.prototype.move = function(position) { + var css, elVal, found, key, moved, offsetParent, point, same, transcribe, type, val, write, writeCSS, _i, _len, _ref1, _ref2, + _this = this; + if (this.element.parentNode == null) { + return; + } + same = {}; + for (type in position) { + same[type] = {}; + for (key in position[type]) { + found = false; + _ref1 = this.history; + for (_i = 0, _len = _ref1.length; _i < _len; _i++) { + point = _ref1[_i]; + if (!within((_ref2 = point[type]) != null ? _ref2[key] : void 0, position[type][key])) { + found = true; + break; + } + } + if (!found) { + same[type][key] = true; + } + } + } + css = { + top: '', + left: '', + right: '', + bottom: '' + }; + transcribe = function(same, pos) { + var xPos, yPos, _ref3; + if (((_ref3 = _this.options.optimizations) != null ? _ref3.gpu : void 0) !== false) { + if (same.top) { + css.top = 0; + yPos = pos.top; + } else { + css.bottom = 0; + yPos = -pos.bottom; + } + if (same.left) { + css.left = 0; + xPos = pos.left; + } else { + css.right = 0; + xPos = -pos.right; + } + css[transformKey] = "translateX(" + (Math.round(xPos)) + "px) translateY(" + (Math.round(yPos)) + "px)"; + if (transformKey !== 'msTransform') { + return css[transformKey] += " translateZ(0)"; + } + } else { + if (same.top) { + css.top = "" + pos.top + "px"; + } else { + css.bottom = "" + pos.bottom + "px"; + } + if (same.left) { + return css.left = "" + pos.left + "px"; + } else { + return css.right = "" + pos.right + "px"; + } + } + }; + moved = false; + if ((same.page.top || same.page.bottom) && (same.page.left || same.page.right)) { + css.position = 'absolute'; + transcribe(same.page, position.page); + } else if ((same.viewport.top || same.viewport.bottom) && (same.viewport.left || same.viewport.right)) { + css.position = 'fixed'; + transcribe(same.viewport, position.viewport); + } else if ((same.offset != null) && same.offset.top && same.offset.left) { + css.position = 'absolute'; + offsetParent = this.cache('target-offsetparent', function() { + return getOffsetParent(_this.target); + }); + if (getOffsetParent(this.element) !== offsetParent) { + defer(function() { + _this.element.parentNode.removeChild(_this.element); + return offsetParent.appendChild(_this.element); + }); + } + transcribe(same.offset, position.offset); + moved = true; + } else { + css.position = 'absolute'; + transcribe({ + top: true, + left: true + }, position.page); + } + if (!moved && this.element.parentNode.tagName !== 'BODY') { + this.element.parentNode.removeChild(this.element); + document.body.appendChild(this.element); + } + writeCSS = {}; + write = false; + for (key in css) { + val = css[key]; + elVal = this.element.style[key]; + if (elVal !== '' && val !== '' && (key === 'top' || key === 'left' || key === 'bottom' || key === 'right')) { + elVal = parseFloat(elVal); + val = parseFloat(val); + } + if (elVal !== val) { + write = true; + writeCSS[key] = css[key]; + } + } + if (write) { + return defer(function() { + return extend(_this.element.style, writeCSS); + }); + } + }; + + return _Tether; + + })(); + + Tether.position = position; + + this.Tether = extend(_Tether, Tether); + +}).call(this); + +(function() { + var BOUNDS_FORMAT, MIRROR_ATTACH, defer, extend, getBoundingRect, getBounds, getOuterSize, getSize, updateClasses, _ref, + __indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; + + _ref = this.Tether.Utils, getOuterSize = _ref.getOuterSize, getBounds = _ref.getBounds, getSize = _ref.getSize, extend = _ref.extend, updateClasses = _ref.updateClasses, defer = _ref.defer; + + MIRROR_ATTACH = { + left: 'right', + right: 'left', + top: 'bottom', + bottom: 'top', + middle: 'middle' + }; + + BOUNDS_FORMAT = ['left', 'top', 'right', 'bottom']; + + getBoundingRect = function(tether, to) { + var i, pos, side, size, style, _i, _len; + if (to === 'scrollParent') { + to = tether.scrollParent; + } else if (to === 'window') { + to = [pageXOffset, pageYOffset, innerWidth + pageXOffset, innerHeight + pageYOffset]; + } + if (to === document) { + to = to.documentElement; + } + if (to.nodeType != null) { + pos = size = getBounds(to); + style = getComputedStyle(to); + to = [pos.left, pos.top, size.width + pos.left, size.height + pos.top]; + for (i = _i = 0, _len = BOUNDS_FORMAT.length; _i < _len; i = ++_i) { + side = BOUNDS_FORMAT[i]; + side = side[0].toUpperCase() + side.substr(1); + if (side === 'Top' || side === 'Left') { + to[i] += parseFloat(style["border" + side + "Width"]); + } else { + to[i] -= parseFloat(style["border" + side + "Width"]); + } + } + } + return to; + }; + + this.Tether.modules.push({ + position: function(_arg) { + var addClasses, allClasses, attachment, bounds, changeAttachX, changeAttachY, cls, constraint, eAttachment, height, left, oob, oobClass, p, pin, pinned, pinnedClass, removeClass, side, tAttachment, targetAttachment, targetHeight, targetSize, targetWidth, to, top, width, _i, _j, _k, _l, _len, _len1, _len2, _len3, _len4, _len5, _m, _n, _ref1, _ref2, _ref3, _ref4, _ref5, _ref6, _ref7, _ref8, + _this = this; + top = _arg.top, left = _arg.left, targetAttachment = _arg.targetAttachment; + if (!this.options.constraints) { + return true; + } + removeClass = function(prefix) { + var side, _i, _len, _results; + _this.removeClass(prefix); + _results = []; + for (_i = 0, _len = BOUNDS_FORMAT.length; _i < _len; _i++) { + side = BOUNDS_FORMAT[_i]; + _results.push(_this.removeClass("" + prefix + "-" + side)); + } + return _results; + }; + _ref1 = this.cache('element-bounds', function() { + return getBounds(_this.element); + }), height = _ref1.height, width = _ref1.width; + if (width === 0 && height === 0 && (this.lastSize != null)) { + _ref2 = this.lastSize, width = _ref2.width, height = _ref2.height; + } + targetSize = this.cache('target-bounds', function() { + return _this.getTargetBounds(); + }); + targetHeight = targetSize.height; + targetWidth = targetSize.width; + tAttachment = {}; + eAttachment = {}; + allClasses = [this.getClass('pinned'), this.getClass('out-of-bounds')]; + _ref3 = this.options.constraints; + for (_i = 0, _len = _ref3.length; _i < _len; _i++) { + constraint = _ref3[_i]; + if (constraint.outOfBoundsClass) { + allClasses.push(constraint.outOfBoundsClass); + } + if (constraint.pinnedClass) { + allClasses.push(constraint.pinnedClass); + } + } + for (_j = 0, _len1 = allClasses.length; _j < _len1; _j++) { + cls = allClasses[_j]; + _ref4 = ['left', 'top', 'right', 'bottom']; + for (_k = 0, _len2 = _ref4.length; _k < _len2; _k++) { + side = _ref4[_k]; + allClasses.push("" + cls + "-" + side); + } + } + addClasses = []; + tAttachment = extend({}, targetAttachment); + eAttachment = extend({}, this.attachment); + _ref5 = this.options.constraints; + for (_l = 0, _len3 = _ref5.length; _l < _len3; _l++) { + constraint = _ref5[_l]; + to = constraint.to, attachment = constraint.attachment, pin = constraint.pin; + if (attachment == null) { + attachment = ''; + } + if (__indexOf.call(attachment, ' ') >= 0) { + _ref6 = attachment.split(' '), changeAttachY = _ref6[0], changeAttachX = _ref6[1]; + } else { + changeAttachX = changeAttachY = attachment; + } + bounds = getBoundingRect(this, to); + if (changeAttachY === 'target' || changeAttachY === 'both') { + if (top < bounds[1] && tAttachment.top === 'top') { + top += targetHeight; + tAttachment.top = 'bottom'; + } + if (top + height > bounds[3] && tAttachment.top === 'bottom') { + top -= targetHeight; + tAttachment.top = 'top'; + } + } + if (changeAttachY === 'together') { + if (top < bounds[1] && tAttachment.top === 'top') { + if (eAttachment.top === 'bottom') { + top += targetHeight; + tAttachment.top = 'bottom'; + top += height; + eAttachment.top = 'top'; + } else if (eAttachment.top === 'top') { + top += targetHeight; + tAttachment.top = 'bottom'; + top -= height; + eAttachment.top = 'bottom'; + } + } + if (top + height > bounds[3] && tAttachment.top === 'bottom') { + if (eAttachment.top === 'top') { + top -= targetHeight; + tAttachment.top = 'top'; + top -= height; + eAttachment.top = 'bottom'; + } else if (eAttachment.top === 'bottom') { + top -= targetHeight; + tAttachment.top = 'top'; + top += height; + eAttachment.top = 'top'; + } + } + if (tAttachment.top === 'middle') { + if (top + height > bounds[3] && eAttachment.top === 'top') { + top -= height; + eAttachment.top = 'bottom'; + } else if (top < bounds[1] && eAttachment.top === 'bottom') { + top += height; + eAttachment.top = 'top'; + } + } + } + if (changeAttachX === 'target' || changeAttachX === 'both') { + if (left < bounds[0] && tAttachment.left === 'left') { + left += targetWidth; + tAttachment.left = 'right'; + } + if (left + width > bounds[2] && tAttachment.left === 'right') { + left -= targetWidth; + tAttachment.left = 'left'; + } + } + if (changeAttachX === 'together') { + if (left < bounds[0] && tAttachment.left === 'left') { + if (eAttachment.left === 'right') { + left += targetWidth; + tAttachment.left = 'right'; + left += width; + eAttachment.left = 'left'; + } else if (eAttachment.left === 'left') { + left += targetWidth; + tAttachment.left = 'right'; + left -= width; + eAttachment.left = 'right'; + } + } else if (left + width > bounds[2] && tAttachment.left === 'right') { + if (eAttachment.left === 'left') { + left -= targetWidth; + tAttachment.left = 'left'; + left -= width; + eAttachment.left = 'right'; + } else if (eAttachment.left === 'right') { + left -= targetWidth; + tAttachment.left = 'left'; + left += width; + eAttachment.left = 'left'; + } + } else if (tAttachment.left === 'center') { + if (left + width > bounds[2] && eAttachment.left === 'left') { + left -= width; + eAttachment.left = 'right'; + } else if (left < bounds[0] && eAttachment.left === 'right') { + left += width; + eAttachment.left = 'left'; + } + } + } + if (changeAttachY === 'element' || changeAttachY === 'both') { + if (top < bounds[1] && eAttachment.top === 'bottom') { + top += height; + eAttachment.top = 'top'; + } + if (top + height > bounds[3] && eAttachment.top === 'top') { + top -= height; + eAttachment.top = 'bottom'; + } + } + if (changeAttachX === 'element' || changeAttachX === 'both') { + if (left < bounds[0] && eAttachment.left === 'right') { + left += width; + eAttachment.left = 'left'; + } + if (left + width > bounds[2] && eAttachment.left === 'left') { + left -= width; + eAttachment.left = 'right'; + } + } + if (typeof pin === 'string') { + pin = (function() { + var _len4, _m, _ref7, _results; + _ref7 = pin.split(','); + _results = []; + for (_m = 0, _len4 = _ref7.length; _m < _len4; _m++) { + p = _ref7[_m]; + _results.push(p.trim()); + } + return _results; + })(); + } else if (pin === true) { + pin = ['top', 'left', 'right', 'bottom']; + } + pin || (pin = []); + pinned = []; + oob = []; + if (top < bounds[1]) { + if (__indexOf.call(pin, 'top') >= 0) { + top = bounds[1]; + pinned.push('top'); + } else { + oob.push('top'); + } + } + if (top + height > bounds[3]) { + if (__indexOf.call(pin, 'bottom') >= 0) { + top = bounds[3] - height; + pinned.push('bottom'); + } else { + oob.push('bottom'); + } + } + if (left < bounds[0]) { + if (__indexOf.call(pin, 'left') >= 0) { + left = bounds[0]; + pinned.push('left'); + } else { + oob.push('left'); + } + } + if (left + width > bounds[2]) { + if (__indexOf.call(pin, 'right') >= 0) { + left = bounds[2] - width; + pinned.push('right'); + } else { + oob.push('right'); + } + } + if (pinned.length) { + pinnedClass = (_ref7 = this.options.pinnedClass) != null ? _ref7 : this.getClass('pinned'); + addClasses.push(pinnedClass); + for (_m = 0, _len4 = pinned.length; _m < _len4; _m++) { + side = pinned[_m]; + addClasses.push("" + pinnedClass + "-" + side); + } + } + if (oob.length) { + oobClass = (_ref8 = this.options.outOfBoundsClass) != null ? _ref8 : this.getClass('out-of-bounds'); + addClasses.push(oobClass); + for (_n = 0, _len5 = oob.length; _n < _len5; _n++) { + side = oob[_n]; + addClasses.push("" + oobClass + "-" + side); + } + } + if (__indexOf.call(pinned, 'left') >= 0 || __indexOf.call(pinned, 'right') >= 0) { + eAttachment.left = tAttachment.left = false; + } + if (__indexOf.call(pinned, 'top') >= 0 || __indexOf.call(pinned, 'bottom') >= 0) { + eAttachment.top = tAttachment.top = false; + } + if (tAttachment.top !== targetAttachment.top || tAttachment.left !== targetAttachment.left || eAttachment.top !== this.attachment.top || eAttachment.left !== this.attachment.left) { + this.updateAttachClasses(eAttachment, tAttachment); + } + } + defer(function() { + updateClasses(_this.target, addClasses, allClasses); + return updateClasses(_this.element, addClasses, allClasses); + }); + return { + top: top, + left: left + }; + } + }); + +}).call(this); + +(function() { + var defer, getBounds, updateClasses, _ref; + + _ref = this.Tether.Utils, getBounds = _ref.getBounds, updateClasses = _ref.updateClasses, defer = _ref.defer; + + this.Tether.modules.push({ + position: function(_arg) { + var abutted, addClasses, allClasses, bottom, height, left, right, side, sides, targetPos, top, width, _i, _j, _k, _l, _len, _len1, _len2, _len3, _ref1, _ref2, _ref3, _ref4, _ref5, + _this = this; + top = _arg.top, left = _arg.left; + _ref1 = this.cache('element-bounds', function() { + return getBounds(_this.element); + }), height = _ref1.height, width = _ref1.width; + targetPos = this.getTargetBounds(); + bottom = top + height; + right = left + width; + abutted = []; + if (top <= targetPos.bottom && bottom >= targetPos.top) { + _ref2 = ['left', 'right']; + for (_i = 0, _len = _ref2.length; _i < _len; _i++) { + side = _ref2[_i]; + if ((_ref3 = targetPos[side]) === left || _ref3 === right) { + abutted.push(side); + } + } + } + if (left <= targetPos.right && right >= targetPos.left) { + _ref4 = ['top', 'bottom']; + for (_j = 0, _len1 = _ref4.length; _j < _len1; _j++) { + side = _ref4[_j]; + if ((_ref5 = targetPos[side]) === top || _ref5 === bottom) { + abutted.push(side); + } + } + } + allClasses = []; + addClasses = []; + sides = ['left', 'top', 'right', 'bottom']; + allClasses.push(this.getClass('abutted')); + for (_k = 0, _len2 = sides.length; _k < _len2; _k++) { + side = sides[_k]; + allClasses.push("" + (this.getClass('abutted')) + "-" + side); + } + if (abutted.length) { + addClasses.push(this.getClass('abutted')); + } + for (_l = 0, _len3 = abutted.length; _l < _len3; _l++) { + side = abutted[_l]; + addClasses.push("" + (this.getClass('abutted')) + "-" + side); + } + defer(function() { + updateClasses(_this.target, addClasses, allClasses); + return updateClasses(_this.element, addClasses, allClasses); + }); + return true; + } + }); + +}).call(this); + +(function() { + this.Tether.modules.push({ + position: function(_arg) { + var left, result, shift, shiftLeft, shiftTop, top, _ref; + top = _arg.top, left = _arg.left; + if (!this.options.shift) { + return; + } + result = function(val) { + if (typeof val === 'function') { + return val.call(this, { + top: top, + left: left + }); + } else { + return val; + } + }; + shift = result(this.options.shift); + if (typeof shift === 'string') { + shift = shift.split(' '); + shift[1] || (shift[1] = shift[0]); + shiftTop = shift[0], shiftLeft = shift[1]; + shiftTop = parseFloat(shiftTop, 10); + shiftLeft = parseFloat(shiftLeft, 10); + } else { + _ref = [shift.top, shift.left], shiftTop = _ref[0], shiftLeft = _ref[1]; + } + top += shiftTop; + left += shiftLeft; + return { + top: top, + left: left + }; + } + }); + +}).call(this); + +return this.Tether; + +})); diff --git a/demo/res/img/sprite-green.png b/demo/res/img/sprite-green.png new file mode 100755 index 0000000000..89fc8f2343 Binary files /dev/null and b/demo/res/img/sprite-green.png differ diff --git a/demo/res/img/sprite-orange.png b/demo/res/img/sprite-orange.png new file mode 100755 index 0000000000..49cfa479dc Binary files /dev/null and b/demo/res/img/sprite-orange.png differ diff --git a/demo/src/DemoInitializer.js b/demo/src/DemoInitializer.js index a53e4dc617..16ad0739d7 100644 --- a/demo/src/DemoInitializer.js +++ b/demo/src/DemoInitializer.js @@ -20,13 +20,40 @@ * at runtime from the About dialog for additional information. *****************************************************************************/ /*global define*/ +require.config({ +/* paths: { + tether: "demo/lib/tether/tether", + shepherd: "demo/lib/shepherd/shepherd.min" + }, + shim: { + tether: { + exports: "tether" + }, + shepherd: { + deps: ["tether"], + exports: "shepherd" + } + }*/ + paths: { + hopscotch: "demo/lib/hopscotch/hopscotch.min" + }, + shim: { + tourist: { + exports: "hopscotch" + } + } +}); define( - ["../../platform/features/conductor/src/ConductorRepresenter"], - function (ConductorRepresenter){ + [ + "../../platform/features/conductor/src/ConductorRepresenter", + "hopscotch", + "zepto" + ], + function (ConductorRepresenter, hopscotch, $){ "use strict"; - function DemoInitializer(representers) { + function DemoInitializer($timeout, representers) { function indexOf(array, callback) { return array.reduce(function(previous, element, index) { @@ -48,6 +75,53 @@ define( } removeRepresenter(ConductorRepresenter); + + $timeout(function() { + var tour = { + id: "hello-hopscotch", + steps: [ + { + title: "The Object Tree", + content: "The object tree contains telemetry and" + + " view objects", + target: document.querySelector("mct-tree ul.tree"), + placement: "right" + }, + { + title: "Creating objects", + content: "New objects can be created under" + + " the My Items folder using the " + + " Create button", + target: document.querySelector(".create-btn"), + placement: "bottom" + }, + { + title: "Composing objects", + content: "Objects can be composed by dragging" + + " them from the tree...", + target: document.querySelector("mct-tree" + + " ul.tree"), + placement: "right" + }, + { + title: "Composing objects (cont.)", + content: "...into the current view", + target: document.querySelector(".object-holder-main"), + placement: "top" + }, + { + title: "Create a layout", + content: "Try composing a Display Layout by creating it from the create menu, and then dragging some objects into it.", + target: document.querySelector(".create-btn"), + placement: "right" + } + ] + }; + hopscotch.endTour(true); + // Start the tour! + hopscotch.startTour(tour); + + }, 3000); } return DemoInitializer; diff --git a/demo/src/conductor/ConductorPolicy.js b/demo/src/conductor/ConductorPolicy.js index 20b8de910b..c2b6e3f231 100644 --- a/demo/src/conductor/ConductorPolicy.js +++ b/demo/src/conductor/ConductorPolicy.js @@ -48,6 +48,12 @@ define( }, true); } + function or(array) { + return array.reduce(function (previous, next) { + return previous || next; + }, false); + } + /** * @param {DomainObject} candidate * @returns {Promise} a promise resolved with true if the object @@ -66,7 +72,7 @@ define( if (composition.length === 0 ) { return fastPromise(false); } else { - return self.$q.all(composition.map(self.allow.bind(self))).then(and); + return self.$q.all(composition.map(self.allow.bind(self))).then(or); } }); } else { diff --git a/demo/src/conductor/DemoConductorRepresenter.js b/demo/src/conductor/DemoConductorRepresenter.js index 6515fab67e..1fdfab2b5d 100644 --- a/demo/src/conductor/DemoConductorRepresenter.js +++ b/demo/src/conductor/DemoConductorRepresenter.js @@ -36,6 +36,7 @@ define( conductorService, views, throttle, + navigationService, scope, element ) { @@ -43,6 +44,7 @@ define( this.element = element; this.views = views; this.conductorPolicy = new ConductorPolicy($q); + this.navigationService = navigationService; ConductorRepresenter.call(this, throttle, @@ -57,7 +59,8 @@ define( DemoConductorRepresenter.prototype.represent = function (representation, representedObject) { var self = this; - if (this.views.indexOf(representation) !== -1) { + if (this.views.indexOf(representation) !== -1 && representedObject.getId() === this.navigationService.getNavigation().getId()) { + this.conductorPolicy.allow(representedObject).then(function (show) { if (show && representation.type !== 'folder') { ConductorRepresenter.prototype.represent.call(self, representation, representedObject); @@ -66,7 +69,5 @@ define( } }; - DemoConductorRepresenter.prototype.destroy = function destroy() {}; - return DemoConductorRepresenter; });