diff --git a/Site/Master-v5.master b/Site/Master-v5.master index 397e8355..38483c45 100644 --- a/Site/Master-v5.master +++ b/Site/Master-v5.master @@ -10,6 +10,7 @@ + @@ -31,6 +32,7 @@ + @@ -354,9 +356,11 @@ // This JavaScript block is for the Master Modal Person Editor. $(document).ready(function() { - $('.EditCheck').switchbutton({ - checkedLabel: SwarmopsJS.unescape('<%= this.Localized_SwitchLabelOn_Upper %>'), - uncheckedLabel: SwarmopsJS.unescape('<%= this.Localized_SwitchLabelOff_Upper %>') + $('.MasterToggles').toggles( + { text: { + on: SwarmopsJS.unescape('<%= this.Localized_SwitchLabelOn_Upper %>'), + off: SwarmopsJS.unescape('<%= this.Localized_SwitchLabelOff_Upper %>') + } }).change(function() {}); }); diff --git a/Site/Scripts/jquery.toggles.js b/Site/Scripts/jquery.toggles.js new file mode 100644 index 00000000..38938d2b --- /dev/null +++ b/Site/Scripts/jquery.toggles.js @@ -0,0 +1,272 @@ +/** +@license jQuery Toggles v4.0.0 +Copyright 2012 - 2015 Simon Tabor - MIT License +https://github.com/simontabor/jquery-toggles / http://simontabor.com/labs/toggles +*/ +(function (root) { + + var factory = function ($) { + + var Toggles = root['Toggles'] = function (el, opts) { + var self = this; + + if (typeof opts === 'boolean' && el.data('toggles')) { + el.data('toggles').toggle(opts); + return; + } + + var dataAttr = [ + 'on', + 'drag', + 'click', + 'width', + 'height', + 'animate', + 'easing', + 'type', + 'checkbox' + ]; + var dataOpts = {}; + for (var i = 0; i < dataAttr.length; i++) { + var opt = el.data('toggle-' + dataAttr[i]); + if (typeof opt !== 'undefined') dataOpts[dataAttr[i]] = opt; + } + + // extend default opts with the users options + opts = $.extend({ + // can the toggle be dragged + 'drag': true, + // can it be clicked to toggle + 'click': true, + 'text': { + // text for the ON/OFF position + 'on': 'ON', + 'off': 'OFF' + }, + // is the toggle ON on init + 'on': false, + // animation time (ms) + 'animate': 250, + // animation transition easing function, + 'easing': 'swing', + // the checkbox to toggle (for use in forms) + 'checkbox': null, + // element that can be clicked on to toggle. removes binding from the toggle itself (use nesting) + 'clicker': null, + // width (falls back to 50px) + 'width': 0, + // height (falls back to 20px) + 'height': 0, + // defaults to a compact toggle, other option is 'select' where both options are shown at once + 'type': 'compact', + // the event name to fire when we toggle + 'event': 'toggle' + }, opts || {}, dataOpts); + + el.data('toggles', self); + + // set active to the opposite of what we want, so toggle will run properly + var active = !opts['on']; + + var selectType = opts['type'] === 'select'; + + // make checkbox a jquery element + var checkbox = $(opts['checkbox']); + + var clicker = opts['clicker'] && $(opts['clicker']); + + var height = opts['height'] || el.height() || 20; + var width = opts['width'] || el.width() || 50; + + el.height(height); + el.width(width); + + var div = function (name) { + return $('
'); + }; + + // wrapper inside toggle + var elSlide = div('slide'); + // inside slide, this bit moves + var elInner = div('inner'); + // the on/off divs + var elOn = div('on'); + var elOff = div('off'); + // the grip to drag the toggle + var elBlob = div('blob'); + + var halfHeight = height / 2; + var onOffWidth = width - halfHeight; + + var text = opts['text']; + + // set up the CSS for the individual elements + elOn + .css({ + height: height, + width: onOffWidth, + textIndent: selectType ? '' : -height / 3, + lineHeight: height + 'px' + }) + .html(text['on']); + + elOff + .css({ + height: height, + width: onOffWidth, + marginLeft: selectType ? '' : -halfHeight, + textIndent: selectType ? '' : height / 3, + lineHeight: height + 'px' + }) + .html(text['off']); + + elBlob.css({ + height: height, + width: height, + marginLeft: -halfHeight + }); + + elInner.css({ + width: width * 2 - height, + marginLeft: selectType ? 0 : -width + height + }); + + if (selectType) { + elSlide.addClass('toggle-select'); + el.css('width', onOffWidth * 2); + elBlob.hide(); + } + + // construct the toggle + elInner.append(elOn, elBlob, elOff); + elSlide.html(elInner); + el.html(elSlide); + + var doToggle = self.toggle = function (state, noAnimate, noEvent) { + // check we arent already in the desired state + if (active === state) return; + + active = self['active'] = !active; + + el.data('toggle-active', active); + + elOff.toggleClass('active', !active); + elOn.toggleClass('active', active); + checkbox.prop('checked', active); + + if (!noEvent) el.trigger(opts['event'], active); + + if (selectType) return; + + var margin = active ? 0 : -width + height; + + // move the toggle! + elInner.stop().animate({ + 'marginLeft': margin + }, noAnimate ? 0 : opts['animate'], opts['easing']); + }; + + + // evt handler for click events + var clickHandler = function (e) { + // if the target isn't the blob or dragging is disabled, toggle! + if (!el.hasClass('disabled') && (e['target'] !== elBlob[0] || !opts['drag'])) { + doToggle(); + } + }; + + // if click is enabled and toggle isn't within the clicker element (stops double binding) + if (opts['click'] && (!clicker || !clicker.has(el).length)) { + el.on('click', clickHandler); + } + + // setup the clicker element + if (clicker) { + clicker.on('click', clickHandler); + } + + // bind up dragging stuff + if (opts['drag'] && !selectType) { + // time to begin the dragging parts/blob clicks + var diff; + var slideLimit = (width - height) / 4; + + // fired on mouseup and mouseleave events + var upLeave = function (e) { + el.off('mousemove'); + elSlide.off('mouseleave'); + elBlob.off('mouseup'); + + if (!diff && opts['click'] && e.type !== 'mouseleave') { + doToggle(); + return; + } + + var overBound = active ? diff < -slideLimit : diff > slideLimit; + if (overBound) { + // dragged far enough, toggle + doToggle(); + } else { + // reset to previous state + elInner.stop().animate({ + marginLeft: active ? 0 : -width + height + }, opts['animate'] / 2, opts['easing']); + } + }; + + var wh = -width + height; + + elBlob.on('mousedown', function (e) { + + if (el.hasClass('disabled')) return; + + // reset diff + diff = 0; + + elBlob.off('mouseup'); + elSlide.off('mouseleave'); + var cursor = e.pageX; + + el.on('mousemove', elBlob, function (e) { + diff = e.pageX - cursor; + var marginLeft; + + if (active) { + marginLeft = diff; + + // keep it within the limits + if (diff > 0) marginLeft = 0; + if (diff < wh) marginLeft = wh; + } else { + marginLeft = diff + wh; + + if (diff < 0) marginLeft = wh; + if (diff > -wh) marginLeft = 0; + } + + elInner.css('margin-left', marginLeft); + }); + + elBlob.on('mouseup', upLeave); + elSlide.on('mouseleave', upLeave); + }); + } + + // toggle the toggle to the correct state with no animation and no event + doToggle(opts['on'], true, true); + }; + + $.fn['toggles'] = function (opts) { + return this.each(function () { + new Toggles($(this), opts); + }); + }; + }; + + if (typeof define === 'function' && define['amd']) { + define(['jquery'], factory); + } else { + factory(root['jQuery'] || root['Zepto'] || root['ender'] || root['$'] || $); + } + +})(this); \ No newline at end of file diff --git a/Site/Scripts/jquery.toggles.min.js b/Site/Scripts/jquery.toggles.min.js new file mode 100644 index 00000000..dabe912c --- /dev/null +++ b/Site/Scripts/jquery.toggles.min.js @@ -0,0 +1,11 @@ +/* + jQuery Toggles v4.0.0 +Copyright 2012 - 2015 Simon Tabor - MIT License +https://github.com/simontabor/jquery-toggles / http://simontabor.com/labs/toggles +*/ +(function(g){function p(q){var p=g.Toggles=function(c,a){var g=this;if("boolean"===typeof a&&c.data("toggles"))c.data("toggles").toggle(a);else{for(var k="on drag click width height animate easing type checkbox".split(" "),b={},l=0;l')},r=b("slide"),s=b("inner"),w=b("on"),x=b("off"),h=b("blob"),b=d/2,l=m-b,t=a.text;w.css({height:d,width:l,textIndent:n?"":-d/3,lineHeight:d+"px"}).html(t.on);x.css({height:d,width:l,marginLeft:n?"":-b,textIndent:n?"":d/3,lineHeight:d+"px"}).html(t.off);h.css({height:d,width:d,marginLeft:-b}); +s.css({width:2*m-d,marginLeft:n?0:-m+d});n&&(r.addClass("toggle-select"),c.css("width",2*l),h.hide());s.append(w,h,x);r.html(s);c.html(r);var v=g.toggle=function(b,e,A){f!==b&&(f=g.active=!f,c.data("toggle-active",f),x.toggleClass("active",!f),w.toggleClass("active",f),p.prop("checked",f),A||c.trigger(a.event,f),n||(b=f?0:-m+d,s.stop().animate({marginLeft:b},e?0:a.animate,a.easing)))},b=function(b){c.hasClass("disabled")||b.target===h[0]&&a.drag||v()};if(a.click&&(!k||!k.has(c).length))c.on("click", +b);if(k)k.on("click",b);if(a.drag&&!n){var e,y=(m-d)/4,z=function(b){c.off("mousemove");r.off("mouseleave");h.off("mouseup");!e&&a.click&&"mouseleave"!==b.type?v():(f?e<-y:e>y)?v():s.stop().animate({marginLeft:f?0:-m+d},a.animate/2,a.easing)},u=-m+d;h.on("mousedown",function(a){if(!c.hasClass("disabled")){e=0;h.off("mouseup");r.off("mouseleave");var b=a.pageX;c.on("mousemove",h,function(a){e=a.pageX-b;f?(a=e,0e&&(a=u),e>-u&&(a=0));s.css("margin-left",a)});h.on("mouseup", +z);r.on("mouseleave",z)}})}v(a.on,!0,!0)}};q.fn.toggles=function(c){return this.each(function(){new p(q(this),c)})}}"function"===typeof define&&define.amd?define(["jquery"],p):p(g.jQuery||g.Zepto||g.ender||g.$||$)})(this); + diff --git a/Site/Site.csproj b/Site/Site.csproj index 5d178f3a..f8062d6c 100644 --- a/Site/Site.csproj +++ b/Site/Site.csproj @@ -1725,6 +1725,8 @@ + + @@ -1765,6 +1767,7 @@ + diff --git a/Site/Style/jquery.toggles.css b/Site/Style/jquery.toggles.css new file mode 100644 index 00000000..1db9a731 --- /dev/null +++ b/Site/Style/jquery.toggles.css @@ -0,0 +1,75 @@ +.toggle-slide { + overflow: hidden; + cursor: pointer; + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + direction: ltr; + text-align: center; +} +div.disabled > .toggle-slide { + opacity: 0.7; + pointer-events: none; +} +.toggle-slide .toggle-on, +.toggle-slide .toggle-off, +.toggle-slide .toggle-blob { + float: left; +} +.toggle-slide .toggle-blob { + position: relative; + z-index: 99; + cursor: hand; + cursor: grab; +} + +.toggle-iphone .toggle-slide { + border-radius: 9999px; + box-shadow: 0 0 0 1px #999; +} +.toggle-iphone .toggle-on, +.toggle-iphone .toggle-off { + color: white; + font-size: 18px; + font-weight: bold; + text-shadow: 0 0 8px rgba(0, 0, 0, 0.5); +} +.toggle-iphone .toggle-on { + border-radius: 9999px 0 0 9999px; + background: #037bda; + box-shadow: inset 2px 2px 5px rgba(0, 0, 0, 0.4); +} +.toggle-iphone .toggle-on:after { + background: -webkit-linear-gradient(#1189f1, #3797ef); + background: linear-gradient(#1189f1, #3797ef); + height: 50%; + content: ''; + margin-top: -19%; + display: block; + border-radius: 9999px; + margin-left: 10%; +} +.toggle-iphone .toggle-off { + box-shadow: inset -2px 2px 5px rgba(0, 0, 0, 0.4); + border-radius: 0 9999px 9999px 0; + color: #828282; + background: #ECECEC; + text-shadow: 0 0 1px white; +} +.toggle-iphone .toggle-off:after { + background: -webkit-linear-gradient(#fafafa, #fdfdfd); + background: linear-gradient(#fafafa, #fdfdfd); + height: 50%; + content: ''; + margin-top: -19%; + display: block; + margin-right: 10%; + border-radius: 9999px; +} +.toggle-iphone .toggle-blob { + border-radius: 50px; + background: -webkit-linear-gradient(#d1d1d1, #fafafa); + background: linear-gradient(#d1d1d1, #fafafa); + box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.6), inset 0 0 0 2px white, 0 0 3px rgba(0, 0, 0, 0.6); +} \ No newline at end of file