diff --git a/css/color-picker.css b/Mobile/css/color-picker.css similarity index 100% rename from css/color-picker.css rename to Mobile/css/color-picker.css diff --git a/css/fonts.less b/Mobile/css/fonts.less similarity index 100% rename from css/fonts.less rename to Mobile/css/fonts.less diff --git a/css/fonts/MozTT-Bold.ttf b/Mobile/css/fonts/MozTT-Bold.ttf similarity index 100% rename from css/fonts/MozTT-Bold.ttf rename to Mobile/css/fonts/MozTT-Bold.ttf diff --git a/css/fonts/MozTT-Light.ttf b/Mobile/css/fonts/MozTT-Light.ttf similarity index 100% rename from css/fonts/MozTT-Light.ttf rename to Mobile/css/fonts/MozTT-Light.ttf diff --git a/css/fonts/MozTT-Medium.ttf b/Mobile/css/fonts/MozTT-Medium.ttf similarity index 100% rename from css/fonts/MozTT-Medium.ttf rename to Mobile/css/fonts/MozTT-Medium.ttf diff --git a/css/fonts/MozTT-Regular.ttf b/Mobile/css/fonts/MozTT-Regular.ttf similarity index 100% rename from css/fonts/MozTT-Regular.ttf rename to Mobile/css/fonts/MozTT-Regular.ttf diff --git a/css/imgs/bg_overlay_pressed_1.png b/Mobile/css/imgs/bg_overlay_pressed_1.png similarity index 100% rename from css/imgs/bg_overlay_pressed_1.png rename to Mobile/css/imgs/bg_overlay_pressed_1.png diff --git a/css/imgs/bg_overlay_pressed_2.png b/Mobile/css/imgs/bg_overlay_pressed_2.png similarity index 100% rename from css/imgs/bg_overlay_pressed_2.png rename to Mobile/css/imgs/bg_overlay_pressed_2.png diff --git a/css/imgs/clear.png b/Mobile/css/imgs/clear.png similarity index 100% rename from css/imgs/clear.png rename to Mobile/css/imgs/clear.png diff --git a/css/imgs/div_line_lg_black.png b/Mobile/css/imgs/div_line_lg_black.png similarity index 100% rename from css/imgs/div_line_lg_black.png rename to Mobile/css/imgs/div_line_lg_black.png diff --git a/css/imgs/div_line_sm_black.png b/Mobile/css/imgs/div_line_sm_black.png similarity index 100% rename from css/imgs/div_line_sm_black.png rename to Mobile/css/imgs/div_line_sm_black.png diff --git a/css/imgs/download.png b/Mobile/css/imgs/download.png similarity index 100% rename from css/imgs/download.png rename to Mobile/css/imgs/download.png diff --git a/css/imgs/header_bg_black.png b/Mobile/css/imgs/header_bg_black.png similarity index 100% rename from css/imgs/header_bg_black.png rename to Mobile/css/imgs/header_bg_black.png diff --git a/css/imgs/menu.png b/Mobile/css/imgs/menu.png similarity index 100% rename from css/imgs/menu.png rename to Mobile/css/imgs/menu.png diff --git a/css/imgs/redo.png b/Mobile/css/imgs/redo.png similarity index 100% rename from css/imgs/redo.png rename to Mobile/css/imgs/redo.png diff --git a/css/imgs/settings.png b/Mobile/css/imgs/settings.png similarity index 100% rename from css/imgs/settings.png rename to Mobile/css/imgs/settings.png diff --git a/css/imgs/undo.png b/Mobile/css/imgs/undo.png similarity index 100% rename from css/imgs/undo.png rename to Mobile/css/imgs/undo.png diff --git a/css/main.less b/Mobile/css/main.less similarity index 80% rename from css/main.less rename to Mobile/css/main.less index 2ae0bc2..ea83e2e 100644 --- a/css/main.less +++ b/Mobile/css/main.less @@ -65,26 +65,62 @@ button { border: none; } -.picker { +.close { + display: block; + width: 2rem; + height: 2rem; + padding: 0 0 0.2rem 0.2rem; + font-size: 10pt; + border: 1px solid rgb(227, 227, 227); + border-radius: 50%; + position: absolute; + text-align: center; + top: -2%; + left: 97%; +} + +.picker, .about { + font-family: 'MozTT-Light'; width: 30rem; - height: 30rem; + height: 24.6rem; position: absolute; left: 50%; top: 50%; - margin-top: -15rem; + margin-top: -12.3rem; margin-left: -15rem; - - #closePicker { - width: 2rem; - height: 2rem; - border: 1px solid rgb(227, 227, 227); - border-radius: 50%; - position: absolute; - top: 1rem; - left: 27rem; + + .color-picker { + margin: 0; } } +.about { + background: #262626; + padding: 1rem 2rem;; + height: 23rem; + margin-top: -11.5rem; + margin-left: -17rem; + border-radius: 0.2rem; + color: white; + box-shadow: 0 0 0.3rem black; + + a, a:link, a:visited, a:active { + color: white; + } + + .close { + background: #262626; + color: white; + border: 1px solid gray; + } + + p { + font-size: 11pt; + } + span { + font-size: 8pt; + } +} header { width: 100%; @@ -217,9 +253,13 @@ header { .bottom { position: absolute; bottom: 5rem; - button { + width: 100%; + button[class^='icon'] { margin-left: 3.5rem; } + button { + margin-left: 5rem; + } } } diff --git a/css/seekbars.css b/Mobile/css/seekbars.css similarity index 100% rename from css/seekbars.css rename to Mobile/css/seekbars.css diff --git a/css/seekbars/images/ui/handler.png b/Mobile/css/seekbars/images/ui/handler.png similarity index 100% rename from css/seekbars/images/ui/handler.png rename to Mobile/css/seekbars/images/ui/handler.png diff --git a/css/seekbars/images/ui/handler@1.5x.png b/Mobile/css/seekbars/images/ui/handler@1.5x.png similarity index 100% rename from css/seekbars/images/ui/handler@1.5x.png rename to Mobile/css/seekbars/images/ui/handler@1.5x.png diff --git a/css/seekbars/images/ui/handler@2x.png b/Mobile/css/seekbars/images/ui/handler@2x.png similarity index 100% rename from css/seekbars/images/ui/handler@2x.png rename to Mobile/css/seekbars/images/ui/handler@2x.png diff --git a/css/seekbars/seekbars.css b/Mobile/css/seekbars/seekbars.css similarity index 100% rename from css/seekbars/seekbars.css rename to Mobile/css/seekbars/seekbars.css diff --git a/css/switches.css b/Mobile/css/switches.css similarity index 100% rename from css/switches.css rename to Mobile/css/switches.css diff --git a/css/switches/images/check/danger.png b/Mobile/css/switches/images/check/danger.png similarity index 100% rename from css/switches/images/check/danger.png rename to Mobile/css/switches/images/check/danger.png diff --git a/css/switches/images/check/danger@1.5x.png b/Mobile/css/switches/images/check/danger@1.5x.png similarity index 100% rename from css/switches/images/check/danger@1.5x.png rename to Mobile/css/switches/images/check/danger@1.5x.png diff --git a/css/switches/images/check/danger@2x.png b/Mobile/css/switches/images/check/danger@2x.png similarity index 100% rename from css/switches/images/check/danger@2x.png rename to Mobile/css/switches/images/check/danger@2x.png diff --git a/css/switches/images/check/default.png b/Mobile/css/switches/images/check/default.png similarity index 100% rename from css/switches/images/check/default.png rename to Mobile/css/switches/images/check/default.png diff --git a/css/switches/images/check/default@1.5x.png b/Mobile/css/switches/images/check/default@1.5x.png similarity index 100% rename from css/switches/images/check/default@1.5x.png rename to Mobile/css/switches/images/check/default@1.5x.png diff --git a/css/switches/images/check/default@2x.png b/Mobile/css/switches/images/check/default@2x.png similarity index 100% rename from css/switches/images/check/default@2x.png rename to Mobile/css/switches/images/check/default@2x.png diff --git a/css/switches/images/radio/danger.png b/Mobile/css/switches/images/radio/danger.png similarity index 100% rename from css/switches/images/radio/danger.png rename to Mobile/css/switches/images/radio/danger.png diff --git a/css/switches/images/radio/danger@1.5x.png b/Mobile/css/switches/images/radio/danger@1.5x.png similarity index 100% rename from css/switches/images/radio/danger@1.5x.png rename to Mobile/css/switches/images/radio/danger@1.5x.png diff --git a/css/switches/images/radio/danger@2x.png b/Mobile/css/switches/images/radio/danger@2x.png similarity index 100% rename from css/switches/images/radio/danger@2x.png rename to Mobile/css/switches/images/radio/danger@2x.png diff --git a/css/switches/images/radio/default.png b/Mobile/css/switches/images/radio/default.png similarity index 100% rename from css/switches/images/radio/default.png rename to Mobile/css/switches/images/radio/default.png diff --git a/css/switches/images/radio/default@1.5x.png b/Mobile/css/switches/images/radio/default@1.5x.png similarity index 100% rename from css/switches/images/radio/default@1.5x.png rename to Mobile/css/switches/images/radio/default@1.5x.png diff --git a/css/switches/images/radio/default@2x.png b/Mobile/css/switches/images/radio/default@2x.png similarity index 100% rename from css/switches/images/radio/default@2x.png rename to Mobile/css/switches/images/radio/default@2x.png diff --git a/css/switches/images/switch/background.png b/Mobile/css/switches/images/switch/background.png similarity index 100% rename from css/switches/images/switch/background.png rename to Mobile/css/switches/images/switch/background.png diff --git a/css/switches/images/switch/background@1.5x.png b/Mobile/css/switches/images/switch/background@1.5x.png similarity index 100% rename from css/switches/images/switch/background@1.5x.png rename to Mobile/css/switches/images/switch/background@1.5x.png diff --git a/css/switches/images/switch/background_off.png b/Mobile/css/switches/images/switch/background_off.png similarity index 100% rename from css/switches/images/switch/background_off.png rename to Mobile/css/switches/images/switch/background_off.png diff --git a/css/switches/images/switch/background_off@1.5x.png b/Mobile/css/switches/images/switch/background_off@1.5x.png similarity index 100% rename from css/switches/images/switch/background_off@1.5x.png rename to Mobile/css/switches/images/switch/background_off@1.5x.png diff --git a/css/value_selector.css b/Mobile/css/value_selector.css similarity index 100% rename from css/value_selector.css rename to Mobile/css/value_selector.css diff --git a/css/value_selector/images/icons/checked.png b/Mobile/css/value_selector/images/icons/checked.png similarity index 100% rename from css/value_selector/images/icons/checked.png rename to Mobile/css/value_selector/images/icons/checked.png diff --git a/css/value_selector/images/icons/checked@1.5x.png b/Mobile/css/value_selector/images/icons/checked@1.5x.png similarity index 100% rename from css/value_selector/images/icons/checked@1.5x.png rename to Mobile/css/value_selector/images/icons/checked@1.5x.png diff --git a/css/value_selector/images/icons/checked@2x.png b/Mobile/css/value_selector/images/icons/checked@2x.png similarity index 100% rename from css/value_selector/images/icons/checked@2x.png rename to Mobile/css/value_selector/images/icons/checked@2x.png diff --git a/css/value_selector/images/ui/affirmative.png b/Mobile/css/value_selector/images/ui/affirmative.png similarity index 100% rename from css/value_selector/images/ui/affirmative.png rename to Mobile/css/value_selector/images/ui/affirmative.png diff --git a/css/value_selector/images/ui/default.png b/Mobile/css/value_selector/images/ui/default.png similarity index 100% rename from css/value_selector/images/ui/default.png rename to Mobile/css/value_selector/images/ui/default.png diff --git a/css/value_selector/images/ui/gradient.png b/Mobile/css/value_selector/images/ui/gradient.png similarity index 100% rename from css/value_selector/images/ui/gradient.png rename to Mobile/css/value_selector/images/ui/gradient.png diff --git a/css/value_selector/images/ui/gradient@1.5x.png b/Mobile/css/value_selector/images/ui/gradient@1.5x.png similarity index 100% rename from css/value_selector/images/ui/gradient@1.5x.png rename to Mobile/css/value_selector/images/ui/gradient@1.5x.png diff --git a/css/value_selector/images/ui/pattern.png b/Mobile/css/value_selector/images/ui/pattern.png similarity index 100% rename from css/value_selector/images/ui/pattern.png rename to Mobile/css/value_selector/images/ui/pattern.png diff --git a/css/value_selector/images/ui/shadow-invert.png b/Mobile/css/value_selector/images/ui/shadow-invert.png similarity index 100% rename from css/value_selector/images/ui/shadow-invert.png rename to Mobile/css/value_selector/images/ui/shadow-invert.png diff --git a/css/value_selector/images/ui/shadow-invert@1.5x.png b/Mobile/css/value_selector/images/ui/shadow-invert@1.5x.png similarity index 100% rename from css/value_selector/images/ui/shadow-invert@1.5x.png rename to Mobile/css/value_selector/images/ui/shadow-invert@1.5x.png diff --git a/css/value_selector/images/ui/shadow-invert@2x.png b/Mobile/css/value_selector/images/ui/shadow-invert@2x.png similarity index 100% rename from css/value_selector/images/ui/shadow-invert@2x.png rename to Mobile/css/value_selector/images/ui/shadow-invert@2x.png diff --git a/css/value_selector/images/ui/shadow.png b/Mobile/css/value_selector/images/ui/shadow.png similarity index 100% rename from css/value_selector/images/ui/shadow.png rename to Mobile/css/value_selector/images/ui/shadow.png diff --git a/css/value_selector/images/ui/shadow@1.5x.png b/Mobile/css/value_selector/images/ui/shadow@1.5x.png similarity index 100% rename from css/value_selector/images/ui/shadow@1.5x.png rename to Mobile/css/value_selector/images/ui/shadow@1.5x.png diff --git a/css/value_selector/images/ui/shadow@2x.png b/Mobile/css/value_selector/images/ui/shadow@2x.png similarity index 100% rename from css/value_selector/images/ui/shadow@2x.png rename to Mobile/css/value_selector/images/ui/shadow@2x.png diff --git a/Mobile/img/icons/MozillaFXOSIconTemplate1_overlay.png b/Mobile/img/icons/MozillaFXOSIconTemplate1_overlay.png new file mode 100644 index 0000000..2389796 Binary files /dev/null and b/Mobile/img/icons/MozillaFXOSIconTemplate1_overlay.png differ diff --git a/Mobile/img/icons/icon120.png b/Mobile/img/icons/icon120.png new file mode 100644 index 0000000..9519dd3 Binary files /dev/null and b/Mobile/img/icons/icon120.png differ diff --git a/Mobile/img/icons/icon128.png b/Mobile/img/icons/icon128.png new file mode 100644 index 0000000..96e7f9f Binary files /dev/null and b/Mobile/img/icons/icon128.png differ diff --git a/Mobile/img/icons/icon16.png b/Mobile/img/icons/icon16.png new file mode 100644 index 0000000..186045d Binary files /dev/null and b/Mobile/img/icons/icon16.png differ diff --git a/Mobile/img/icons/icon2.png b/Mobile/img/icons/icon2.png new file mode 100644 index 0000000..559431b Binary files /dev/null and b/Mobile/img/icons/icon2.png differ diff --git a/Mobile/img/icons/icon2.svg b/Mobile/img/icons/icon2.svg new file mode 100644 index 0000000..6256192 --- /dev/null +++ b/Mobile/img/icons/icon2.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/Mobile/img/icons/icon32.png b/Mobile/img/icons/icon32.png new file mode 100644 index 0000000..78e4cf0 Binary files /dev/null and b/Mobile/img/icons/icon32.png differ diff --git a/Mobile/img/icons/icon48.png b/Mobile/img/icons/icon48.png new file mode 100644 index 0000000..301142f Binary files /dev/null and b/Mobile/img/icons/icon48.png differ diff --git a/Mobile/img/icons/icon60.png b/Mobile/img/icons/icon60.png new file mode 100644 index 0000000..bac55b3 Binary files /dev/null and b/Mobile/img/icons/icon60.png differ diff --git a/Mobile/img/icons/icon64.png b/Mobile/img/icons/icon64.png new file mode 100644 index 0000000..fd0041a Binary files /dev/null and b/Mobile/img/icons/icon64.png differ diff --git a/Mobile/img/icons/icon90.png b/Mobile/img/icons/icon90.png new file mode 100644 index 0000000..4e56717 Binary files /dev/null and b/Mobile/img/icons/icon90.png differ diff --git a/Mobile/index.html b/Mobile/index.html new file mode 100644 index 0000000..dd28227 --- /dev/null +++ b/Mobile/index.html @@ -0,0 +1,191 @@ + + + + + + + + + + + + + + + + + +
+ + +

Sketchy

+ + +
+ +
+ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/js/functions.js b/Mobile/js/functions.js similarity index 100% rename from js/functions.js rename to Mobile/js/functions.js diff --git a/js/less-1.5.0.min.js b/Mobile/js/less-1.5.0.min.js similarity index 100% rename from js/less-1.5.0.min.js rename to Mobile/js/less-1.5.0.min.js diff --git a/js/libs/color-picker-touch.js b/Mobile/js/libs/color-picker-touch.js similarity index 100% rename from js/libs/color-picker-touch.js rename to Mobile/js/libs/color-picker-touch.js diff --git a/js/libs/color-picker.js b/Mobile/js/libs/color-picker.js similarity index 100% rename from js/libs/color-picker.js rename to Mobile/js/libs/color-picker.js diff --git a/js/libs/mobilebrowsers.js b/Mobile/js/libs/mobilebrowsers.js similarity index 100% rename from js/libs/mobilebrowsers.js rename to Mobile/js/libs/mobilebrowsers.js diff --git a/js/libs/stack.js b/Mobile/js/libs/stack.js similarity index 100% rename from js/libs/stack.js rename to Mobile/js/libs/stack.js diff --git a/js/libs/touch.js b/Mobile/js/libs/touch.js similarity index 100% rename from js/libs/touch.js rename to Mobile/js/libs/touch.js diff --git a/js/libs/yepnope.min.js b/Mobile/js/libs/yepnope.min.js similarity index 100% rename from js/libs/yepnope.min.js rename to Mobile/js/libs/yepnope.min.js diff --git a/js/libs/zepto.min.js b/Mobile/js/libs/zepto.min.js similarity index 100% rename from js/libs/zepto.min.js rename to Mobile/js/libs/zepto.min.js diff --git a/Mobile/js/main.js b/Mobile/js/main.js new file mode 100644 index 0000000..6bd4f0b --- /dev/null +++ b/Mobile/js/main.js @@ -0,0 +1,38 @@ +"use strict"; + +$(document).ready(function() { + window.c = $('canvas')[0].getContext('2d'); + window.o = $('canvas')[1].getContext('2d'); + + window.settings = { + lineWidth : 2, + color : 'black', + type: 'sketch', + lineCap: 'round', + lineJoin: 'round', + furLength: 5, + connectTelorance: 40, + composite: 'source-over' + }; + window.points = []; + window.$c = $('canvas'); + window.points.history = [{ data: c.createImageData($c.width(), $c.height()), points: []}]; + window.points.history.last = 0; + + sizeAndPos(); + //$(window).resize(sizeAndPos); + + $('.color-picker').change(function() { + var c = $(this).find('.color').val(); + settings.color = c; + $('#setcolor span').html(c); + }) + $('.color').val('#000000'); + + /*yepnope({ + test: window.mobile, + yep : ['js/libs/touch.js', 'js/mobile.js', 'js/libs/color-picker-touch.js'], + nope: ['js/desktop.js', 'js/libs/color-picker.js'] + })*/ + +}) diff --git a/Mobile/js/mobile.js b/Mobile/js/mobile.js new file mode 100644 index 0000000..4359e38 --- /dev/null +++ b/Mobile/js/mobile.js @@ -0,0 +1,223 @@ +"use strict"; + +$(document).ready(function() { + +// Open External Links in browser + +$('*').click(function(e) { + e.preventDefault(); +}) + +$('a[href^="http"]').on('tap', function(e) { + e.preventDefault(); + var href = $(this).attr('href'); + var view = new MozActivity({ + name: 'view', + data: { + type: 'url', + url: href + } + }) +}) + +function save() { + switch(save.background) { + case 'white': { + var cache = { + fillStyle: c.color, + composite: c.globalCompositeOperation + } + c.fillStyle = 'white'; + c.globalCompositeOperation = 'destination-over'; + c.fillRect(0, 0, width(), height()); + c.fillStyle = cache.fillStyle; + c.globalCompositeOperation = cache.composite; + break; + } + case 'current color': { + var cache = { + fillStyle: c.color, + composite: c.globalCompositeOperation + } + c.fillStyle = settings.strokeStyle; + c.globalCompositeOperation = 'destination-over'; + c.fillRect(0, 0, width(), height()); + c.fillStyle = cache.fillStyle; + c.globalCompositeOperation = cache.composite; + break; + } + } + var data = $c[0].toDataURL(); + var file = dataToBlob($c[0].toDataURL()); + var pics = navigator.getDeviceStorage('pictures'); + var r = pics.addNamed(file, save['file name'] + '.png'); + r.onsuccess = function() { + alert('Your sketch was successfuly saved to ' + this.result); + } + r.onerror = function() { + alert('Something bad happened when we tried to save your file\n Possible problems: \n Duplicate name \n Permission problems') + console.warn(this.error); + } + c.putImageData(window.points.history[window.points.history.last].data, 0, 0); +} + + $('.menu').tap(function() { + $('#menu').toggleClass('pulled'); + }) + $('.save').tap(function() { + $('#save').removeClass('hidden'); + }) + $c.last().on('touchstart', function(e) { + var xy = relative(e.changedTouches[0].pageX, e.changedTouches[0].pageY); + startPoint(xy.x, xy.y); + window.active = true; + }).on('touchmove', function(e) { + if (!window.active || settings.type == 'line') return; + var xy = relative(e.changedTouches[0].pageX, e.changedTouches[0].pageY); + drawPoint(xy.x, xy.y); + }).on('touchend', function(e) { + window.active = false; + if( settings.type == 'eraser' ) return; + + if(window.points.history.last < window.points.history.length-1) { + window.points.history.splice(window.points.history.last+1); + } + + window.points.history.push({ + data: c.getImageData(0, 0, width(), height()), + points: window.points.slice(0) + }) + window.points.history.last = window.points.history.length-1; + }).on('longTap', function(e) { + if( points[points.length-1].type == 'line' ) { + window.active = false; + points[points.length-1].type = ''; + points[points.length-1].start = undefined; + } + }) + + // Value Selector + + var $single = $('form[data-type="value-selector"].single'); + + $single.find('li').tap(function(e) { + e.preventDefault(); + $(this).parent().find('li[aria-selected]').removeAttr('aria-selected'); + $(this).attr('aria-selected', 'true'); + var key = $(this).parents('form').attr('id'), + value = $(this).find('label span').html().toLowerCase(); + window.settings[key] = value; + + $('button[id="set' + key + '"] span').html(value[0].toUpperCase() + value.substr(1)); + $('#menu div.options > div').addClass('hidden'); + $('#menu div.options > .general, #menu div.options > .'+value).removeClass('hidden'); + + $(this).parents('form').addClass('hidden'); + }) + + $single.find('button').tap(function(e) { + e.preventDefault(); + $(this).parents('form').addClass('hidden'); + }) + + // Confirm + + var $confirm = $('form[data-type="value-selector"].confirm'); + + $confirm.find('li').tap(function(e) { + $(this).parent().find('li[aria-selected]').removeAttr('aria-selected'); + $(this).attr('aria-selected', 'true'); + }) + $confirm.find('button').last().tap(function(e) { + e.preventDefault(); + var v = $(this).parents('form').attr('id'); + $(this).parents('form').find('h1').each(function(i) { + if( i > 0 ) { + var key = $(this).html().toLowerCase(); + var value = $(this).parent().find('ol:nth-of-type('+i+') li[aria-selected] span').html(); + if( key !== 'file name' ) value = value.toLowerCase(); + + window[v][key] = value; + } + }) + $(this).parents('form').addClass('hidden'); + window[v](); + }) + $confirm.find('button').first().tap(function(e) { + e.preventDefault(); + $(this).parents('form').addClass('hidden'); + }) + + // Value Selector Callers + + var $btn = $('button[id^="set"]'); + $btn.each(function() { + var target = /set(.*)/.exec($(this).attr('id'))[1]; + if( target == 'color' ) { + return $(this).tap(function() { + $('.picker').removeClass('hidden'); + }) + } + $(this).tap(function(e) { + e.preventDefault(); + $('form[id="' + target + '"]').removeClass('hidden'); + }) + }) + + // Seekbar + + var sliderLeft; + $('div[role="slider"] button').on('touchstart', function() { + $(this).attr('data-moving','true'); + if( !sliderLeft ) sliderLeft = $('div[role="slider"] button').offset().left; + }).on('touchmove', function(e) { + if( $(this).attr('data-moving') ) { + var x = parseInt(e.changedTouches[0].pageX - sliderLeft - 15); + var $c = $('.'+$(this).parents('div[role="slider"]').attr('class')); + var progress = $c.find('progress'); + var max = +progress.attr('max'); + var min = +progress.attr('min'); + if( x <= max && x >= min ) { + $c.find('button').css('left', x+'%'); + progress.attr('value', x); + var key = $c.attr('class'); + settings[key] = x; + $('#'+ key +' span').html(x); + } + } + }).on('touchend', function() { + $(this).removeAttr('data-moving'); + }) + + // Color Picker + + $('.close').tap(function() { + $(this).parent().addClass('hidden'); + }) + + // Bottom + + $('#clear').tap(function() { + c.clearRect(0, 0, width(), height()); + var h = window.points.history; + window.points = []; + window.points.history = h; + if(window.points.history.last < window.points.history.length-1) { + window.points.history.splice(window.points.history.last+1); + } + + window.points.history.push({ + data: c.getImageData(0, 0, width(), height()), + points: [] + }) + window.points.history.last = window.points.history.length-1; + }) + + $('#undo').tap(undo); + $('#redo').tap(redo); + + $('#about').tap(function() { + $('.about').removeClass('hidden'); + }) + +}); diff --git a/manifest.webapp b/Mobile/manifest.webapp similarity index 100% rename from manifest.webapp rename to Mobile/manifest.webapp diff --git a/Web/LICENSE b/Web/LICENSE new file mode 100644 index 0000000..c42e6b5 --- /dev/null +++ b/Web/LICENSE @@ -0,0 +1,20 @@ +The MIT License (MIT) + +Copyright (c) 2013 Mahdi Dibaiee + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. diff --git a/Web/README.md b/Web/README.md new file mode 100644 index 0000000..857ebfe --- /dev/null +++ b/Web/README.md @@ -0,0 +1,4 @@ +Brush +===== + +An image manipulation tool written in Javascript diff --git a/Web/css/color-picker.css b/Web/css/color-picker.css new file mode 100644 index 0000000..cfcbba5 --- /dev/null +++ b/Web/css/color-picker.css @@ -0,0 +1,90 @@ +/* Purty Picker Copyright 2013 Jayden Seric (MIT license): https://github.com/jaydenseric/Purty-Picker */ +/* Core: No touchy! */ +.color-picker .spectrum { + position: relative; + /* To position pin, luminosity filter */ + background: linear-gradient(gray, transparent), linear-gradient(90deg, red, #ff2b00, #ff5500, #ff8000, #ffaa00, #ffd500, yellow, #d4ff00, #aaff00, #80ff00, #55ff00, #2bff00, lime, #00ff2b, #00ff55, #00ff80, #00ffaa, #00ffd5, cyan, #00d4ff, #00aaff, #007fff, #0055ff, #002bff, blue, #2a00ff, #5500ff, #7f00ff, #aa00ff, #d400ff, magenta, #ff00d4, #ff00aa, #ff0080, #ff0055, #ff002b, red); + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; + /* Prevent pin interaction causing content selection */ + cursor: crosshair; +} +.color-picker .spectrum.active { + cursor: none; +} +.color-picker .spectrum.active .pin { + cursor: none; +} +.color-picker .spectrum > div { + /* Luminosity filter */ + position: absolute; + left: 0; + right: 0; + top: 0; + bottom: 0; +} +.color-picker .spectrum .pin { + position: absolute; + cursor: move; +} + +/* Customization: Default skin */ +.color-picker { + margin: 20px; + padding: 11px; + border: 1px solid #e3e3e3; + border-radius: 4px; + background-color: #f5f5f5; +} +.color-picker .color, +.color-picker .luminosity { + -moz-box-sizing: border-box; + box-sizing: border-box; + display: block; + width: 100%; +} +.color-picker .format { + display: block; + margin: 0 auto 10px auto; +} +.color-picker .color { + -webkit-appearance: none; + border: 0; + border-radius: 2px; + padding: 10px; + text-align: center; + font-size: 11px; + letter-spacing: 1px; + font-family: Consolas, Monaco, 'Andale Mono', monospace; + color: rgba(0, 0, 0, 0.6); + box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2); + transition: color 0.2s; +} +.color-picker .color.dark { + color: rgba(255, 255, 255, 0.7); +} +.color-picker .spectrum { + height: 150px; + /* Arbitary but required */ + overflow: hidden; + /* Prevent pin overflowing container */ + border-radius: 2px; + margin: 10px 0; +} +.color-picker .spectrum > div { + box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.2); +} +.color-picker .spectrum .pin { + margin-left: -4px; + margin-top: -4px; + width: 4px; + height: 4px; + border: 2px solid white; + box-shadow: 0 1px 1px rgba(0, 0, 0, 0.4); + border-radius: 100%; +} +.color-picker .luminosity { + margin: 0; +} diff --git a/Web/css/fonts.less b/Web/css/fonts.less new file mode 100644 index 0000000..e92a90b --- /dev/null +++ b/Web/css/fonts.less @@ -0,0 +1,16 @@ +@font-face { + font-family: 'MozTT-Regular'; + src: url('fonts/MozTT-Regular.ttf'); +} +@font-face { + font-family: 'MozTT-Light'; + src: url('fonts/MozTT-Light.ttf'); +} +@font-face { + font-family: 'MozTT-Medium'; + src: url('fonts/MozTT-Medium.ttf'); +} +@font-face { + font-family: 'MozTT-Bold'; + src: url('fonts/MozTT-Bold.ttf'); +} diff --git a/Web/css/fonts/MozTT-Bold.ttf b/Web/css/fonts/MozTT-Bold.ttf new file mode 100644 index 0000000..8ad5fab Binary files /dev/null and b/Web/css/fonts/MozTT-Bold.ttf differ diff --git a/Web/css/fonts/MozTT-Light.ttf b/Web/css/fonts/MozTT-Light.ttf new file mode 100644 index 0000000..0553c17 Binary files /dev/null and b/Web/css/fonts/MozTT-Light.ttf differ diff --git a/Web/css/fonts/MozTT-Medium.ttf b/Web/css/fonts/MozTT-Medium.ttf new file mode 100644 index 0000000..91466be Binary files /dev/null and b/Web/css/fonts/MozTT-Medium.ttf differ diff --git a/Web/css/fonts/MozTT-Regular.ttf b/Web/css/fonts/MozTT-Regular.ttf new file mode 100644 index 0000000..e74e0b2 Binary files /dev/null and b/Web/css/fonts/MozTT-Regular.ttf differ diff --git a/Web/css/imgs/bg_overlay_pressed_1.png b/Web/css/imgs/bg_overlay_pressed_1.png new file mode 100644 index 0000000..753e953 Binary files /dev/null and b/Web/css/imgs/bg_overlay_pressed_1.png differ diff --git a/Web/css/imgs/bg_overlay_pressed_2.png b/Web/css/imgs/bg_overlay_pressed_2.png new file mode 100644 index 0000000..8db4bbf Binary files /dev/null and b/Web/css/imgs/bg_overlay_pressed_2.png differ diff --git a/Web/css/imgs/clear.png b/Web/css/imgs/clear.png new file mode 100644 index 0000000..cfcff2e Binary files /dev/null and b/Web/css/imgs/clear.png differ diff --git a/Web/css/imgs/div_line_lg_black.png b/Web/css/imgs/div_line_lg_black.png new file mode 100644 index 0000000..2fd663e Binary files /dev/null and b/Web/css/imgs/div_line_lg_black.png differ diff --git a/Web/css/imgs/div_line_sm_black.png b/Web/css/imgs/div_line_sm_black.png new file mode 100644 index 0000000..c1b4c09 Binary files /dev/null and b/Web/css/imgs/div_line_sm_black.png differ diff --git a/Web/css/imgs/download.png b/Web/css/imgs/download.png new file mode 100644 index 0000000..897c9f2 Binary files /dev/null and b/Web/css/imgs/download.png differ diff --git a/Web/css/imgs/header_bg_black.png b/Web/css/imgs/header_bg_black.png new file mode 100644 index 0000000..5670021 Binary files /dev/null and b/Web/css/imgs/header_bg_black.png differ diff --git a/Web/css/imgs/menu.png b/Web/css/imgs/menu.png new file mode 100644 index 0000000..c0d38c0 Binary files /dev/null and b/Web/css/imgs/menu.png differ diff --git a/Web/css/imgs/redo.png b/Web/css/imgs/redo.png new file mode 100644 index 0000000..d2864fb Binary files /dev/null and b/Web/css/imgs/redo.png differ diff --git a/Web/css/imgs/settings.png b/Web/css/imgs/settings.png new file mode 100644 index 0000000..6792c46 Binary files /dev/null and b/Web/css/imgs/settings.png differ diff --git a/Web/css/imgs/undo.png b/Web/css/imgs/undo.png new file mode 100644 index 0000000..6117001 Binary files /dev/null and b/Web/css/imgs/undo.png differ diff --git a/Web/css/main.less b/Web/css/main.less new file mode 100644 index 0000000..ea83e2e --- /dev/null +++ b/Web/css/main.less @@ -0,0 +1,266 @@ +@import 'fonts'; + + +html, body { + margin: 0; + font-size: 10px; + overflow: hidden; +} + +*::-moz-focus-inner { + border: none; +} +*:focus { + outline: none; +} + +.hidden { + display: none; + visibility: none; +} + +div#container { + position: absolute; +} + +canvas { + position: absolute; + top: 0; + left: 0; +} + +.separator { + display: block; + height: 4.8rem; + width: 0.1rem; + &.long { + background: url('imgs/div_line_lg_black.png'); + } + &.small { + background: url('imgs/div_line_sm_black.png'); + } + &.left { + float: left; + } + &.right { + float: right; + } + &.menu { + position: relative; + left: -3rem; + } +} + +.overlay { + z-index: 9999; + position: absolute; + left: 0; + top: 5.3rem;; +} + +button { + -moz-appearance: none; + z-index: 1; + position: relative; + border: none; +} + +.close { + display: block; + width: 2rem; + height: 2rem; + padding: 0 0 0.2rem 0.2rem; + font-size: 10pt; + border: 1px solid rgb(227, 227, 227); + border-radius: 50%; + position: absolute; + text-align: center; + top: -2%; + left: 97%; +} + +.picker, .about { + font-family: 'MozTT-Light'; + width: 30rem; + height: 24.6rem; + position: absolute; + left: 50%; + top: 50%; + margin-top: -12.3rem; + margin-left: -15rem; + + .color-picker { + margin: 0; + } +} + +.about { + background: #262626; + padding: 1rem 2rem;; + height: 23rem; + margin-top: -11.5rem; + margin-left: -17rem; + border-radius: 0.2rem; + color: white; + box-shadow: 0 0 0.3rem black; + + a, a:link, a:visited, a:active { + color: white; + } + + .close { + background: #262626; + color: white; + border: 1px solid gray; + } + + p { + font-size: 11pt; + } + span { + font-size: 8pt; + } +} + +header { + width: 100%; + height: 5.3rem; + background: url('imgs/header_bg_black.png'); + + button { + width: 5rem; + height: 5rem; + } + + .menu { + background: url('imgs/menu.png') -12px center no-repeat; + float: left; + &:active { + background: url('imgs/menu.png') -12px center no-repeat, url('imgs/bg_overlay_pressed_1.png') left no-repeat; + } + } + + .save { + background: url('imgs/download.png') center center no-repeat; + float: right; + &:active { + background: url('imgs/download.png') center center no-repeat, url('imgs/bg_overlay_pressed_2.png') center center; + } + } + + #title { + color: white; + font-size: 11pt; + font-family: 'MozTT-Regular'; + float: left; + margin: 1.5rem 0; + position: relative; + left: -2rem; + } +} + + +#menu { + height: 100%; + width: 15rem; + background: #262626; + position: absolute; + left: -15rem; + top: 5rem; + color: white; + font-family: 'MozTT-Light'; + font-size: 8pt; + transition: left 0.2s ease-out; + border-collapse: collapse; + overflow: hidden; + + &.pulled { + left: 0; + transition: left 0.2s ease-out; + } + + button[id^='set'], p, .bottom button { + background: none; + display: block; + width: 75%; + color: white; + text-align: left; + margin: 1rem 2.5rem; + font-family: 'MozTT-Light'; + font-size: 8pt; + padding: 0 0.6rem; + cursor: pointer; + } + span { + float: right; + font-size: 7pt; + } + div[role='slider'] { + width: 60%; + float: right; + margin: 0 2rem 0 0; + + div { + overflow: visible; + button { + margin-top: -3.4rem; + left: 0%; + } + } + } + hr { + clear: both; + padding: 0.7rem 0; + margin-bottom: 0.7rem; + border: none; + border-bottom: 1px solid rgba(255,255,255,0.3); + } + *[class^='icon'] { + display: block; + margin: 1rem 0.5rem; + + &:nth-of-type(2) { + padding-top: 0.5rem; + } + &:before { + content: ''; + background-size: 2rem; + width: 2rem; + height: 2rem; + display: block; + float: left; + margin: -0.3rem 0.5rem 0 0; + } + } + + .icon-settings:before { + background-image: url('imgs/settings.png'); + } + .icon-clear:before { + background-image: url('imgs/clear.png'); + } + .icon-undo:before { + background-image: url('imgs/undo.png'); + } + .icon-redo:before { + background-image: url('imgs/redo.png'); + } + + .options { + display: block; + margin-top: 1rem; + } + .bottom { + position: absolute; + bottom: 5rem; + width: 100%; + button[class^='icon'] { + margin-left: 3.5rem; + } + button { + margin-left: 5rem; + } + } +} + + diff --git a/Web/css/seekbars.css b/Web/css/seekbars.css new file mode 100644 index 0000000..4717d37 --- /dev/null +++ b/Web/css/seekbars.css @@ -0,0 +1,80 @@ +/* ---------------------------------- +* Seekbars +* ---------------------------------- */ +div[role="slider"] { + position: relative; + height: 3.5rem; +} + +div[role="slider"] > div { + display: block; + padding: 0; + overflow-y: hidden; + position: relative; + height: 100%; +} + +div[role="slider"] progress { + width: 100%; + background: #000; + border: none; + height: 0.1rem; + display: block; + border-radius: 0; + margin-top: 1.9rem; +} + +div[role="slider"] progress::-moz-progress-bar { + background: #01c5ed; + height: 0.6rem; + margin-top: -0.3rem; + border-radius: 0; +} + +div[role="slider"] > label { + font-size: 1.5rem; + line-height: 3.8rem; + font-family: sans-serif; + color: #00aacb; + float: right; + padding: 0 0 0 1rem; + height: 3.5rem; + width: auto; +} + +div[role="slider"] label:first-of-type { + float: left; + padding: 0 1rem 0 0; +} + +div[role="slider"] > label.icon { + width: 3rem; + height: 3rem; + margin-top: 0.5rem; + font-size: 0; + background: no-repeat right top / 3rem auto; +} + +div[role="slider"] > label.icon:first-of-type { + background-position: top left; +} + +div[role="slider"] button { + width: 3.2rem; + height: 3.2rem; + background: url(seekbars/images/ui/handler.png) no-repeat center center / 3rem auto; + font: 0/0 a; + position: absolute; + top: 50%; + left: 0; + margin: -1.5rem 0 0 -1.6rem; + border-radius: 3.2rem; + border: solid 0.1rem transparent; + transition: border 0.15s ease; + padding: 0; + z-index: 10; +} + +div[role="slider"] button:active { + border: solid 0.5rem #01c5ed; +} diff --git a/Web/css/seekbars/images/ui/handler.png b/Web/css/seekbars/images/ui/handler.png new file mode 100644 index 0000000..246b7b4 Binary files /dev/null and b/Web/css/seekbars/images/ui/handler.png differ diff --git a/Web/css/seekbars/images/ui/handler@1.5x.png b/Web/css/seekbars/images/ui/handler@1.5x.png new file mode 100644 index 0000000..26a5092 Binary files /dev/null and b/Web/css/seekbars/images/ui/handler@1.5x.png differ diff --git a/Web/css/seekbars/images/ui/handler@2x.png b/Web/css/seekbars/images/ui/handler@2x.png new file mode 100644 index 0000000..9a69e77 Binary files /dev/null and b/Web/css/seekbars/images/ui/handler@2x.png differ diff --git a/Web/css/seekbars/seekbars.css b/Web/css/seekbars/seekbars.css new file mode 100644 index 0000000..a92a477 --- /dev/null +++ b/Web/css/seekbars/seekbars.css @@ -0,0 +1,79 @@ +/* ---------------------------------- +* Seekbars +* ---------------------------------- */ +div[role="slider"] { + position: relative; + height: 3.5rem; +} + +div[role="slider"] > div { + display: block; + overflow: hidden; + padding: 0; + position: relative; + height: 100%; +} + +div[role="slider"] progress { + width: 100%; + background: #000; + border: none; + height: 0.1rem; + display: block; + border-radius: 0; + margin-top: 1.9rem; +} + +div[role="slider"] progress::-moz-progress-bar { + background: #01c5ed; + height: 0.6rem; + margin-top: -0.3rem; + border-radius: 0; +} + +div[role="slider"] > label { + font-size: 1.5rem; + line-height: 3.8rem; + font-family: sans-serif; + color: #00aacb; + float: right; + padding: 0 0 0 1rem; + height: 3.5rem; + width: auto; +} + +div[role="slider"] label:first-of-type { + float: left; + padding: 0 1rem 0 0; +} + +div[role="slider"] > label.icon { + width: 3rem; + height: 3rem; + margin-top: 0.5rem; + font-size: 0; + background: no-repeat right top / 3rem auto; +} + +div[role="slider"] > label.icon:first-of-type { + background-position: top left; +} + +div[role="slider"] button { + width: 3.2rem; + height: 3.2rem; + background: url(seekbars/images/ui/handler.png) no-repeat center center / 3rem auto; + font: 0/0 a; + position: absolute; + top: 50%; + left: 0; + margin: -1.5rem 0 0 -1.6rem; + border-radius: 3.2rem; + border: solid 0.1rem transparent; + transition: border 0.15s ease; + padding: 0; +} + +div[role="slider"] button:active { + border: solid 0.5rem #01c5ed; +} diff --git a/Web/css/switches.css b/Web/css/switches.css new file mode 100644 index 0000000..9025a22 --- /dev/null +++ b/Web/css/switches.css @@ -0,0 +1,94 @@ +/* ---------------------------------- + * CHECKBOXES / RADIOS + * ---------------------------------- */ + +label.pack-checkbox, +label.pack-radio, +label.pack-switch { + display: inline-block; + vertical-align: middle; + width: 5rem; + height: 5rem; + position: relative; + background: none; +} + +label.pack-checkbox input, +label.pack-radio input, +label.pack-switch input { + margin: 0; + opacity: 0; + position: absolute; + top: 0; + left: 0; +} + +label.pack-checkbox input ~ span:after, +label.pack-radio input ~ span:after { + content: ''; + position: absolute; + left: 50%; + top: 50%; + margin: -1.1rem 0 0 -1.1rem; + width: 2.2rem; + height: 2.2rem; + pointer-events: none; +} + +label.pack-checkbox input ~ span:after { + background: url(switches/images/check/default.png) no-repeat center top / 2.2rem auto; +} + +label.pack-radio input ~ span:after { + background: url(switches/images/radio/default.png) no-repeat center top / 2.2rem auto; +} + +label.pack-checkbox input:checked ~ span:after, +label.pack-radio input:checked ~ span:after, +label.pack-switch input:checked ~ span:after { + background-position: center bottom; +} + +/* 'Dangerous' switches */ + +label.pack-checkbox.danger input ~ span:after { + background-image: url(switches/images/check/danger.png); +} + +label.pack-radio.danger input ~ span:after { + background-image: url(switches/images/radio/danger.png); +} + + +/* ---------------------------------- + * ON/OFF SWITCHES + * ---------------------------------- */ + +label.pack-switch input ~ span:after { + content: ''; + position: absolute; + right: 0; + top: 50%; + width: 6rem; + margin: -1.4rem 0rem 0rem; + height: 2.7rem; + pointer-events: none; + border-radius: 1.35rem; + overflow: hidden; + background: #e6e6e6 url(switches/images/switch/background_off.png) no-repeat -3.2rem 0rem / 9.2rem 2.7rem; + transition: background 0.2s ease; +} + +/* switch: 'ON' state */ +label.pack-switch input:checked ~ span:after { + background: #e6e6e6 url(switches/images/switch/background.png) no-repeat 0rem 0rem / 9.2rem 2.7rem; +} + +/* switch: disabled state */ +label.pack-switch input:disabled ~ span:after { + opacity: 0.4; +} + +label.pack-switch input.uninit ~ span:after { + transition: none; +} diff --git a/Web/css/switches/images/check/danger.png b/Web/css/switches/images/check/danger.png new file mode 100644 index 0000000..ed1f267 Binary files /dev/null and b/Web/css/switches/images/check/danger.png differ diff --git a/Web/css/switches/images/check/danger@1.5x.png b/Web/css/switches/images/check/danger@1.5x.png new file mode 100644 index 0000000..8d4b61d Binary files /dev/null and b/Web/css/switches/images/check/danger@1.5x.png differ diff --git a/Web/css/switches/images/check/danger@2x.png b/Web/css/switches/images/check/danger@2x.png new file mode 100644 index 0000000..7befd67 Binary files /dev/null and b/Web/css/switches/images/check/danger@2x.png differ diff --git a/Web/css/switches/images/check/default.png b/Web/css/switches/images/check/default.png new file mode 100644 index 0000000..9f188bb Binary files /dev/null and b/Web/css/switches/images/check/default.png differ diff --git a/Web/css/switches/images/check/default@1.5x.png b/Web/css/switches/images/check/default@1.5x.png new file mode 100644 index 0000000..8c25cae Binary files /dev/null and b/Web/css/switches/images/check/default@1.5x.png differ diff --git a/Web/css/switches/images/check/default@2x.png b/Web/css/switches/images/check/default@2x.png new file mode 100644 index 0000000..3e19692 Binary files /dev/null and b/Web/css/switches/images/check/default@2x.png differ diff --git a/Web/css/switches/images/radio/danger.png b/Web/css/switches/images/radio/danger.png new file mode 100644 index 0000000..d285887 Binary files /dev/null and b/Web/css/switches/images/radio/danger.png differ diff --git a/Web/css/switches/images/radio/danger@1.5x.png b/Web/css/switches/images/radio/danger@1.5x.png new file mode 100644 index 0000000..3b6a7d2 Binary files /dev/null and b/Web/css/switches/images/radio/danger@1.5x.png differ diff --git a/Web/css/switches/images/radio/danger@2x.png b/Web/css/switches/images/radio/danger@2x.png new file mode 100644 index 0000000..812f9a3 Binary files /dev/null and b/Web/css/switches/images/radio/danger@2x.png differ diff --git a/Web/css/switches/images/radio/default.png b/Web/css/switches/images/radio/default.png new file mode 100644 index 0000000..086d61a Binary files /dev/null and b/Web/css/switches/images/radio/default.png differ diff --git a/Web/css/switches/images/radio/default@1.5x.png b/Web/css/switches/images/radio/default@1.5x.png new file mode 100644 index 0000000..27ead41 Binary files /dev/null and b/Web/css/switches/images/radio/default@1.5x.png differ diff --git a/Web/css/switches/images/radio/default@2x.png b/Web/css/switches/images/radio/default@2x.png new file mode 100644 index 0000000..a93f80b Binary files /dev/null and b/Web/css/switches/images/radio/default@2x.png differ diff --git a/Web/css/switches/images/switch/background.png b/Web/css/switches/images/switch/background.png new file mode 100644 index 0000000..99bfe33 Binary files /dev/null and b/Web/css/switches/images/switch/background.png differ diff --git a/Web/css/switches/images/switch/background@1.5x.png b/Web/css/switches/images/switch/background@1.5x.png new file mode 100644 index 0000000..d1c2bd5 Binary files /dev/null and b/Web/css/switches/images/switch/background@1.5x.png differ diff --git a/Web/css/switches/images/switch/background_off.png b/Web/css/switches/images/switch/background_off.png new file mode 100644 index 0000000..963a0d1 Binary files /dev/null and b/Web/css/switches/images/switch/background_off.png differ diff --git a/Web/css/switches/images/switch/background_off@1.5x.png b/Web/css/switches/images/switch/background_off@1.5x.png new file mode 100644 index 0000000..c7bb7f5 Binary files /dev/null and b/Web/css/switches/images/switch/background_off@1.5x.png differ diff --git a/Web/css/value_selector.css b/Web/css/value_selector.css new file mode 100644 index 0000000..0a3493c --- /dev/null +++ b/Web/css/value_selector.css @@ -0,0 +1,203 @@ +/* ---------------------------------- + * Value selector (Single & Multiple) + * ---------------------------------- */ + +/* Main dialog setup */ +form[role="dialog"][data-type="value-selector"] { + background: url(value_selector/images/ui/pattern.png) repeat left top, url(value_selector/images/ui/gradient.png) no-repeat left top / 100% 100%; + overflow: hidden; + position: absolute; + z-index: 100; + top: 0; + left: 0; + right: 0; + bottom: 0; + padding: 0 0 7rem; + color: #fff; + font-family: sans-serif; +} + +form[role="dialog"][data-type="value-selector"] > section { + padding: 0 1.5rem 0; + -moz-box-sizing: padding-box; + width: 100%; + height: 100%; +} + +form[role="dialog"][data-type="value-selector"] h1 { + font-weight: 400; + font-size: 1.9rem; + line-height: 4.8rem; + color: #fff; + border-bottom: 0.1rem solid #616262; + background: rgba(0 ,0, 0, .2); + margin: 0 -1.5rem; + padding: 0 3rem 1rem; + height: 4.8rem; + -moz-box-sizing: border-box; +} + +/* Specific component code */ +form[role="dialog"][data-type="value-selector"] [role="listbox"] { + position: relative; + padding: 0; + margin: 0 -1.5rem; + max-height: calc(100% - 5rem); + overflow: auto; + border-top: solid 0.1rem #222323; +} + +form[role="dialog"][data-type="value-selector"] .scrollable:before { + content: ""; + display: block; + position: absolute; + pointer-events: none; + top: 4.8rem; + left: 0; + right: 0; + bottom: 6.9rem; + background: url(value_selector/images/ui/shadow.png) repeat-x left top, url(value_selector/images/ui/shadow-invert.png) repeat-x left bottom; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li { + margin: 0; + padding: 0 1.5rem; + height: auto; + list-style: none; + position: relative; + font-weight: lighter; + font-size: 2.2rem; + line-height: 3.9rem; + color: #fff; + transition: background-color 0.2s ease; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li:first-child label { + border-top-color: transparent; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li label { + outline: none; + display: block; + color: #fff; + border-top: 0.1rem solid #666; + border-bottom: 0.1rem solid #000; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li:last-child label { + border-bottom-color: transparent; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li label span { + display: block; + padding: 1rem 1.5rem; + line-height: 4rem; + word-wrap: break-word; +} + +/* Pressed status */ +form[role="dialog"][data-type="value-selector"] [role="listbox"] li:active { + background-color: #00ABCC; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li:active label { + border-color: transparent; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li:active + li label { + border-top-color: #000; +} + +form[role="dialog"][data-type="value-selector"] [role="listbox"] li:active label span { + color: #fff !important; + background-image: none; +} + +/* Checked status */ +form[role="dialog"][data-type="value-selector"] [role="listbox"] li[aria-selected="true"]:not([data-input]) span { + padding-right: 2.6rem; + margin-right: 1.2rem; + color: #00abcd; + background: transparent url(value_selector/images/icons/checked.png) no-repeat 100% 50%; + background-size: 2rem; +} + + +/* Menu & buttons setup */ +form[role="dialog"][data-type="value-selector"] menu { + white-space: nowrap; + margin: 0; + padding: 1.5rem; + border-top: solid 0.1rem rgba(255, 255, 255, 0.1); + background: #2d2d2d url(value_selector/images/ui/pattern.png) repeat left top; + display: block; + overflow: hidden; + position: absolute; + left: 0; + right: 0; + bottom: 0; +} + +form[role="dialog"][data-type="value-selector"] menu button::-moz-focus-inner { + border: none; + outline: none; +} + +form[role="dialog"][data-type="value-selector"] menu button { + width: calc((100% - 1rem) / 2); + height: 3.8rem; + margin: 0 0 1rem; + padding: 0 1.5rem; + -moz-box-sizing: border-box; + display: inline-block; + vertical-align: middle; + text-overflow: ellipsis; + white-space: nowrap; + overflow: hidden; + background: #fafafa url(value_selector/images/ui/default.png) repeat-x left bottom/ auto 100%; + border: 0.1rem solid #a6a6a6; + border-radius: 0.3rem; + font-weight: 500; + font-size: 1.6rem; + line-height: 3.8rem; + color: #333; + text-align: center; + text-shadow: 0.1rem 0.1rem 0 rgba(255,255,255,0.3); + text-decoration: none; + outline: none; +} + +/* Press (default & affirmative) */ +form[role="dialog"][data-type="value-selector"] menu button:active, +form[role="dialog"][data-type="value-selector"] menu button.affirmative:active { + border-color: #008aaa; + background: #008aaa; + color: #333; +} + +/* affirmative */ +form[role="dialog"][data-type="value-selector"] menu button.affirmative { + background-image: url(value_selector/images/ui/affirmative.png); + background-color: #00caf2; + border-color: #008eab; +} + +form[role="dialog"][data-type="value-selector"] menu button:last-child { + margin-left: 1rem; +} + +form[role="dialog"][data-type="value-selector"] menu button, +form[role="dialog"][data-type="value-selector"] menu button:first-child { + margin: 0; +} + +form[role="dialog"][data-type="value-selector"] menu button.full { + width: 100%; +} + +/* Right to left tweaks */ +html[dir="rtl"] #value-selector li input:checked + span, +html[dir="rtl"] #value-selector li[aria-selected="true"] span { + padding-left: 2.6rem; + margin-left: 1.2rem; +} diff --git a/Web/css/value_selector/images/icons/checked.png b/Web/css/value_selector/images/icons/checked.png new file mode 100644 index 0000000..69d5c3d Binary files /dev/null and b/Web/css/value_selector/images/icons/checked.png differ diff --git a/Web/css/value_selector/images/icons/checked@1.5x.png b/Web/css/value_selector/images/icons/checked@1.5x.png new file mode 100644 index 0000000..490dded Binary files /dev/null and b/Web/css/value_selector/images/icons/checked@1.5x.png differ diff --git a/Web/css/value_selector/images/icons/checked@2x.png b/Web/css/value_selector/images/icons/checked@2x.png new file mode 100644 index 0000000..c1a6fbd Binary files /dev/null and b/Web/css/value_selector/images/icons/checked@2x.png differ diff --git a/Web/css/value_selector/images/ui/affirmative.png b/Web/css/value_selector/images/ui/affirmative.png new file mode 100644 index 0000000..c1823eb Binary files /dev/null and b/Web/css/value_selector/images/ui/affirmative.png differ diff --git a/Web/css/value_selector/images/ui/default.png b/Web/css/value_selector/images/ui/default.png new file mode 100644 index 0000000..a174b67 Binary files /dev/null and b/Web/css/value_selector/images/ui/default.png differ diff --git a/Web/css/value_selector/images/ui/gradient.png b/Web/css/value_selector/images/ui/gradient.png new file mode 100644 index 0000000..d2e6f5b Binary files /dev/null and b/Web/css/value_selector/images/ui/gradient.png differ diff --git a/Web/css/value_selector/images/ui/gradient@1.5x.png b/Web/css/value_selector/images/ui/gradient@1.5x.png new file mode 100644 index 0000000..0e420cd Binary files /dev/null and b/Web/css/value_selector/images/ui/gradient@1.5x.png differ diff --git a/Web/css/value_selector/images/ui/pattern.png b/Web/css/value_selector/images/ui/pattern.png new file mode 100644 index 0000000..af03f56 Binary files /dev/null and b/Web/css/value_selector/images/ui/pattern.png differ diff --git a/Web/css/value_selector/images/ui/shadow-invert.png b/Web/css/value_selector/images/ui/shadow-invert.png new file mode 100644 index 0000000..b1b905f Binary files /dev/null and b/Web/css/value_selector/images/ui/shadow-invert.png differ diff --git a/Web/css/value_selector/images/ui/shadow-invert@1.5x.png b/Web/css/value_selector/images/ui/shadow-invert@1.5x.png new file mode 100644 index 0000000..ee2dc1c Binary files /dev/null and b/Web/css/value_selector/images/ui/shadow-invert@1.5x.png differ diff --git a/Web/css/value_selector/images/ui/shadow-invert@2x.png b/Web/css/value_selector/images/ui/shadow-invert@2x.png new file mode 100644 index 0000000..15c95ed Binary files /dev/null and b/Web/css/value_selector/images/ui/shadow-invert@2x.png differ diff --git a/Web/css/value_selector/images/ui/shadow.png b/Web/css/value_selector/images/ui/shadow.png new file mode 100644 index 0000000..728fe77 Binary files /dev/null and b/Web/css/value_selector/images/ui/shadow.png differ diff --git a/Web/css/value_selector/images/ui/shadow@1.5x.png b/Web/css/value_selector/images/ui/shadow@1.5x.png new file mode 100644 index 0000000..44b35b4 Binary files /dev/null and b/Web/css/value_selector/images/ui/shadow@1.5x.png differ diff --git a/Web/css/value_selector/images/ui/shadow@2x.png b/Web/css/value_selector/images/ui/shadow@2x.png new file mode 100644 index 0000000..f515eff Binary files /dev/null and b/Web/css/value_selector/images/ui/shadow@2x.png differ diff --git a/Web/img/icons/MozillaFXOSIconTemplate1_overlay.png b/Web/img/icons/MozillaFXOSIconTemplate1_overlay.png new file mode 100644 index 0000000..2389796 Binary files /dev/null and b/Web/img/icons/MozillaFXOSIconTemplate1_overlay.png differ diff --git a/Web/img/icons/icon120.png b/Web/img/icons/icon120.png new file mode 100644 index 0000000..9519dd3 Binary files /dev/null and b/Web/img/icons/icon120.png differ diff --git a/Web/img/icons/icon128.png b/Web/img/icons/icon128.png new file mode 100644 index 0000000..96e7f9f Binary files /dev/null and b/Web/img/icons/icon128.png differ diff --git a/Web/img/icons/icon16.png b/Web/img/icons/icon16.png new file mode 100644 index 0000000..186045d Binary files /dev/null and b/Web/img/icons/icon16.png differ diff --git a/Web/img/icons/icon2.png b/Web/img/icons/icon2.png new file mode 100644 index 0000000..559431b Binary files /dev/null and b/Web/img/icons/icon2.png differ diff --git a/Web/img/icons/icon2.svg b/Web/img/icons/icon2.svg new file mode 100644 index 0000000..6256192 --- /dev/null +++ b/Web/img/icons/icon2.svg @@ -0,0 +1,102 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + diff --git a/Web/img/icons/icon32.png b/Web/img/icons/icon32.png new file mode 100644 index 0000000..78e4cf0 Binary files /dev/null and b/Web/img/icons/icon32.png differ diff --git a/Web/img/icons/icon48.png b/Web/img/icons/icon48.png new file mode 100644 index 0000000..301142f Binary files /dev/null and b/Web/img/icons/icon48.png differ diff --git a/Web/img/icons/icon60.png b/Web/img/icons/icon60.png new file mode 100644 index 0000000..bac55b3 Binary files /dev/null and b/Web/img/icons/icon60.png differ diff --git a/Web/img/icons/icon64.png b/Web/img/icons/icon64.png new file mode 100644 index 0000000..fd0041a Binary files /dev/null and b/Web/img/icons/icon64.png differ diff --git a/Web/img/icons/icon90.png b/Web/img/icons/icon90.png new file mode 100644 index 0000000..4e56717 Binary files /dev/null and b/Web/img/icons/icon90.png differ diff --git a/index.html b/Web/index.html similarity index 89% rename from index.html rename to Web/index.html index 29a46ea..e7a6df5 100644 --- a/index.html +++ b/Web/index.html @@ -79,6 +79,8 @@ +
+ @@ -150,7 +152,6 @@ + + diff --git a/js/events.js b/Web/js/desktop.js similarity index 96% rename from js/events.js rename to Web/js/desktop.js index 004f084..09d5994 100644 --- a/js/events.js +++ b/Web/js/desktop.js @@ -2,6 +2,8 @@ $(window).resize(sizeAndPos); +// Check for update + function save() { switch(save.background) { case 'white': { @@ -166,8 +168,8 @@ function save() { // Color Picker - $('#closePicker').click(function() { - $('.picker').addClass('hidden'); + $('.close').click(function() { + $(this).parent().addClass('hidden'); }) // Bottom @@ -189,3 +191,7 @@ function save() { $('#undo').click(undo); $('#redo').click(redo); + $('#about').click(function() { + $('.about').removeClass('hidden'); + }) + diff --git a/Web/js/functions.js b/Web/js/functions.js new file mode 100644 index 0000000..1da937d --- /dev/null +++ b/Web/js/functions.js @@ -0,0 +1,196 @@ +"use strict"; +/*** ESSENTIALS ***/ + +function sizeAndPos() { + + var data = window.points.history[window.points.history.last].data || c.getImageData(0,0, $c.width(), $c.height()); + var w = $(window).width(), + h = $(window).height() - 53; + $c.attr('width', w * window.devicePixelRatio); + $c.attr('height',h * window.devicePixelRatio); + $c.css({ + 'width' : w, + 'height' : h + }); + c.clearRect(0,0, width(), height()); + c.putImageData(data, 0, 0); +} + +function relative(x,y) { + return { + x : x*window.devicePixelRatio, + y : (y - 53) * window.devicePixelRatio + } +} + +function threshold(x1, y1, x2, y2, threshold) { + var tr = threshold || 5; + if( x1 <= x2 + tr && x1 >= x2 - tr && y1 <= y2 + tr && y1 >= y2 - tr ) return true; + return false; +} + +function draw(x1, y1, x2, y2, opts, overlay) { + opts = opts || {}; + var c = window.c; + if( overlay ) var c = window.o; + c.beginPath(); + if( settings.type == 'eraser' ) c.globalCompositeOperation = 'destination-out'; + else c.globalCompositeOperation = opts.composite || settings.composite; + c.lineCap = opts.lineCap || settings.lineCap; + c.lineJoin = opts.lineJoin || settings.lineJoin; + c.strokeStyle = opts.color || settings.color; + c.fillStyle = opts.color || settings.color; + c.lineWidth = ( opts.lineWidth || settings.lineWidth ) / 10; + c.moveTo(x1, y1); + c.lineTo(x2, y2); + if( !opts.noStroke ) c.stroke(); + if( opts.fill ) c.fill(); +} + +function undo() { + var history = window.points.history; + if( history.last > 1 ) { + var step = history[history.last-1]; + c.putImageData(step.data, 0, 0); + window.points = step.points.slice(0); + window.points.history = history; + window.points.history.last = history.last-1; + } else { + c.clearRect(0,0, width(), height()); + window.points = []; + window.points.history = history; + window.points.history.last = 0; + } + +} + +function redo() { + var history = window.points.history; + if( history.last < history.length-1 ) { + var step = history[history.last+1]; + c.putImageData(step.data, 0, 0); + window.points = step.points.slice(0); + window.points.history = history; + window.points.history.last = history.last+1; + } +} + +function width() { + return +$c.attr('width'); +} + +function height() { + return +$c.attr('height'); +} + +function dataToBlob(data) { + var binary = atob(data.split(',')[1]), array = []; + var type = data.split(',')[0].split(':')[1].split(';')[0]; + for(var i = 0; i < binary.length; i++) array.push(binary.charCodeAt(i)); + return new Blob([new Uint8Array(array)], {type: type}); +} + + +/*** END ***/ + +function startPoint(x, y) { + + // If no previous point exists, make the first one. + if( !points.length ) points.push({x: x, y: y, type: '', start: {x: x, y: y}}); + + var old = points[points.length-1], + start = old.start, + current = { + x : x, + y : y, + start : old.start || {x: x, y: y}, + type : settings.type + } + if( old.type !== 'line' && current.type == 'line' ) { + window.o.beginPath(); + window.o.fillStyle = 'red'; + window.o.arc(x,y, 3, 0, 2*Math.PI); + window.o.fill(); + } + + if( old.type == 'line' && current.type == 'line' ) { + if( points[points.indexOf(old)-1].type !== 'line' ) { + o.clearRect(old.x-3, old.y-3, 6, 6, true); + draw(old.x, old.y, x, y); + } else + draw(old.x, old.y, x, y); + } + + var thresholds = window.mobile ? [10, 5] : [5, 2]; + if( points.length > 1 && ((start && threshold(start.x, start.y, x, y, thresholds[0])) || threshold(old.x, old.y, x, y, thresholds[1])) ) { + window.active = false; + points[points.length-1].type = ''; + points[points.length-1].start = undefined; + return; + } + points.push(current); +} + +function drawPoint(x,y) { + var capture = points[points.length-1]; + + switch(capture.type) { + case 'eraser': { + capture.type = 'pen'; + } + case 'pen': { + draw(capture.x, capture.y, x, y); + + var current = { + x : x, + y : y, + start : capture.start, + type : capture.type + } + + points.push(current); + break; + } + case 'sketch': { + draw(capture.x, capture.y, x, y); + var current = { + x : x, + y : y, + start : capture.start, + type : capture.type + } + points.push(current); + + for( var i = 0, len = points.length-1; i < len; i++ ) { + if(threshold(points[i].x, points[i].y, current.x, current.y, settings.connectTelorance)) { + var x = points[i].x - current.x, + y = points[i].y - current.y; + + draw(points[i].x - x*0.2, points[i].y - y*0.2, current.x + x*0.2, current.y + y*0.2, {strokeStyle: 'rgba(0,0,0,0.4)', lineWidth: settings.lineWidth/20}) + } + } + break; + } + case 'fur': { + draw(capture.x, capture.y, x, y); + var current = { + x : x, + y : y, + start : capture.start, + type : capture.type + } + points.push(current); + + for( var i = 0, len = points.length-1; i < len; i++ ) { + if(threshold(points[i].x, points[i].y, current.x, current.y, settings.connectTelorance)) { + var x = points[i].x - current.x, + y = points[i].y - current.y; + var l = settings.furLength / 100 || 0.2; + draw(points[i].x + x*l, points[i].y + y*l, current.x - x*l, current.y - y*l, {strokeStyle: 'rgba(0,0,0,0.4)', lineWidth: settings.lineWidth/2}) + } + } + break; + } + } +} + diff --git a/Web/js/less-1.5.0.min.js b/Web/js/less-1.5.0.min.js new file mode 100644 index 0000000..ef4be90 --- /dev/null +++ b/Web/js/less-1.5.0.min.js @@ -0,0 +1,13 @@ +/*! + * LESS - Leaner CSS v1.5.0 + * http://lesscss.org + * + * Copyright (c) 2009-2013, Alexis Sellier + * Licensed under the Apache v2 License. + * + * @licence + */ + +function require(a){return window.less[a.split("/")[1]]}function log(a,b){"development"==less.env&&"undefined"!=typeof console&&less.logLevel>=b&&console.log("less: "+a)}function extractId(a){return a.replace(/^[a-z-]+:\/+?[^\/]+/,"").replace(/^\//,"").replace(/\.[a-zA-Z]+$/,"").replace(/[^\.\w-]+/g,"-").replace(/\./g,":")}function errorConsole(a,b){var c="{line} {content}",d=a.filename||b,e=[],f=(a.type||"Syntax")+"Error: "+(a.message||"There is an error in your .less file")+" in "+d+" ",g=function(a,b,d){void 0!==a.extract[b]&&e.push(c.replace(/\{line\}/,(parseInt(a.line,10)||0)+(b-1)).replace(/\{class\}/,d).replace(/\{content\}/,a.extract[b]))};a.extract?(g(a,0,""),g(a,1,"line"),g(a,2,""),f+="on line "+a.line+", column "+(a.column+1)+":\n"+e.join("\n")):a.stack&&(f+=a.stack),log(f,logLevel.errors)}function createCSS(a,b,c){var d=b.href||"",e="less:"+(b.title||extractId(d)),f=document.getElementById(e),g=!1,h=document.createElement("style");if(h.setAttribute("type","text/css"),b.media&&h.setAttribute("media",b.media),h.id=e,h.styleSheet)try{h.styleSheet.cssText=a}catch(i){throw new Error("Couldn't reassign styleSheet.cssText.")}else h.appendChild(document.createTextNode(a)),g=null!==f&&f.childNodes.length>0&&h.childNodes.length>0&&f.firstChild.nodeValue===h.firstChild.nodeValue;var j=document.getElementsByTagName("head")[0];if(null===f||g===!1){var k=b&&b.nextSibling||null;k?k.parentNode.insertBefore(h,k):j.appendChild(h)}if(f&&g===!1&&f.parentNode.removeChild(f),c&&cache){log("saving "+d+" to cache.",logLevel.info);try{cache.setItem(d,a),cache.setItem(d+":timestamp",c)}catch(i){log("failed to save",logLevel.errors)}}}function errorHTML(a,b){var c,d,e="less-error-message:"+extractId(b||""),f='
  • {content}
  • ',g=document.createElement("div"),h=[],i=a.filename||b,j=i.match(/([^\/]+(\?.*)?)$/)[1];g.id=e,g.className="less-error-message",d="

    "+(a.type||"Syntax")+"Error: "+(a.message||"There is an error in your .less file")+"

    "+'

    in '+j+" ";var k=function(a,b,c){void 0!==a.extract[b]&&h.push(f.replace(/\{line\}/,(parseInt(a.line,10)||0)+(b-1)).replace(/\{class\}/,c).replace(/\{content\}/,a.extract[b]))};a.extract?(k(a,0,""),k(a,1,"line"),k(a,2,""),d+="on line "+a.line+", column "+(a.column+1)+":

    "+""):a.stack&&(d+="
    "+a.stack.split("\n").slice(1).join("
    ")),g.innerHTML=d,createCSS([".less-error-message ul, .less-error-message li {","list-style-type: none;","margin-right: 15px;","padding: 4px 0;","margin: 0;","}",".less-error-message label {","font-size: 12px;","margin-right: 15px;","padding: 4px 0;","color: #cc7777;","}",".less-error-message pre {","color: #dd6666;","padding: 4px 0;","margin: 0;","display: inline-block;","}",".less-error-message pre.line {","color: #ff0000;","}",".less-error-message h3 {","font-size: 20px;","font-weight: bold;","padding: 15px 0 5px 0;","margin: 0;","}",".less-error-message a {","color: #10a","}",".less-error-message .error {","color: red;","font-weight: bold;","padding-bottom: 2px;","border-bottom: 1px dashed red;","}"].join("\n"),{title:"error-message"}),g.style.cssText=["font-family: Arial, sans-serif","border: 1px solid #e00","background-color: #eee","border-radius: 5px","-webkit-border-radius: 5px","-moz-border-radius: 5px","color: #e00","padding: 15px","margin-bottom: 15px"].join(";"),"development"==less.env&&(c=setInterval(function(){document.body&&(document.getElementById(e)?document.body.replaceChild(g,document.getElementById(e)):document.body.insertBefore(g,document.body.firstChild),clearInterval(c))},10))}function error(a,b){less.errorReporting&&"html"!==less.errorReporting?"console"===less.errorReporting?errorConsole(a,b):"function"==typeof less.errorReporting&&less.errorReporting("add",a,b):errorHTML(a,b)}function removeErrorHTML(a){var b=document.getElementById("less-error-message:"+extractId(a));b&&b.parentNode.removeChild(b)}function removeErrorConsole(){}function removeError(a){less.errorReporting&&"html"!==less.errorReporting?"console"===less.errorReporting?removeErrorConsole(a):"function"==typeof less.errorReporting&&less.errorReporting("remove",a):removeErrorHTML(a)}function loadStyles(a){for(var b,c=document.getElementsByTagName("style"),d=0;d0&&(h.splice(c-1,2),c-=2)}return g.hostPart=f[1],g.directories=h,g.path=f[1]+h.join("/"),g.fileUrl=g.path+(f[4]||""),g.url=g.fileUrl+(f[5]||""),g}function pathDiff(a,b){var c,d,e,f,g=extractUrlParts(a),h=extractUrlParts(b),i="";if(g.hostPart!==h.hostPart)return"";for(d=Math.max(h.directories.length,g.directories.length),c=0;d>c&&h.directories[c]===g.directories[c];c++);for(f=h.directories.slice(c),e=g.directories.slice(c),c=0;c=200&&b.status<300?c(b.responseText,b.getResponseHeader("Last-Modified")):"function"==typeof d&&d(b.status,a)}var f=getXMLHttpRequest(),g=isFileProtocol?less.fileAsync:less.async;"function"==typeof f.overrideMimeType&&f.overrideMimeType("text/css"),log("XHR: Getting '"+a+"'",logLevel.info),f.open("GET",a,g),f.setRequestHeader("Accept",b||"text/x-less, text/css; q=0.9, */*; q=0.5"),f.send(null),isFileProtocol&&!less.fileAsync?0===f.status||f.status>=200&&f.status<300?c(f.responseText):d(f.status,a):g?f.onreadystatechange=function(){4==f.readyState&&e(f,c,d)}:e(f,c,d)}function loadFile(a,b,c,d,e){b&&b.currentDirectory&&!/^([a-z-]+:)?\//.test(a)&&(a=b.currentDirectory+a);var f=extractUrlParts(a,window.location.href),g=f.url,h={currentDirectory:f.path,filename:g};if(b?(h.entryPath=b.entryPath,h.rootpath=b.rootpath,h.rootFilename=b.rootFilename,h.relativeUrls=b.relativeUrls):(h.entryPath=f.path,h.rootpath=less.rootpath||f.path,h.rootFilename=g,h.relativeUrls=d.relativeUrls),h.relativeUrls&&(h.rootpath=d.rootpath?extractUrlParts(d.rootpath+pathDiff(f.path,h.entryPath)).path:f.path),d.useFileCache&&fileCache[g])try{var i=fileCache[g];e&&(i+="\n"+e),c(null,i,g,h,{lastModified:new Date})}catch(j){c(j,null,g)}else doXHR(g,d.mime,function(a,b){fileCache[g]=a;try{c(null,a,g,h,{lastModified:b})}catch(d){c(d,null,g)}},function(a,b){c({type:"File",message:"'"+b+"' wasn't found ("+a+")"},null,g)})}function loadStyleSheet(a,b,c,d,e){var f=new less.tree.parseEnv(less);f.mime=a.type,e&&(f.useFileCache=!0),loadFile(a.href,null,function(e,g,h,i,j){if(j){j.remaining=d;var k=cache&&cache.getItem(h),l=cache&&cache.getItem(h+":timestamp");if(!c&&l&&j.lastModified&&new Date(j.lastModified).valueOf()===new Date(l).valueOf())return createCSS(k,a),j.local=!0,b(null,null,g,a,j,h),void 0}removeError(h),g?(f.currentFileInfo=i,new less.Parser(f).parse(g,function(c,d){if(c)return b(c,null,null,a);try{b(c,d,g,a,j,h)}catch(c){b(c,null,null,a)}})):b(e,null,null,a,j,h)},f,e)}function loadStyleSheets(a,b,c){for(var d=0;dv&&(u[q]=u[q].slice(p-v),v=p)}function e(a){var b=a.charCodeAt(0);return 32===b||10===b||9===b}function f(a){var b,c;if(a instanceof Function)return a.call(w.parsers);if("string"==typeof a)b=o.charAt(p)===a?a:null,c=1,d();else{if(d(),!(b=a.exec(u[q])))return null;c=b[0].length}return b?(g(c),"string"==typeof b?b:1===b.length?b[0]:b):void 0}function g(a){for(var b=p,c=q,d=p+u[q].length,f=p+=a;d>p&&e(o.charAt(p));)p++;return u[q]=u[q].slice(a+(p-f)),v=p,0===u[q].length&&q=0&&"\n"!==b.charAt(c);)e++;return"number"==typeof a&&(d=(b.slice(0,a).match(/\n/g)||"").length),{line:d,column:e}}function m(a,b,c){var d=c.currentFileInfo.filename;return"browser"!==less.mode&&"rhino"!==less.mode&&(d=require("path").resolve(d)),{lineNumber:l(a,b).line+1,fileName:d}}function n(a,b){var c=k(a,b),d=l(a.index,c),e=d.line,f=d.column,g=a.call&&l(a.call,c).line,h=c.split("\n");this.type=a.type||"Syntax",this.message=a.message,this.filename=a.filename||b.currentFileInfo.filename,this.index=a.index,this.line="number"==typeof e?e+1:null,this.callLine=g+1,this.callExtract=h[g],this.stack=a.stack,this.column=f,this.extract=[h[e-1],h[e],h[e+1]]}var o,p,q,r,s,t,u,v,w,x=a&&a.filename;a instanceof tree.parseEnv||(a=new tree.parseEnv(a));var y=this.imports={paths:a.paths||[],queue:[],files:a.files,contents:a.contents,mime:a.mime,error:null,push:function(b,c,d,e){var f=this;this.queue.push(b);var g=function(a,c,d){f.queue.splice(f.queue.indexOf(b),1);var g=d in f.files||d===x;f.files[d]=c,a&&!f.error&&(f.error=a),e(a,c,g,d)};less.Parser.importer?less.Parser.importer(b,c,g,a):less.Parser.fileLoader(b,c,function(b,e,f,h){if(b)return g(b),void 0;var i=new tree.parseEnv(a);i.currentFileInfo=h,i.processImports=!1,i.contents[f]=e,(c.reference||d.reference)&&(h.reference=!0),d.inline?g(null,e,f):new less.Parser(i).parse(e,function(a,b){g(a,b,f)})},a)}};return n.prototype=new Error,n.prototype.constructor=n,this.env=a=a||{},this.optimization="optimization"in this.env?this.env.optimization:1,w={imports:y,parse:function(b,c){var d,e,g,h=null;if(p=q=v=t=0,o=b.replace(/\r\n/g,"\n"),o=o.replace(/^\uFEFF/,""),w.imports.contents[a.currentFileInfo.filename]=o,u=function(b){for(var c,d,e,f,g=0,i=/(?:@\{[\w-]+\}|[^"'`\{\}\/\(\)\\])+/g,j=/\/\*(?:[^*]|\*+[^\/*])*\*+\/|\/\/.*/g,k=/"((?:[^"\\\r\n]|\\.)*)"|'((?:[^'\\\r\n]|\\.)*)'|`((?:[^`]|\\.)*)`/g,l=0,m=b[0],p=0;p0?"missing closing `}`":"missing opening `{`",filename:a.currentFileInfo.filename},a)),b.map(function(a){return a.join("")})}([[]]),h)return c(new n(h,a));try{d=new tree.Ruleset([],f(this.parsers.primary)),d.root=!0,d.firstRoot=!0}catch(i){return c(new n(i,a))}if(d.toCSS=function(b){return function(c,d){c=c||{};var e,f,g=new tree.evalEnv(c);"object"!=typeof d||Array.isArray(d)||(d=Object.keys(d).map(function(a){var b=d[a];return b instanceof tree.Value||(b instanceof tree.Expression||(b=new tree.Expression([b])),b=new tree.Value([b])),new tree.Rule("@"+a,b,!1,null,0)}),g.frames=[new tree.Ruleset(null,d)]);try{e=b.call(this,g),(new tree.joinSelectorVisitor).run(e),(new tree.processExtendsVisitor).run(e),new tree.toCSSVisitor({compress:Boolean(c.compress)}).run(e),c.sourceMap&&(e=new tree.sourceMapOutput({writeSourceMap:c.writeSourceMap,rootNode:e,contentsMap:w.imports.contents,sourceMapFilename:c.sourceMapFilename,outputFilename:c.sourceMapOutputFilename,sourceMapBasepath:c.sourceMapBasepath,sourceMapRootpath:c.sourceMapRootpath,outputSourceFiles:c.outputSourceFiles,sourceMapGenerator:c.sourceMapGenerator})),f=e.toCSS({compress:Boolean(c.compress),dumpLineNumbers:a.dumpLineNumbers,strictUnits:Boolean(c.strictUnits)})}catch(h){throw new n(h,a)}return c.cleancss&&"node"===less.mode?require("clean-css").process(f):c.compress?f.replace(/(^(\s)+)|((\s)+$)/g,""):f}}(d.eval),p57||43>b||47===b||44==b))return(a=f(/^([+-]?\d*\.?\d+)(%|[a-z]+)?/))?new tree.Dimension(a[1],a[2]):void 0},unicodeDescriptor:function(){var a;return(a=f(/^U\+[0-9a-fA-F?]+(\-[0-9a-fA-F?]+)?/))?new tree.UnicodeDescriptor(a[0]):void 0},javascript:function(){var b,c,d=p;return"~"===o.charAt(d)&&(d++,c=!0),"`"===o.charAt(d)?(void 0===a.javascriptEnabled||a.javascriptEnabled||i("You are using JavaScript, which has been disabled."),c&&f("~"),(b=f(/^`([^`]*)`/))?new tree.JavaScript(b[1],p,c):void 0):void 0}},variable:function(){var a;return"@"===o.charAt(p)&&(a=f(/^(@[\w-]+)\s*:/))?a[1]:void 0},extend:function(a){var b,c,d,e=p,g=[];if(f(a?/^&:extend\(/:/^:extend\(/)){do{for(d=null,b=[];;){if(d=f(/^(all)(?=\s*(\)|,))/))break;if(c=f(this.element),!c)break;b.push(c)}d=d&&d[1],g.push(new tree.Extend(new tree.Selector(b),d,e))}while(f(","));return h(/^\)/),a&&h(/^;/),g}},extendRule:function(){return this.extend(!0)},mixin:{call:function(){var d,e,g,i=[],k=p,l=o.charAt(p),m=!1;if("."===l||"#"===l){for(b();d=f(/^[#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/);)i.push(new tree.Element(e,d,p,a.currentFileInfo)),e=f(">");return f("(")&&(g=this.mixin.args.call(this,!0).args,h(")")),g=g||[],f(this.important)&&(m=!0),i.length>0&&(f(";")||j("}"))?new tree.mixin.Call(i,g,k,a.currentFileInfo,m):(c(),void 0)}},args:function(a){for(var b,c,d,e,g,j,k=[],l=[],m=[],n={args:null,variadic:!1};;){if(a)j=f(this.expression);else{if(f(this.comments),"."===o.charAt(p)&&f(/^\.{3}/)){n.variadic=!0,f(";")&&!b&&(b=!0),(b?l:m).push({variadic:!0});break}j=f(this.entities.variable)||f(this.entities.literal)||f(this.entities.keyword)}if(!j)break;e=null,j.throwAwayComments&&j.throwAwayComments(),g=j;var q=null;if(a?1==j.value.length&&(q=j.value[0]):q=j,q&&q instanceof tree.Variable)if(f(":"))k.length>0&&(b&&i("Cannot mix ; and , as delimiter types"),c=!0),g=h(this.expression),e=d=q.name;else{if(!a&&f(/^\.{3}/)){n.variadic=!0,f(";")&&!b&&(b=!0),(b?l:m).push({name:j.name,variadic:!0});break}a||(d=e=q.name,g=null)}g&&k.push(g),m.push({name:e,value:g}),f(",")||(f(";")||b)&&(c&&i("Cannot mix ; and , as delimiter types"),b=!0,k.length>1&&(g=new tree.Value(k)),l.push({name:d,value:g}),d=null,k=[],c=!1)}return n.args=b?l:m,n},definition:function(){var a,d,e,g,i=[],k=!1;if(!("."!==o.charAt(p)&&"#"!==o.charAt(p)||j(/^[^{]*\}/))&&(b(),d=f(/^([#.](?:[\w-]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+)\s*\(/))){a=d[1];var l=this.mixin.args.call(this,!1);if(i=l.args,k=l.variadic,f(")")||(t=p,c()),f(this.comments),f(/^when/)&&(g=h(this.conditions,"expected condition")),e=f(this.block))return new tree.mixin.Definition(a,i,e,g,k);c()}}},entity:function(){return f(this.entities.literal)||f(this.entities.variable)||f(this.entities.url)||f(this.entities.call)||f(this.entities.keyword)||f(this.entities.javascript)||f(this.comment)},end:function(){return f(";")||j("}")},alpha:function(){var a;if(f(/^\(opacity=/i))return(a=f(/^\d+/)||f(this.entities.variable))?(h(")"),new tree.Alpha(a)):void 0},element:function(){var b,c,d;return c=f(this.combinator),b=f(/^(?:\d+\.\d+|\d+)%/)||f(/^(?:[.#]?|:*)(?:[\w-]|[^\x00-\x9f]|\\(?:[A-Fa-f0-9]{1,6} ?|[^A-Fa-f0-9]))+/)||f("*")||f("&")||f(this.attribute)||f(/^\([^()@]+\)/)||f(/^[\.#](?=@)/)||f(this.entities.variableCurly),b||f("(")&&(d=f(this.selector))&&f(")")&&(b=new tree.Paren(d)),b?new tree.Element(c,b,p,a.currentFileInfo):void 0},combinator:function(){var a=o.charAt(p);if(">"===a||"+"===a||"~"===a||"|"===a){for(p++;o.charAt(p).match(/\s/);)p++;return new tree.Combinator(a)}return o.charAt(p-1).match(/\s/)?new tree.Combinator(" "):new tree.Combinator(null)},lessSelector:function(){return this.selector(!0)},selector:function(b){for(var c,d,e,g,j,k=[],l=[];(b&&(e=f(this.extend))||b&&(g=f(/^when/))||(c=f(this.element)))&&(g?j=h(this.conditions,"expected condition"):j?i("CSS guard can only be used at the end of selector"):e?l.push.apply(l,e):(l.length&&i("Extend can only be used at the end of selector"),d=o.charAt(p),k.push(c),c=null),"{"!==d&&"}"!==d&&";"!==d&&","!==d&&")"!==d););return k.length>0?new tree.Selector(k,l,j,p,a.currentFileInfo):(l.length&&i("Extend must be used to extend a selector, it cannot be used on its own"),void 0)},attribute:function(){var a,b,c;if(f("["))return(a=f(this.entities.variableCurly))||(a=h(/^(?:[_A-Za-z0-9-\*]*\|)?(?:[_A-Za-z0-9-]|\\.)+/)),(c=f(/^[|~*$^]?=/))&&(b=f(this.entities.quoted)||f(/^[0-9]+%/)||f(/^[\w-]+/)||f(this.entities.variableCurly)),h("]"),new tree.Attribute(a,c,b)},block:function(){var a;return f("{")&&(a=f(this.primary))&&f("}")?a:void 0},ruleset:function(){var d,e,g,h=[];for(b(),a.dumpLineNumbers&&(g=m(p,o,a));(d=f(this.lessSelector))&&(h.push(d),f(this.comments),f(","));)d.condition&&i("Guards are only currently allowed on a single selector."),f(this.comments);if(h.length>0&&(e=f(this.block))){var j=new tree.Ruleset(h,e,a.strictImports);return a.dumpLineNumbers&&(j.debugInfo=g),j}t=p,c()},rule:function(d){var e,g,h,i=o.charAt(p),j=!1;if(b(),"."!==i&&"#"!==i&&"&"!==i&&(e=f(this.variable)||f(this.ruleProperty))){if(g=d||!a.compress&&"@"!==e.charAt(0)?f(this.anonymousValue)||f(this.value):f(this.value)||f(this.anonymousValue),h=f(this.important),"+"===e[e.length-1]&&(j=!0,e=e.substr(0,e.length-1)),g&&f(this.end))return new tree.Rule(e,g,h,j,s,a.currentFileInfo);if(t=p,c(),g&&!d)return this.rule(!0)}},anonymousValue:function(){var a;return(a=/^([^@+\/'"*`(;{}-]*);/.exec(u[q]))?(p+=a[0].length-1,new tree.Anonymous(a[1])):void 0},"import":function(){var d,e,g=p;b();var h=f(/^@import?\s+/),i=(h?f(this.importOptions):null)||{};return h&&(d=f(this.entities.quoted)||f(this.entities.url))&&(e=f(this.mediaFeatures),f(";"))?(e=e&&new tree.Value(e),new tree.Import(d,e,i,g,a.currentFileInfo)):(c(),void 0)},importOptions:function(){var a,b,c,d={};if(!f("("))return null;do if(a=f(this.importOption)){switch(b=a,c=!0,b){case"css":b="less",c=!1;break;case"once":b="multiple",c=!1}if(d[b]=c,!f(","))break}while(a);return h(")"),d},importOption:function(){var a=f(/^(less|css|multiple|once|inline|reference)/);return a?a[1]:void 0},mediaFeature:function(){var b,c,d=[];do if(b=f(this.entities.keyword)||f(this.entities.variable))d.push(b);else if(f("(")){if(c=f(this.property),b=f(this.value),!f(")"))return null;if(c&&b)d.push(new tree.Paren(new tree.Rule(c,b,null,null,p,a.currentFileInfo,!0)));else{if(!b)return null;d.push(new tree.Paren(b))}}while(b);return d.length>0?new tree.Expression(d):void 0},mediaFeatures:function(){var a,b=[];do if(a=f(this.mediaFeature)){if(b.push(a),!f(","))break}else if((a=f(this.entities.variable))&&(b.push(a),!f(",")))break;while(a);return b.length>0?b:null},media:function(){var b,c,d,e;return a.dumpLineNumbers&&(e=m(p,o,a)),f(/^@media/)&&(b=f(this.mediaFeatures),c=f(this.block))?(d=new tree.Media(c,b,p,a.currentFileInfo),a.dumpLineNumbers&&(d.debugInfo=e),d):void 0},directive:function(){var d,e,g,h,i,j,k,l;if("@"===o.charAt(p)){if(e=f(this["import"])||f(this.media))return e;if(b(),d=f(/^@[a-z-]+/)){switch(h=d,"-"==d.charAt(1)&&d.indexOf("-",2)>0&&(h="@"+d.slice(d.indexOf("-",2)+1)),h){case"@font-face":i=!0;break;case"@viewport":case"@top-left":case"@top-left-corner":case"@top-center":case"@top-right":case"@top-right-corner":case"@bottom-left":case"@bottom-left-corner":case"@bottom-center":case"@bottom-right":case"@bottom-right-corner":case"@left-top":case"@left-middle":case"@left-bottom":case"@right-top":case"@right-middle":case"@right-bottom":i=!0;break;case"@host":case"@page":case"@document":case"@supports":case"@keyframes":i=!0,j=!0;break;case"@namespace":k=!0}if(j&&(l=(f(/^[^{]+/)||"").trim(),l&&(d+=" "+l)),i){if(g=f(this.block))return new tree.Directive(d,g,p,a.currentFileInfo)}else if((e=k?f(this.expression):f(this.entity))&&f(";")){var n=new tree.Directive(d,e,p,a.currentFileInfo);return a.dumpLineNumbers&&(n.debugInfo=m(p,o,a)),n}c()}}},value:function(){for(var a,b=[];(a=f(this.expression))&&(b.push(a),f(",")););return b.length>0?new tree.Value(b):void 0},important:function(){return"!"===o.charAt(p)?f(/^! *important/):void 0},sub:function(){var a,b;return f("(")&&(a=f(this.addition))?(b=new tree.Expression([a]),h(")"),b.parens=!0,b):void 0},multiplication:function(){var a,b,c,d,g;if(a=f(this.operand)){for(g=e(o.charAt(p-1));!j(/^\/[*\/]/)&&(c=f("/")||f("*"))&&(b=f(this.operand));)a.parensInOp=!0,b.parensInOp=!0,d=new tree.Operation(c,[d||a,b],g),g=e(o.charAt(p-1));return d||a}},addition:function(){var a,b,c,d,g;if(a=f(this.multiplication)){for(g=e(o.charAt(p-1));(c=f(/^[-+]\s+/)||!g&&(f("+")||f("-")))&&(b=f(this.multiplication));)a.parensInOp=!0,b.parensInOp=!0,d=new tree.Operation(c,[d||a,b],g),g=e(o.charAt(p-1));return d||a}},conditions:function(){var a,b,c,d=p;if(a=f(this.condition)){for(;j(/^,\s*(not\s*)?\(/)&&f(",")&&(b=f(this.condition));)c=new tree.Condition("or",c||a,b,d);return c||a}},condition:function(){var a,b,c,d,e=p,g=!1;return f(/^not/)&&(g=!0),h("("),(a=f(this.addition)||f(this.entities.keyword)||f(this.entities.quoted))?((d=f(/^(?:>=|<=|=<|[<=>])/))?(b=f(this.addition)||f(this.entities.keyword)||f(this.entities.quoted))?c=new tree.Condition(d,a,b,e,g):i("expected expression"):c=new tree.Condition("=",a,new tree.Keyword("true"),e,g),h(")"),f(/^and/)?new tree.Condition("and",c,f(this.condition)):c):void 0},operand:function(){var a,b=o.charAt(p+1);"-"!==o.charAt(p)||"@"!==b&&"("!==b||(a=f("-"));var c=f(this.sub)||f(this.entities.dimension)||f(this.entities.color)||f(this.entities.variable)||f(this.entities.call);return a&&(c.parensInOp=!0,c=new tree.Negative(c)),c},expression:function(){for(var a,b,c=[];a=f(this.addition)||f(this.entity);)c.push(a),!j(/^\/[\/*]/)&&(b=f("/"))&&c.push(new tree.Anonymous(b));return c.length>0?new tree.Expression(c):void 0},property:function(){var a;return(a=f(/^(\*?-?[_a-zA-Z0-9-]+)\s*:/))?a[1]:void 0},ruleProperty:function(){var a;return(a=f(/^(\*?-?[_a-zA-Z0-9-]+)\s*(\+?)\s*:/))?a[1]+(a[2]||""):void 0}}}},function(a){function b(b){return a.functions.hsla(b.h,b.s,b.l,b.a)}function c(b,c){return b instanceof a.Dimension&&b.unit.is("%")?parseFloat(b.value*c/100):d(b)}function d(b){if(b instanceof a.Dimension)return parseFloat(b.unit.is("%")?b.value/100:b.value);if("number"==typeof b)return b;throw{error:"RuntimeError",message:"color functions take numbers as parameters"}}function e(a){return Math.min(1,Math.max(0,a))}a.functions={rgb:function(a,b,c){return this.rgba(a,b,c,1)},rgba:function(b,e,f,g){var h=[b,e,f].map(function(a){return c(a,256)});return g=d(g),new a.Color(h,g)},hsl:function(a,b,c){return this.hsla(a,b,c,1)},hsla:function(a,b,c,f){function g(a){return a=0>a?a+1:a>1?a-1:a,1>6*a?i+6*(h-i)*a:1>2*a?h:2>3*a?i+6*(h-i)*(2/3-a):i}a=d(a)%360/360,b=e(d(b)),c=e(d(c)),f=e(d(f));var h=.5>=c?c*(b+1):c+b-c*b,i=2*c-h;return this.rgba(255*g(a+1/3),255*g(a),255*g(a-1/3),f)},hsv:function(a,b,c){return this.hsva(a,b,c,1)},hsva:function(a,b,c,e){a=360*(d(a)%360/360),b=d(b),c=d(c),e=d(e);var f,g;f=Math.floor(a/60%6),g=a/60-f;var h=[c,c*(1-b),c*(1-g*b),c*(1-(1-g)*b)],i=[[0,3,1],[2,0,1],[1,0,3],[1,2,0],[3,1,0],[0,1,2]];return this.rgba(255*h[i[f][0]],255*h[i[f][1]],255*h[i[f][2]],e)},hue:function(b){return new a.Dimension(Math.round(b.toHSL().h))},saturation:function(b){return new a.Dimension(Math.round(100*b.toHSL().s),"%")},lightness:function(b){return new a.Dimension(Math.round(100*b.toHSL().l),"%")},hsvhue:function(b){return new a.Dimension(Math.round(b.toHSV().h))},hsvsaturation:function(b){return new a.Dimension(Math.round(100*b.toHSV().s),"%")},hsvvalue:function(b){return new a.Dimension(Math.round(100*b.toHSV().v),"%")},red:function(b){return new a.Dimension(b.rgb[0])},green:function(b){return new a.Dimension(b.rgb[1])},blue:function(b){return new a.Dimension(b.rgb[2])},alpha:function(b){return new a.Dimension(b.toHSL().a)},luma:function(b){return new a.Dimension(Math.round(100*b.luma()*b.alpha),"%")},saturate:function(a,c){if(!a.rgb)return null;var d=a.toHSL();return d.s+=c.value/100,d.s=e(d.s),b(d)},desaturate:function(a,c){var d=a.toHSL();return d.s-=c.value/100,d.s=e(d.s),b(d)},lighten:function(a,c){var d=a.toHSL();return d.l+=c.value/100,d.l=e(d.l),b(d)},darken:function(a,c){var d=a.toHSL();return d.l-=c.value/100,d.l=e(d.l),b(d)},fadein:function(a,c){var d=a.toHSL();return d.a+=c.value/100,d.a=e(d.a),b(d)},fadeout:function(a,c){var d=a.toHSL();return d.a-=c.value/100,d.a=e(d.a),b(d)},fade:function(a,c){var d=a.toHSL();return d.a=c.value/100,d.a=e(d.a),b(d)},spin:function(a,c){var d=a.toHSL(),e=(d.h+c.value)%360;return d.h=0>e?360+e:e,b(d)},mix:function(b,c,d){d||(d=new a.Dimension(50));var e=d.value/100,f=2*e-1,g=b.toHSL().a-c.toHSL().a,h=((-1==f*g?f:(f+g)/(1+f*g))+1)/2,i=1-h,j=[b.rgb[0]*h+c.rgb[0]*i,b.rgb[1]*h+c.rgb[1]*i,b.rgb[2]*h+c.rgb[2]*i],k=b.alpha*e+c.alpha*(1-e);return new a.Color(j,k)},greyscale:function(b){return this.desaturate(b,new a.Dimension(100))},contrast:function(a,b,c,e){if(!a.rgb)return null;if("undefined"==typeof c&&(c=this.rgba(255,255,255,1)),"undefined"==typeof b&&(b=this.rgba(0,0,0,1)),b.luma()>c.luma()){var f=c;c=b,b=f}return e="undefined"==typeof e?.43:d(e),a.luma()*a.alphah.value)&&(j[e]=f)):(k[i]=j.length,j.push(f))):j.push(f);return 1==j.length?j[0]:(c=j.map(function(a){return a.toCSS(this.env)}).join(this.env.compress?",":", "),new a.Anonymous((b?"min":"max")+"("+c+")"))},min:function(){return this._minmax(!0,arguments)},max:function(){return this._minmax(!1,arguments)},argb:function(b){return new a.Anonymous(b.toARGB())},percentage:function(b){return new a.Dimension(100*b.value,"%")},color:function(b){if(b instanceof a.Quoted){var c,d=b.value;if(c=a.Color.fromKeyword(d))return c;if(/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})/.test(d))return new a.Color(d.slice(1));throw{type:"Argument",message:"argument must be a color keyword or 3/6 digit hex e.g. #FFF"}}throw{type:"Argument",message:"argument must be a string"}},iscolor:function(b){return this._isa(b,a.Color)},isnumber:function(b){return this._isa(b,a.Dimension)},isstring:function(b){return this._isa(b,a.Quoted)},iskeyword:function(b){return this._isa(b,a.Keyword)},isurl:function(b){return this._isa(b,a.URL) +},ispixel:function(a){return this.isunit(a,"px")},ispercentage:function(a){return this.isunit(a,"%")},isem:function(a){return this.isunit(a,"em")},isunit:function(b,c){return b instanceof a.Dimension&&b.unit.is(c.value||c)?a.True:a.False},_isa:function(b,c){return b instanceof c?a.True:a.False},multiply:function(a,b){var c=a.rgb[0]*b.rgb[0]/255,d=a.rgb[1]*b.rgb[1]/255,e=a.rgb[2]*b.rgb[2]/255;return this.rgb(c,d,e)},screen:function(a,b){var c=255-(255-a.rgb[0])*(255-b.rgb[0])/255,d=255-(255-a.rgb[1])*(255-b.rgb[1])/255,e=255-(255-a.rgb[2])*(255-b.rgb[2])/255;return this.rgb(c,d,e)},overlay:function(a,b){var c=a.rgb[0]<128?2*a.rgb[0]*b.rgb[0]/255:255-2*(255-a.rgb[0])*(255-b.rgb[0])/255,d=a.rgb[1]<128?2*a.rgb[1]*b.rgb[1]/255:255-2*(255-a.rgb[1])*(255-b.rgb[1])/255,e=a.rgb[2]<128?2*a.rgb[2]*b.rgb[2]/255:255-2*(255-a.rgb[2])*(255-b.rgb[2])/255;return this.rgb(c,d,e)},softlight:function(a,b){var c=b.rgb[0]*a.rgb[0]/255,d=c+a.rgb[0]*(255-(255-a.rgb[0])*(255-b.rgb[0])/255-c)/255;c=b.rgb[1]*a.rgb[1]/255;var e=c+a.rgb[1]*(255-(255-a.rgb[1])*(255-b.rgb[1])/255-c)/255;c=b.rgb[2]*a.rgb[2]/255;var f=c+a.rgb[2]*(255-(255-a.rgb[2])*(255-b.rgb[2])/255-c)/255;return this.rgb(d,e,f)},hardlight:function(a,b){var c=b.rgb[0]<128?2*b.rgb[0]*a.rgb[0]/255:255-2*(255-b.rgb[0])*(255-a.rgb[0])/255,d=b.rgb[1]<128?2*b.rgb[1]*a.rgb[1]/255:255-2*(255-b.rgb[1])*(255-a.rgb[1])/255,e=b.rgb[2]<128?2*b.rgb[2]*a.rgb[2]/255:255-2*(255-b.rgb[2])*(255-a.rgb[2])/255;return this.rgb(c,d,e)},difference:function(a,b){var c=Math.abs(a.rgb[0]-b.rgb[0]),d=Math.abs(a.rgb[1]-b.rgb[1]),e=Math.abs(a.rgb[2]-b.rgb[2]);return this.rgb(c,d,e)},exclusion:function(a,b){var c=a.rgb[0]+b.rgb[0]*(255-a.rgb[0]-a.rgb[0])/255,d=a.rgb[1]+b.rgb[1]*(255-a.rgb[1]-a.rgb[1])/255,e=a.rgb[2]+b.rgb[2]*(255-a.rgb[2]-a.rgb[2])/255;return this.rgb(c,d,e)},average:function(a,b){var c=(a.rgb[0]+b.rgb[0])/2,d=(a.rgb[1]+b.rgb[1])/2,e=(a.rgb[2]+b.rgb[2])/2;return this.rgb(c,d,e)},negation:function(a,b){var c=255-Math.abs(255-b.rgb[0]-a.rgb[0]),d=255-Math.abs(255-b.rgb[1]-a.rgb[1]),e=255-Math.abs(255-b.rgb[2]-a.rgb[2]);return this.rgb(c,d,e)},tint:function(a,b){return this.mix(this.rgb(255,255,255),a,b)},shade:function(a,b){return this.mix(this.rgb(0,0,0),a,b)},extract:function(a,b){return b=b.value-1,Array.isArray(a.value)?a.value[b]:Array(a)[b]},length:function(b){var c=Array.isArray(b.value)?b.value.length:1;return new a.Dimension(c)},"data-uri":function(b,c){if("undefined"!=typeof window)return new a.URL(c||b,this.currentFileInfo).eval(this.env);var d=b.value,e=c&&c.value,f=require("fs"),g=require("path"),h=!1;if(arguments.length<2&&(e=d),this.env.isPathRelative(e)&&(e=this.currentFileInfo.relativeUrls?g.join(this.currentFileInfo.currentDirectory,e):g.join(this.currentFileInfo.entryPath,e)),arguments.length<2){var i;try{i=require("mime")}catch(j){i=a._mime}d=i.lookup(e);var k=i.charsets.lookup(d);h=["US-ASCII","UTF-8"].indexOf(k)<0,h&&(d+=";base64")}else h=/;base64$/.test(d);var l=f.readFileSync(e),m=32,n=parseInt(l.length/1024,10);if(n>=m&&this.env.ieCompat!==!1)return this.env.silent||console.warn("Skipped data-uri embedding of %s because its size (%dKB) exceeds IE8-safe %dKB!",e,n,m),new a.URL(c||b,this.currentFileInfo).eval(this.env);l=h?l.toString("base64"):encodeURIComponent(l);var o="'data:"+d+","+l+"'";return new a.URL(new a.Anonymous(o))},"svg-gradient":function(b){function c(){throw{type:"Argument",message:"svg-gradient expects direction, start_color [start_position], [color position,]..., end_color [end_position]"}}arguments.length<3&&c();var d,e,f,g,h,i,j,k=Array.prototype.slice.call(arguments,1),l="linear",m='x="0" y="0" width="1" height="1"',n=!0,o={compress:!1},p=b.toCSS(o);switch(p){case"to bottom":d='x1="0%" y1="0%" x2="0%" y2="100%"';break;case"to right":d='x1="0%" y1="0%" x2="100%" y2="0%"';break;case"to bottom right":d='x1="0%" y1="0%" x2="100%" y2="100%"';break;case"to top right":d='x1="0%" y1="100%" x2="100%" y2="0%"';break;case"ellipse":case"ellipse at center":l="radial",d='cx="50%" cy="50%" r="75%"',m='x="-50" y="-50" width="101" height="101"';break;default:throw{type:"Argument",message:"svg-gradient direction must be 'to bottom', 'to right', 'to bottom right', 'to top right' or 'ellipse at center'"}}for(e='<'+l+'Gradient id="gradient" gradientUnits="userSpaceOnUse" '+d+">",f=0;fj?' stop-opacity="'+j+'"':"")+"/>";if(e+=""+"',n)try{e=new Buffer(e).toString("base64")}catch(q){n=!1}return e="'data:image/svg+xml"+(n?";base64":"")+","+e+"'",new a.URL(new a.Anonymous(e))}},a._mime={_types:{".htm":"text/html",".html":"text/html",".gif":"image/gif",".jpg":"image/jpeg",".jpeg":"image/jpeg",".png":"image/png"},lookup:function(b){var c=require("path").extname(b),d=a._mime._types[c];if(void 0===d)throw new Error('Optional dependency "mime" is required for '+c);return d},charsets:{lookup:function(a){return a&&/^text\//.test(a)?"UTF-8":""}}};for(var f=[{name:"ceil"},{name:"floor"},{name:"sqrt"},{name:"abs"},{name:"tan",unit:""},{name:"sin",unit:""},{name:"cos",unit:""},{name:"atan",unit:"rad"},{name:"asin",unit:"rad"},{name:"acos",unit:"rad"}],g=function(a,b){return function(c){return null!=b&&(c=c.unify()),this._math(Math[a],b,c)}},h=0;h1?"["+a.value.map(function(a){return a.toCSS(!1)}).join(", ")+"]":a.toCSS(!1)},a.toCSS=function(a){var b=[];return this.genCSS(a,{add:function(a){b.push(a)},isEmpty:function(){return 0===b.length}}),b.join("")},a.outputRuleset=function(a,b,c){b.add(a.compress?"{":" {\n"),a.tabLevel=(a.tabLevel||0)+1;for(var d=a.compress?"":Array(a.tabLevel+1).join(" "),e=a.compress?"":Array(a.tabLevel).join(" "),f=0;fb?-1:1},genCSS:function(a,b){b.add(this.value,this.currentFileInfo,this.index,this.mapLines)},toCSS:a.toCSS}}(require("../tree")),function(a){a.Assignment=function(a,b){this.key=a,this.value=b},a.Assignment.prototype={type:"Assignment",accept:function(a){this.value=a.visit(this.value)},eval:function(b){return this.value.eval?new a.Assignment(this.key,this.value.eval(b)):this},genCSS:function(a,b){b.add(this.key+"="),this.value.genCSS?this.value.genCSS(a,b):b.add(this.value)},toCSS:a.toCSS}}(require("../tree")),function(a){a.Call=function(a,b,c,d){this.name=a,this.args=b,this.index=c,this.currentFileInfo=d},a.Call.prototype={type:"Call",accept:function(a){this.args=a.visit(this.args)},eval:function(b){var c,d,e=this.args.map(function(a){return a.eval(b)}),f=this.name.toLowerCase();if(f in a.functions)try{if(d=new a.functionCall(b,this.currentFileInfo),c=d[f].apply(d,e),null!=c)return c}catch(g){throw{type:g.type||"Runtime",message:"error evaluating function `"+this.name+"`"+(g.message?": "+g.message:""),index:this.index,filename:this.currentFileInfo.filename}}return new a.Call(this.name,e,this.index,this.currentFileInfo)},genCSS:function(a,b){b.add(this.name+"(",this.currentFileInfo,this.index);for(var c=0;cf;f++)e[f]=a.operate(b,c,this.rgb[f],d.rgb[f]);return new a.Color(e,this.alpha+d.alpha)},toRGB:function(){return"#"+this.rgb.map(function(a){return a=Math.round(a),a=(a>255?255:0>a?0:a).toString(16),1===a.length?"0"+a:a}).join("")},toHSL:function(){var a,b,c=this.rgb[0]/255,d=this.rgb[1]/255,e=this.rgb[2]/255,f=this.alpha,g=Math.max(c,d,e),h=Math.min(c,d,e),i=(g+h)/2,j=g-h;if(g===h)a=b=0;else{switch(b=i>.5?j/(2-g-h):j/(g+h),g){case c:a=(d-e)/j+(e>d?6:0);break;case d:a=(e-c)/j+2;break;case e:a=(c-d)/j+4}a/=6}return{h:360*a,s:b,l:i,a:f}},toHSV:function(){var a,b,c=this.rgb[0]/255,d=this.rgb[1]/255,e=this.rgb[2]/255,f=this.alpha,g=Math.max(c,d,e),h=Math.min(c,d,e),i=g,j=g-h;if(b=0===g?0:j/g,g===h)a=0;else{switch(g){case c:a=(d-e)/j+(e>d?6:0);break;case d:a=(e-c)/j+2;break;case e:a=(c-d)/j+4}a/=6}return{h:360*a,s:b,v:i,a:f}},toARGB:function(){var a=[Math.round(255*this.alpha)].concat(this.rgb);return"#"+a.map(function(a){return a=Math.round(a),a=(a>255?255:0>a?0:a).toString(16),1===a.length?"0"+a:a}).join("")},compare:function(a){return a.rgb?a.rgb[0]===this.rgb[0]&&a.rgb[1]===this.rgb[1]&&a.rgb[2]===this.rgb[2]&&a.alpha===this.alpha?0:-1:-1}},a.Color.fromKeyword=function(c){if(a.colors.hasOwnProperty(c))return new a.Color(a.colors[c].slice(1));if(c===b){var d=new a.Color([0,0,0],0);return d.isTransparentKeyword=!0,d}}}(require("../tree")),function(a){a.Comment=function(a,b,c,d){this.value=a,this.silent=!!b,this.currentFileInfo=d},a.Comment.prototype={type:"Comment",genCSS:function(b,c){this.debugInfo&&c.add(a.debugInfo(b,this),this.currentFileInfo,this.index),c.add(this.value.trim())},toCSS:a.toCSS,isSilent:function(a){var b=this.currentFileInfo&&this.currentFileInfo.reference&&!this.isReferenced,c=a.compress&&!this.value.match(/^\/\*!/);return this.silent||b||c},eval:function(){return this},markReferenced:function(){this.isReferenced=!0}}}(require("../tree")),function(a){a.Condition=function(a,b,c,d,e){this.op=a.trim(),this.lvalue=b,this.rvalue=c,this.index=d,this.negate=e},a.Condition.prototype={type:"Condition",accept:function(a){this.lvalue=a.visit(this.lvalue),this.rvalue=a.visit(this.rvalue)},eval:function(a){var b,c=this.lvalue.eval(a),d=this.rvalue.eval(a),e=this.index;return b=function(a){switch(a){case"and":return c&&d;case"or":return c||d;default:if(c.compare)b=c.compare(d);else{if(!d.compare)throw{type:"Type",message:"Unable to perform comparison",index:e};b=d.compare(c)}switch(b){case-1:return"<"===a||"=<"===a||"<="===a;case 0:return"="===a||">="===a||"=<"===a||"<="===a;case 1:return">"===a||">="===a}}}(this.op),this.negate?!b:b}}}(require("../tree")),function(a){a.Dimension=function(b,c){this.value=parseFloat(b),this.unit=c&&c instanceof a.Unit?c:new a.Unit(c?[c]:void 0)},a.Dimension.prototype={type:"Dimension",accept:function(a){this.unit=a.visit(this.unit)},eval:function(){return this},toColor:function(){return new a.Color([this.value,this.value,this.value])},genCSS:function(a,b){if(a&&a.strictUnits&&!this.unit.isSingular())throw new Error("Multiple units in dimension. Correct the units or use the unit function. Bad unit: "+this.unit.toString());var c=this.value,d=String(c);if(0!==c&&1e-6>c&&c>-1e-6&&(d=c.toFixed(20).replace(/0+$/,"")),a&&a.compress){if(0===c&&this.unit.isLength())return b.add(d),void 0;c>0&&1>c&&(d=d.substr(1))}b.add(d),this.unit.genCSS(a,b)},toCSS:a.toCSS,operate:function(b,c,d){var e=a.operate(b,c,this.value,d.value),f=this.unit.clone();if("+"===c||"-"===c)if(0===f.numerator.length&&0===f.denominator.length)f.numerator=d.unit.numerator.slice(0),f.denominator=d.unit.denominator.slice(0);else if(0===d.unit.numerator.length&&0===f.denominator.length);else{if(d=d.convertTo(this.unit.usedUnits()),b.strictUnits&&d.unit.toString()!==f.toString())throw new Error("Incompatible units. Change the units or use the unit function. Bad units: '"+f.toString()+"' and '"+d.unit.toString()+"'.");e=a.operate(b,c,this.value,d.value)}else"*"===c?(f.numerator=f.numerator.concat(d.unit.numerator).sort(),f.denominator=f.denominator.concat(d.unit.denominator).sort(),f.cancel()):"/"===c&&(f.numerator=f.numerator.concat(d.unit.denominator).sort(),f.denominator=f.denominator.concat(d.unit.numerator).sort(),f.cancel());return new a.Dimension(e,f)},compare:function(b){if(b instanceof a.Dimension){var c=this.unify(),d=b.unify(),e=c.value,f=d.value;return f>e?-1:e>f?1:d.unit.isEmpty()||0===c.unit.compare(d.unit)?0:-1}return-1},unify:function(){return this.convertTo({length:"m",duration:"s",angle:"rad"})},convertTo:function(b){var c,d,e,f,g,h=this.value,i=this.unit.clone(),j={};if("string"==typeof b){for(c in a.UnitConversions)a.UnitConversions[c].hasOwnProperty(b)&&(j={},j[c]=b);b=j}g=function(a,b){return e.hasOwnProperty(a)?(b?h/=e[a]/e[f]:h*=e[a]/e[f],f):a};for(d in b)b.hasOwnProperty(d)&&(f=b[d],e=a.UnitConversions[d],i.map(g));return i.cancel(),new a.Dimension(h,i)}},a.UnitConversions={length:{m:1,cm:.01,mm:.001,"in":.0254,pt:.0254/72,pc:12*(.0254/72)},duration:{s:1,ms:.001},angle:{rad:1/(2*Math.PI),deg:1/360,grad:.0025,turn:1}},a.Unit=function(a,b,c){this.numerator=a?a.slice(0).sort():[],this.denominator=b?b.slice(0).sort():[],this.backupUnit=c},a.Unit.prototype={type:"Unit",clone:function(){return new a.Unit(this.numerator.slice(0),this.denominator.slice(0),this.backupUnit)},genCSS:function(a,b){this.numerator.length>=1?b.add(this.numerator[0]):this.denominator.length>=1?b.add(this.denominator[0]):a&&a.strictUnits||!this.backupUnit||b.add(this.backupUnit)},toCSS:a.toCSS,toString:function(){var a,b=this.numerator.join("*");for(a=0;a0)for(b=0;e>b;b++)this.numerator.push(a);else if(0>e)for(b=0;-e>b;b++)this.denominator.push(a)}0===this.numerator.length&&0===this.denominator.length&&c&&(this.backupUnit=c),this.numerator.sort(),this.denominator.sort()}}}(require("../tree")),function(a){a.Directive=function(b,c,d,e){this.name=b,Array.isArray(c)?(this.rules=[new a.Ruleset([],c)],this.rules[0].allowImports=!0):this.value=c,this.currentFileInfo=e},a.Directive.prototype={type:"Directive",accept:function(a){this.rules=a.visit(this.rules),this.value=a.visit(this.value)},genCSS:function(b,c){c.add(this.name,this.currentFileInfo,this.index),this.rules?a.outputRuleset(b,c,this.rules):(c.add(" "),this.value.genCSS(b,c),c.add(";"))},toCSS:a.toCSS,eval:function(b){var c=this;return this.rules&&(b.frames.unshift(this),c=new a.Directive(this.name,null,this.index,this.currentFileInfo),c.rules=[this.rules[0].eval(b)],c.rules[0].root=!0,b.frames.shift()),c},variable:function(b){return a.Ruleset.prototype.variable.call(this.rules[0],b)},find:function(){return a.Ruleset.prototype.find.apply(this.rules[0],arguments)},rulesets:function(){return a.Ruleset.prototype.rulesets.apply(this.rules[0])},markReferenced:function(){var a,b;if(this.isReferenced=!0,this.rules)for(b=this.rules[0].rules,a=0;a":" > ","|":"|"},_outputMapCompressed:{"":""," ":" ",":":" :","+":"+","~":"~",">":">","|":"|"},genCSS:function(a,b){b.add((a.compress?this._outputMapCompressed:this._outputMap)[this.value])},toCSS:a.toCSS}}(require("../tree")),function(a){a.Expression=function(a){this.value=a},a.Expression.prototype={type:"Expression",accept:function(a){this.value=a.visit(this.value)},eval:function(b){var c,d=this.parens&&!this.parensInOp,e=!1;return d&&b.inParenthesis(),this.value.length>1?c=new a.Expression(this.value.map(function(a){return a.eval(b)})):1===this.value.length?(this.value[0].parens&&!this.value[0].parensInOp&&(e=!0),c=this.value[0].eval(b)):c=this,d&&b.outOfParenthesis(),this.parens&&this.parensInOp&&!b.isMathOn()&&!e&&(c=new a.Paren(c)),c},genCSS:function(a,b){for(var c=0;c0&&c.length&&""===c[0].combinator.value&&(c[0].combinator.value=" "),d=d.concat(a[b].elements);this.selfSelectors=[{elements:d}]}}}(require("../tree")),function(a){a.Import=function(a,b,c,d,e){if(this.options=c,this.index=d,this.path=a,this.features=b,this.currentFileInfo=e,void 0!==this.options.less||this.options.inline)this.css=!this.options.less||this.options.inline;else{var f=this.getPath();f&&/css([\?;].*)?$/.test(f)&&(this.css=!0)}},a.Import.prototype={type:"Import",accept:function(a){this.features=a.visit(this.features),this.path=a.visit(this.path),this.options.inline||(this.root=a.visit(this.root))},genCSS:function(a,b){this.css&&(b.add("@import ",this.currentFileInfo,this.index),this.path.genCSS(a,b),this.features&&(b.add(" "),this.features.genCSS(a,b)),b.add(";"))},toCSS:a.toCSS,getPath:function(){if(this.path instanceof a.Quoted){var b=this.path.value;return void 0!==this.css||/(\.[a-z]*$)|([\?;].*)$/.test(b)?b:b+".less"}return this.path instanceof a.URL?this.path.value.value:null},evalForImport:function(b){return new a.Import(this.path.eval(b),this.features,this.options,this.index,this.currentFileInfo)},evalPath:function(b){var c=this.path.eval(b),d=this.currentFileInfo&&this.currentFileInfo.rootpath;if(!(c instanceof a.URL)){if(d){var e=c.value;e&&b.isPathRelative(e)&&(c.value=d+e)}c.value=b.normalizePath(c.value)}return c},eval:function(b){var c,d=this.features&&this.features.eval(b);if(this.skip)return[];if(this.options.inline){var e=new a.Anonymous(this.root,0,{filename:this.importedFilename},!0);return this.features?new a.Media([e],this.features.value):[e]}if(this.css){var f=new a.Import(this.evalPath(b),d,this.options,this.index);if(!f.css&&this.error)throw this.error;return f}return c=new a.Ruleset([],this.root.rules.slice(0)),c.evalImports(b),this.features?new a.Media(c.rules,this.features.value):c.rules}}}(require("../tree")),function(a){a.JavaScript=function(a,b,c){this.escaped=c,this.expression=a,this.index=b},a.JavaScript.prototype={type:"JavaScript",eval:function(b){var c,d=this,e={},f=this.expression.replace(/@\{([\w-]+)\}/g,function(c,e){return a.jsify(new a.Variable("@"+e,d.index).eval(b))});try{f=new Function("return ("+f+")")}catch(g){throw{message:"JavaScript evaluation error: "+g.message+" from `"+f+"`",index:this.index}}for(var h in b.frames[0].variables())e[h.slice(1)]={value:b.frames[0].variables()[h].value,toJS:function(){return this.value.eval(b).toCSS()}};try{c=f.call(e)}catch(g){throw{message:"JavaScript evaluation error: '"+g.name+": "+g.message+"'",index:this.index}}return"string"==typeof c?new a.Quoted('"'+c+'"',c,this.escaped,this.index):Array.isArray(c)?new a.Anonymous(c.join(", ")):new a.Anonymous(c)}}}(require("../tree")),function(a){a.Keyword=function(a){this.value=a},a.Keyword.prototype={type:"Keyword",eval:function(){return this},genCSS:function(a,b){b.add(this.value)},toCSS:a.toCSS,compare:function(b){return b instanceof a.Keyword?b.value===this.value?0:1:-1}},a.True=new a.Keyword("true"),a.False=new a.Keyword("false")}(require("../tree")),function(a){a.Media=function(b,c,d,e){this.index=d,this.currentFileInfo=e;var f=this.emptySelectors();this.features=new a.Value(c),this.rules=[new a.Ruleset(f,b)],this.rules[0].allowImports=!0},a.Media.prototype={type:"Media",accept:function(a){this.features=a.visit(this.features),this.rules=a.visit(this.rules)},genCSS:function(b,c){c.add("@media ",this.currentFileInfo,this.index),this.features.genCSS(b,c),a.outputRuleset(b,c,this.rules)},toCSS:a.toCSS,eval:function(b){b.mediaBlocks||(b.mediaBlocks=[],b.mediaPath=[]);var c=new a.Media([],[],this.index,this.currentFileInfo);this.debugInfo&&(this.rules[0].debugInfo=this.debugInfo,c.debugInfo=this.debugInfo);var d=!1;b.strictMath||(d=!0,b.strictMath=!0);try{c.features=this.features.eval(b)}finally{d&&(b.strictMath=!1)}return b.mediaPath.push(c),b.mediaBlocks.push(c),b.frames.unshift(this.rules[0]),c.rules=[this.rules[0].eval(b)],b.frames.shift(),b.mediaPath.pop(),0===b.mediaPath.length?c.evalTop(b):c.evalNested(b)},variable:function(b){return a.Ruleset.prototype.variable.call(this.rules[0],b)},find:function(){return a.Ruleset.prototype.find.apply(this.rules[0],arguments)},rulesets:function(){return a.Ruleset.prototype.rulesets.apply(this.rules[0])},emptySelectors:function(){var b=new a.Element("","&",this.index,this.currentFileInfo);return[new a.Selector([b],null,null,this.index,this.currentFileInfo)]},markReferenced:function(){var a,b=this.rules[0].rules;for(this.isReferenced=!0,a=0;a1){var d=this.emptySelectors();c=new a.Ruleset(d,b.mediaBlocks),c.multiMedia=!0}return delete b.mediaBlocks,delete b.mediaPath,c},evalNested:function(b){var c,d,e=b.mediaPath.concat([this]);for(c=0;c0;c--)b.splice(c,0,new a.Anonymous("and"));return new a.Expression(b)})),new a.Ruleset([],[])},permute:function(a){if(0===a.length)return[];if(1===a.length)return a[0];for(var b=[],c=this.permute(a.slice(1)),d=0;d0){for(j=!0,g=0;gthis.params.length)return!1}c=Math.min(d,this.arity);for(var e=0;c>e;e++)if(!this.params[e].name&&!this.params[e].variadic&&a[e].value.eval(b).toCSS()!=this.params[e].value.eval(b).toCSS())return!1;return!0}}}(require("../tree")),function(a){a.Negative=function(a){this.value=a},a.Negative.prototype={type:"Negative",accept:function(a){this.value=a.visit(this.value)},genCSS:function(a,b){b.add("-"),this.value.genCSS(a,b)},toCSS:a.toCSS,eval:function(b){return b.isMathOn()?new a.Operation("*",[new a.Dimension(-1),this.value]).eval(b):new a.Negative(this.value.eval(b))}}}(require("../tree")),function(a){a.Operation=function(a,b,c){this.op=a.trim(),this.operands=b,this.isSpaced=c},a.Operation.prototype={type:"Operation",accept:function(a){this.operands=a.visit(this.operands)},eval:function(b){var c,d=this.operands[0].eval(b),e=this.operands[1].eval(b);if(b.isMathOn()){if(d instanceof a.Dimension&&e instanceof a.Color){if("*"!==this.op&&"+"!==this.op)throw{type:"Operation",message:"Can't substract or divide a color from a number"};c=e,e=d,d=c}if(!d.operate)throw{type:"Operation",message:"Operation on an invalid type"};return d.operate(b,this.op,e)}return new a.Operation(this.op,[d,e],this.isSpaced)},genCSS:function(a,b){this.operands[0].genCSS(a,b),this.isSpaced&&b.add(" "),b.add(this.op),this.isSpaced&&b.add(" "),this.operands[1].genCSS(a,b)},toCSS:a.toCSS},a.operate=function(a,b,c,d){switch(b){case"+":return c+d;case"-":return c-d;case"*":return c*d;case"/":return c/d}}}(require("../tree")),function(a){a.Paren=function(a){this.value=a},a.Paren.prototype={type:"Paren",accept:function(a){this.value=a.visit(this.value)},genCSS:function(a,b){b.add("("),this.value.genCSS(a,b),b.add(")")},toCSS:a.toCSS,eval:function(b){return new a.Paren(this.value.eval(b))}}}(require("../tree")),function(a){a.Quoted=function(a,b,c,d,e){this.escaped=c,this.value=b||"",this.quote=a.charAt(0),this.index=d,this.currentFileInfo=e},a.Quoted.prototype={type:"Quoted",genCSS:function(a,b){this.escaped||b.add(this.quote,this.currentFileInfo,this.index),b.add(this.value),this.escaped||b.add(this.quote)},toCSS:a.toCSS,eval:function(b){var c=this,d=this.value.replace(/`([^`]+)`/g,function(d,e){return new a.JavaScript(e,c.index,!0).eval(b).value}).replace(/@\{([\w-]+)\}/g,function(d,e){var f=new a.Variable("@"+e,c.index,c.currentFileInfo).eval(b,!0);return f instanceof a.Quoted?f.value:f.toCSS()});return new a.Quoted(this.quote+d+this.quote,d,this.escaped,this.index,this.currentFileInfo)},compare:function(a){if(!a.toCSS)return-1;var b=this.toCSS(),c=a.toCSS();return b===c?0:c>b?-1:1}}}(require("../tree")),function(a){a.Rule=function(b,c,d,e,f,g,h){this.name=b,this.value=c instanceof a.Value?c:new a.Value([c]),this.important=d?" "+d.trim():"",this.merge=e,this.index=f,this.currentFileInfo=g,this.inline=h||!1,this.variable="@"===b.charAt(0)},a.Rule.prototype={type:"Rule",accept:function(a){this.value=a.visit(this.value)},genCSS:function(a,b){b.add(this.name+(a.compress?":":": "),this.currentFileInfo,this.index);try{this.value.genCSS(a,b)}catch(c){throw c.index=this.index,c.filename=this.currentFileInfo.filename,c}b.add(this.important+(this.inline||a.lastRule&&a.compress?"":";"),this.currentFileInfo,this.index)},toCSS:a.toCSS,eval:function(b){var c=!1;"font"!==this.name||b.strictMath||(c=!0,b.strictMath=!0);try{return new a.Rule(this.name,this.value.eval(b),this.important,this.merge,this.index,this.currentFileInfo,this.inline)}finally{c&&(b.strictMath=!1)}},makeImportant:function(){return new a.Rule(this.name,this.value,"!important",this.merge,this.index,this.currentFileInfo,this.inline)}}}(require("../tree")),function(a){a.Ruleset=function(a,b,c){this.selectors=a,this.rules=b,this._lookups={},this.strictImports=c},a.Ruleset.prototype={type:"Ruleset",accept:function(a){if(this.paths)for(var b=0;bf.selectors[g].elements.length?Array.prototype.push.apply(e,f.find(new a.Selector(b.elements.slice(1)),c)):e.push(f);break}}),this._lookups[f]=e)},genCSS:function(b,c){var d,e,f,g,h,i=[],j=[],k=!0;b.tabLevel=b.tabLevel||0,this.root||b.tabLevel++;var l=b.compress?"":Array(b.tabLevel+1).join(" "),m=b.compress?"":Array(b.tabLevel).join(" ");for(d=0;d0&&this.mergeElementsOnToSelectors(r,i),f=0;f0&&(k[0].elements=k[0].elements.slice(0),k[0].elements.push(new a.Element(j.combinator,"",0,j.index,j.currentFileInfo))),s.push(k);else for(g=0;g0?(m=k.slice(0),q=m.pop(),o=d.createDerived(q.elements.slice(0)),p=!1):o=d.createDerived([]),l.length>1&&(n=n.concat(l.slice(1))),l.length>0&&(p=!1,o.elements.push(new a.Element(j.combinator,l[0].elements[0].value,j.index,j.currentFileInfo)),o.elements=o.elements.concat(l[0].elements.slice(1))),p||m.push(o),m=m.concat(n),s.push(m);i=s,r=[]}for(r.length>0&&this.mergeElementsOnToSelectors(r,i),e=0;e0&&b.push(i[e])}else if(c.length>0)for(e=0;e0?e[e.length-1]=e[e.length-1].createDerived(e[e.length-1].elements.concat(b)):e.push(new a.Selector(b))}}}(require("../tree")),function(a){a.Selector=function(a,b,c,d,e,f){this.elements=a,this.extendList=b||[],this.condition=c,this.currentFileInfo=e||{},this.isReferenced=f,c||(this.evaldCondition=!0)},a.Selector.prototype={type:"Selector",accept:function(a){this.elements=a.visit(this.elements),this.extendList=a.visit(this.extendList),this.condition=a.visit(this.condition)},createDerived:function(b,c,d){d=null!=d?d:this.evaldCondition;var e=new a.Selector(b,c||this.extendList,this.condition,this.index,this.currentFileInfo,this.isReferenced);return e.evaldCondition=d,e},match:function(a){var b,c,d,e,f=this.elements,g=f.length;if(b=a.elements.slice(a.elements.length&&"&"===a.elements[0].value?1:0),c=b.length,d=Math.min(g,c),0===c||c>g)return!1;for(e=0;d>e;e++)if(f[e].value!==b[e].value)return!1;return!0},eval:function(a){var b=this.condition&&this.condition.eval(a);return this.createDerived(this.elements.map(function(b){return b.eval(a)}),this.extendList.map(function(b){return b.eval(a)}),b)},genCSS:function(a,b){var c,d;if(a&&a.firstSelector||""!==this.elements[0].combinator.value||b.add(" ",this.currentFileInfo,this.index),!this._css)for(c=0;c0)&&e.splice(0,0,b);else{b.paths=b.paths.filter(function(b){var c;for(" "===b[0].elements[0].combinator.value&&(b[0].elements[0].combinator=new a.Combinator("")),c=0;c0&&b.accept(this._visitor),c.visitDeeper=!1,this._mergeRules(b.rules),this._removeDuplicateRules(b.rules),b.rules.length>0&&b.paths.length>0&&e.splice(0,0,b)}return 1===e.length?e[0]:e},_removeDuplicateRules:function(b){var c,d,e,f={};for(e=b.length-1;e>=0;e--)if(d=b[e],d instanceof a.Rule)if(f[d.name]){c=f[d.name],c instanceof a.Rule&&(c=f[d.name]=[f[d.name].toCSS(this._env)]);var g=d.toCSS(this._env);-1!==c.indexOf(g)?b.splice(e,1):c.push(g)}else f[d.name]=d},_mergeRules:function(b){for(var c,d,e,f={},g=0;g1&&(d=c[0],d.value=new a.Value(c.map(function(a){return a.value})))})}}}(require("./tree")),function(a){a.extendFinderVisitor=function(){this._visitor=new a.visitor(this),this.contexts=[],this.allExtendsStack=[[]]},a.extendFinderVisitor.prototype={run:function(a){return a=this._visitor.visit(a),a.allExtends=this.allExtendsStack[0],a},visitRule:function(a,b){b.visitDeeper=!1},visitMixinDefinition:function(a,b){b.visitDeeper=!1},visitRuleset:function(b){if(!b.root){var c,d,e,f,g=[];for(c=0;c100){var o="{unable to calculate}",p="{unable to calculate}";try{o=m[0].selfSelectors[0].toCSS(),p=m[0].selector.toCSS()}catch(q){}throw{message:"extend circular reference detected. One of the circular extends is currently:"+o+":extend("+p+")"}}return m.concat(n.doExtendChaining(m,c,d+1))}return m},inInheritanceChain:function(a,b){if(a===b)return!0;if(b.parents){if(this.inInheritanceChain(a,b.parents[0]))return!0;if(this.inInheritanceChain(a,b.parents[1]))return!0}return!1},visitRule:function(a,b){b.visitDeeper=!1},visitMixinDefinition:function(a,b){b.visitDeeper=!1},visitSelector:function(a,b){b.visitDeeper=!1},visitRuleset:function(a){if(!a.root){var b,c,d,e,f=this.allExtendsStack[this.allExtendsStack.length-1],g=[],h=this;for(d=0;d0&&k[i.matched].combinator.value!==g?i=null:i.matched++,i&&(i.finished=i.matched===k.length,i.finished&&!a.allowAfter&&(e+1j&&k>0&&(l[l.length-1].elements=l[l.length-1].elements.concat(c[j].elements.slice(k)),k=0,j++),i=f.elements.slice(k,h.index).concat([g]).concat(d.elements.slice(1)),j===h.pathIndex&&e>0?l[l.length-1].elements=l[l.length-1].elements.concat(i):(l=l.concat(c.slice(j,h.pathIndex)),l.push(new a.Selector(i))),j=h.endPathIndex,k=h.endPathElementIndex,k>=c[j].elements.length&&(k=0,j++);return j0&&(l[l.length-1].elements=l[l.length-1].elements.concat(c[j].elements.slice(k)),j++),l=l.concat(c.slice(j,c.length))},visitRulesetOut:function(){},visitMedia:function(a){var b=a.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);b=b.concat(this.doExtendChaining(b,a.allExtends)),this.allExtendsStack.push(b)},visitMediaOut:function(){this.allExtendsStack.length=this.allExtendsStack.length-1},visitDirective:function(a){var b=a.allExtends.concat(this.allExtendsStack[this.allExtendsStack.length-1]);b=b.concat(this.doExtendChaining(b,a.allExtends)),this.allExtendsStack.push(b)},visitDirectiveOut:function(){this.allExtendsStack.length=this.allExtendsStack.length-1}}}(require("./tree")),function(a){a.sourceMapOutput=function(a){this._css=[],this._rootNode=a.rootNode,this._writeSourceMap=a.writeSourceMap,this._contentsMap=a.contentsMap,this._sourceMapFilename=a.sourceMapFilename,this._outputFilename=a.outputFilename,this._sourceMapBasepath=a.sourceMapBasepath,this._sourceMapRootpath=a.sourceMapRootpath,this._outputSourceFiles=a.outputSourceFiles,this._sourceMapGeneratorConstructor=a.sourceMapGenerator||require("source-map").SourceMapGenerator,this._sourceMapRootpath&&"/"!==this._sourceMapRootpath.charAt(this._sourceMapRootpath.length-1)&&(this._sourceMapRootpath+="/"),this._lineNumber=0,this._column=0},a.sourceMapOutput.prototype.normalizeFilename=function(a){return this._sourceMapBasepath&&0===a.indexOf(this._sourceMapBasepath)&&(a=a.substring(this._sourceMapBasepath.length),("\\"===a.charAt(0)||"/"===a.charAt(0))&&(a=a.substring(1))),(this._sourceMapRootpath||"")+a.replace(/\\/g,"/")},a.sourceMapOutput.prototype.add=function(a,b,c,d){if(a){var e,f,g,h,i;if(b){var j=this._contentsMap[b.filename].substring(0,c);f=j.split("\n"),h=f[f.length-1]}if(e=a.split("\n"),g=e[e.length-1],b)if(d)for(i=0;i0){var c,d=JSON.stringify(this._sourceMapGenerator.toJSON());this._sourceMapFilename&&(c=this.normalizeFilename(this._sourceMapFilename)),this._writeSourceMap?this._writeSourceMap(d):c="data:application/json,"+encodeURIComponent(d),c&&this._css.push("/*# sourceMappingURL="+c+" */")}return this._css.join("")}}(require("./tree"));var isFileProtocol=/^(file|chrome(-extension)?|resource|qrc|app):/.test(location.protocol);less.env=less.env||("127.0.0.1"==location.hostname||"0.0.0.0"==location.hostname||"localhost"==location.hostname||location.port.length>0||isFileProtocol?"development":"production");var logLevel={info:2,errors:1,none:0};if(less.logLevel="undefined"!=typeof less.logLevel?less.logLevel:logLevel.info,less.async=less.async||!1,less.fileAsync=less.fileAsync||!1,less.poll=less.poll||(isFileProtocol?1e3:1500),less.functions)for(var func in less.functions)less.tree.functions[func]=less.functions[func];var dumpLineNumbers=/!dumpLineNumbers:(comments|mediaquery|all)/.exec(location.hash);dumpLineNumbers&&(less.dumpLineNumbers=dumpLineNumbers[1]);var typePattern=/^text\/(x-)?less$/,cache=null,fileCache={};if(less.watch=function(){return less.watchMode||(less.env="development",initRunningMode()),this.watchMode=!0},less.unwatch=function(){return clearInterval(less.watchTimer),this.watchMode=!1},/!watch/.test(location.hash)&&less.watch(),"development"!=less.env)try{cache="undefined"==typeof window.localStorage?null:window.localStorage}catch(_){}var links=document.getElementsByTagName("link");less.sheets=[];for(var i=0;i 1) t -= 1; + if(t < 1/6) return p + (q - p) * 6 * t; + if(t < 1/2) return q; + if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; + return p; + }; + var q = l < 0.5 ? l * (1 + s) : l + s - l * s, + p = 2 * l - q; + r = hueToRGB(p, q, h + 1/3); + g = hueToRGB(p, q, h); + b = hueToRGB(p, q, h - 1/3); + } + return { + red: Math.round(r * 255), + green: Math.round(g * 255), + blue: Math.round(b * 255) + }; + } + +//---------------------- Convert RGB to HSL + +// Source: http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c + + function RGBToHSL(r, g, b) { + r /= 255, + g /= 255, + b /= 255; + var max = Math.max(r, g, b), + min = Math.min(r, g, b); + var h, s, l = (max + min) / 2; + if (max == min) { + h = s = 0; // Achromatic + } else { + var d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + switch(max) { + case r: h = (g - b) / d + (g < b ? 6 : 0); break; + case g: h = (b - r) / d + 2; break; + case b: h = (r - g) / d + 4; break; + } + h /= 6; + } + return { + hue: Math.round(h * 360), + saturation: Math.round(s * 100), + luminosity: Math.round(l * 100) + }; + } + +//---------------------- Convert RGB to Hex + +// Source: http://stackoverflow.com/a/5624139 + + function RGBToHex(r, g, b) { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + } + +//---------------------- Convert hex to RGB + +// Source: http://stackoverflow.com/a/11508164 + + function hexToRGB(hex) { + var bigInt = parseInt(hex.replace('#', ''), 16), + r = (bigInt >> 16) & 255, + g = (bigInt >> 8) & 255, + b = bigInt & 255; + return { + red: r, + green: g, + blue: b + }; + } + +//---------------------- Convert hex to HSL + + function hexToHSL(hex) { + var RGB = hexToRGB(hex); + return RGBToHSL(RGB.red, RGB.green, RGB.blue); + } + +//---------------------- Convert HSL to hex + + function HSLToHex(h, s, l) { + var RGB = HSLToRGB(h, s, l); + return RGBToHex(RGB.red, RGB.green, RGB.blue); + } + +//-------------------------------------------- Setup each color picker + + $.each($('.color-picker'), function() { + +//---------------------- Find componenets + + var picker = $(this), + formatInput = picker.find('.format'), + colorInput = picker.find('.color'), + luminosityInput = picker.find('input[type=range]'), + spectrum = picker.find('.spectrum'), + pin = picker.find('.pin'); + +//---------------------- Get current color in HSL + + function getHSL() { + var position = picker.find('.pin').position(), + width = spectrum.width(), + height = spectrum.height(); + return { + hue: Math.round(position.left / width * 360), + saturation: Math.round(position.top / height * 100), + luminosity: luminosityInput.val() + }; + } + +//---------------------- Output color in desired format + + function updateColorInput() { + var HSL = getHSL(); + switch (formatInput.val()) { + case 'HSL': + colorInput.val('hsl(' + HSL.hue + ', ' + HSL.saturation + '%, ' + HSL.luminosity + '%)'); + break; + case 'RGB': + var RGB = HSLToRGB(HSL.hue, HSL.saturation, HSL.luminosity); + colorInput.val('rgb(' + RGB.red + ', ' + RGB.green + ', ' + RGB.blue + ')'); + break; + case 'Hex': + colorInput.val(HSLToHex(HSL.hue, HSL.saturation, HSL.luminosity)); + break; + } + // Trigger color picker change event for custom callbacks + picker.trigger('change'); + } + +//---------------------- Set color format + + formatInput.on('change', function() { + updateColorInput(); + }); + +//---------------------- Set color + + colorInput.on('change', function() { + // Get the color values in HSL format + var HSL; + switch (formatInput.val()) { + case 'HSL': + var values = $(this).val().match(/\d+/g); + HSL = { + hue: values[0], + saturation: values[1], + luminosity: values[2] + }; + break; + case 'RGB': + var values = $(this).val().match(/\d+/g); + HSL = RGBToHSL(values[0], values[1], values[2]); + break; + case 'Hex': + HSL = hexToHSL($(this).val()); + break; + } + // Set the luminosity + luminosityInput.val(HSL.luminosity); + setLuminosity(HSL.luminosity); + // Place the pin + pin.css({ + left: HSL.hue / 360 * 100 + '%', + top: HSL.saturation + '%' + }); + // Trigger color picker change event for custom callbacks + picker.trigger('change'); + }); + +//---------------------- Set luminosity + +//---------- Set the luminosity spectrum overlay + + function setLuminosity(luminosity) { + var color, + alpha; + if (luminosity <= 50) { + color = '0, 0, 0'; + alpha = 1 - luminosity / 100 * 2; + } else { + color = '255, 255, 255'; + alpha = luminosity / 100 * 2 - 1; + } + // Apply luminosity to the spectrum + spectrum.children().css('background-color', 'rgba(' + color + ', ' + alpha + ')'); + } + +//---------- Luminosity input interaction + + luminosityInput.on('change', function() { + setLuminosity($(this).val()); + updateColorInput(); + }); + +//---------------------- Set hue, saturation via pin + +//---------- Move the pin + + var movePin = function(event) { + var offset = spectrum.offset(), + width = spectrum.width(), + height = spectrum.height(), + x = event.changedTouches[0].clientX - offset.left, + y = event.changedTouches[0].clientY - offset.top; + // Account for pin being dragged outside the spectrum area + // Sanatize x + if (x < 0) { + x = 0; + } else if (x >= width) { + x = width; + } + // Sanatize y + if (y < 0) { + y = 0; + } else if (y >= height) { + y = height; + } + // Place the pin + pin.css({ + left: x / width * 100 + '%', + top: y / height * 100 + '%' + }); + // Output new color value + updateColorInput(); + }; + +//---------- Pin interaction + + spectrum.on('touchstart', function(event) { + event.preventDefault(); + movePin(event); + spectrum.addClass('active'); + $(document).on('touchmove', movePin); + }); + + $(document).on('touchend', function() { + spectrum.removeClass('active'); + $(document).off('touchmove', movePin); + }); + + spectrum.on('touchmove touchstart', movePin); + +//---------------------- Output color preview + + picker.on('change', function() { + colorInput.css('background-color', colorInput.val()).toggleClass('dark', luminosityInput.val() <= 50); + }); + +//---------------------- Initialize this color picker + + colorInput.trigger('change'); + + }); +}); diff --git a/Web/js/libs/color-picker.js b/Web/js/libs/color-picker.js new file mode 100644 index 0000000..7c211f9 --- /dev/null +++ b/Web/js/libs/color-picker.js @@ -0,0 +1,289 @@ +/* + +Purty Picker Copyright 2013 Jayden Seric (MIT license). + +A super lightweight visual HSL, RGB and hex color picker with a responsive, touch-friendly and customizable UI. + +Requires jQuery or Zepto with core and event modules. + +https://github.com/jaydenseric/Purty-Picker + +*/ + +// DOM ready +$(function() { + 'use strict'; + +//-------------------------------------------- Color conversions + +//---------------------- Convert HSL to RGB + +// Source: http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c + + function HSLToRGB(h, s, l) { + h /= 360; + s /= 100; + l /= 100; + var r, g, b; + if(s == 0) { + r = g = b = l; // Achromatic + } else { + var hueToRGB = function(p, q, t) { + if(t < 0) t += 1; + if(t > 1) t -= 1; + if(t < 1/6) return p + (q - p) * 6 * t; + if(t < 1/2) return q; + if(t < 2/3) return p + (q - p) * (2/3 - t) * 6; + return p; + }; + var q = l < 0.5 ? l * (1 + s) : l + s - l * s, + p = 2 * l - q; + r = hueToRGB(p, q, h + 1/3); + g = hueToRGB(p, q, h); + b = hueToRGB(p, q, h - 1/3); + } + return { + red: Math.round(r * 255), + green: Math.round(g * 255), + blue: Math.round(b * 255) + }; + } + +//---------------------- Convert RGB to HSL + +// Source: http://axonflux.com/handy-rgb-to-hsl-and-rgb-to-hsv-color-model-c + + function RGBToHSL(r, g, b) { + r /= 255, + g /= 255, + b /= 255; + var max = Math.max(r, g, b), + min = Math.min(r, g, b); + var h, s, l = (max + min) / 2; + if (max == min) { + h = s = 0; // Achromatic + } else { + var d = max - min; + s = l > 0.5 ? d / (2 - max - min) : d / (max + min); + switch(max) { + case r: h = (g - b) / d + (g < b ? 6 : 0); break; + case g: h = (b - r) / d + 2; break; + case b: h = (r - g) / d + 4; break; + } + h /= 6; + } + return { + hue: Math.round(h * 360), + saturation: Math.round(s * 100), + luminosity: Math.round(l * 100) + }; + } + +//---------------------- Convert RGB to Hex + +// Source: http://stackoverflow.com/a/5624139 + + function RGBToHex(r, g, b) { + return '#' + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1); + } + +//---------------------- Convert hex to RGB + +// Source: http://stackoverflow.com/a/11508164 + + function hexToRGB(hex) { + var bigInt = parseInt(hex.replace('#', ''), 16), + r = (bigInt >> 16) & 255, + g = (bigInt >> 8) & 255, + b = bigInt & 255; + return { + red: r, + green: g, + blue: b + }; + } + +//---------------------- Convert hex to HSL + + function hexToHSL(hex) { + var RGB = hexToRGB(hex); + return RGBToHSL(RGB.red, RGB.green, RGB.blue); + } + +//---------------------- Convert HSL to hex + + function HSLToHex(h, s, l) { + var RGB = HSLToRGB(h, s, l); + return RGBToHex(RGB.red, RGB.green, RGB.blue); + } + +//-------------------------------------------- Setup each color picker + + $.each($('.color-picker'), function() { + +//---------------------- Find componenets + + var picker = $(this), + formatInput = picker.find('.format'), + colorInput = picker.find('.color'), + luminosityInput = picker.find('input[type=range]'), + spectrum = picker.find('.spectrum'), + pin = picker.find('.pin'); + +//---------------------- Get current color in HSL + + function getHSL() { + var position = picker.find('.pin').position(), + width = spectrum.width(), + height = spectrum.height(); + return { + hue: Math.round(position.left / width * 360), + saturation: Math.round(position.top / height * 100), + luminosity: luminosityInput.val() + }; + } + +//---------------------- Output color in desired format + + function updateColorInput() { + var HSL = getHSL(); + switch (formatInput.val()) { + case 'HSL': + colorInput.val('hsl(' + HSL.hue + ', ' + HSL.saturation + '%, ' + HSL.luminosity + '%)'); + break; + case 'RGB': + var RGB = HSLToRGB(HSL.hue, HSL.saturation, HSL.luminosity); + colorInput.val('rgb(' + RGB.red + ', ' + RGB.green + ', ' + RGB.blue + ')'); + break; + case 'Hex': + colorInput.val(HSLToHex(HSL.hue, HSL.saturation, HSL.luminosity)); + break; + } + // Trigger color picker change event for custom callbacks + picker.trigger('change'); + } + +//---------------------- Set color format + + formatInput.on('change', function() { + updateColorInput(); + }); + +//---------------------- Set color + + colorInput.on('change', function() { + // Get the color values in HSL format + var HSL; + switch (formatInput.val()) { + case 'HSL': + var values = $(this).val().match(/\d+/g); + HSL = { + hue: values[0], + saturation: values[1], + luminosity: values[2] + }; + break; + case 'RGB': + var values = $(this).val().match(/\d+/g); + HSL = RGBToHSL(values[0], values[1], values[2]); + break; + case 'Hex': + HSL = hexToHSL($(this).val()); + break; + } + // Set the luminosity + luminosityInput.val(HSL.luminosity); + setLuminosity(HSL.luminosity); + // Place the pin + pin.css({ + left: HSL.hue / 360 * 100 + '%', + top: HSL.saturation + '%' + }); + // Trigger color picker change event for custom callbacks + picker.trigger('change'); + }); + +//---------------------- Set luminosity + +//---------- Set the luminosity spectrum overlay + + function setLuminosity(luminosity) { + var color, + alpha; + if (luminosity <= 50) { + color = '0, 0, 0'; + alpha = 1 - luminosity / 100 * 2; + } else { + color = '255, 255, 255'; + alpha = luminosity / 100 * 2 - 1; + } + // Apply luminosity to the spectrum + spectrum.children().css('background-color', 'rgba(' + color + ', ' + alpha + ')'); + } + +//---------- Luminosity input interaction + + luminosityInput.on('change', function() { + setLuminosity($(this).val()); + updateColorInput(); + }); + +//---------------------- Set hue, saturation via pin + +//---------- Move the pin + + var movePin = function(event) { + var offset = spectrum.offset(), + width = spectrum.width(), + height = spectrum.height(), + x = event.clientX - offset.left, + y = event.clientY - offset.top; + // Account for pin being dragged outside the spectrum area + // Sanatize x + if (x < 0) { + x = 0; + } else if (x >= width) { + x = width; + } + // Sanatize y + if (y < 0) { + y = 0; + } else if (y >= height) { + y = height; + } + // Place the pin + pin.css({ + left: x / width * 100 + '%', + top: y / height * 100 + '%' + }); + // Output new color value + updateColorInput(); + }; + +//---------- Pin interaction + + spectrum.on('mousedown', function(event) { + event.preventDefault(); + movePin(event); + spectrum.addClass('active'); + $(document).on('mousemove', movePin); + }); + + $(document).on('mouseup', function() { + spectrum.removeClass('active'); + $(document).off('mousemove', movePin); + }); + + spectrum.on('touchmove touchstart', movePin); + +//---------------------- Output color preview + + picker.on('change', function() { + colorInput.css('background-color', colorInput.val()).toggleClass('dark', luminosityInput.val() <= 50); + }); + +//---------------------- Initialize this color picker + + colorInput.trigger('change'); + }); +}); diff --git a/Web/js/libs/mobilebrowsers.js b/Web/js/libs/mobilebrowsers.js new file mode 100644 index 0000000..3d8d819 --- /dev/null +++ b/Web/js/libs/mobilebrowsers.js @@ -0,0 +1 @@ +(function(a,b){if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(a)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|yas\-|your|zeto|zte\-/i.test(a.substr(0,4)))window.mobile=true})(navigator.userAgent||navigator.vendor||window.opera,'http://detectmobilebrowser.com/mobile'); diff --git a/Web/js/libs/stack.js b/Web/js/libs/stack.js new file mode 100644 index 0000000..cbec614 --- /dev/null +++ b/Web/js/libs/stack.js @@ -0,0 +1,22 @@ +// Zepto.js +// (c) 2010-2014 Thomas Fuchs +// Zepto.js may be freely distributed under the MIT license. + +;(function($){ + $.fn.end = function(){ + return this.prevObject || $() + } + + $.fn.andSelf = function(){ + return this.add(this.prevObject || $()) + } + + 'filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings'.split(',').forEach(function(property){ + var fn = $.fn[property] + $.fn[property] = function(){ + var ret = fn.apply(this, arguments) + ret.prevObject = this + return ret + } + }) +})(Zepto) diff --git a/Web/js/libs/touch.js b/Web/js/libs/touch.js new file mode 100644 index 0000000..cada189 --- /dev/null +++ b/Web/js/libs/touch.js @@ -0,0 +1,166 @@ +// Zepto.js +// (c) 2010-2014 Thomas Fuchs +// Zepto.js may be freely distributed under the MIT license. + +;(function($){ + var touch = {}, + touchTimeout, tapTimeout, swipeTimeout, longTapTimeout, + longTapDelay = 750, + gesture + + function swipeDirection(x1, x2, y1, y2) { + return Math.abs(x1 - x2) >= + Math.abs(y1 - y2) ? (x1 - x2 > 0 ? 'Left' : 'Right') : (y1 - y2 > 0 ? 'Up' : 'Down') + } + + function longTap() { + longTapTimeout = null + if (touch.last) { + touch.el.trigger('longTap') + window.touchEl = touch.el; + touch = {} + } + } + + function cancelLongTap() { + if (longTapTimeout) clearTimeout(longTapTimeout) + longTapTimeout = null + } + + function cancelAll() { + if (touchTimeout) clearTimeout(touchTimeout) + if (tapTimeout) clearTimeout(tapTimeout) + if (swipeTimeout) clearTimeout(swipeTimeout) + if (longTapTimeout) clearTimeout(longTapTimeout) + touchTimeout = tapTimeout = swipeTimeout = longTapTimeout = null + touch = {} + } + + function isPrimaryTouch(event){ + return (event.pointerType == 'touch' || + event.pointerType == event.MSPOINTER_TYPE_TOUCH) + && event.isPrimary + } + + function isPointerEventType(e, type){ + return (e.type == 'pointer'+type || + e.type.toLowerCase() == 'mspointer'+type) + } + + $(document).ready(function(){ + var now, delta, deltaX = 0, deltaY = 0, firstTouch, _isPointerType + + if ('MSGesture' in window) { + gesture = new MSGesture() + gesture.target = document.body + } + + $(document) + .bind('MSGestureEnd', function(e){ + var swipeDirectionFromVelocity = + e.velocityX > 1 ? 'Right' : e.velocityX < -1 ? 'Left' : e.velocityY > 1 ? 'Down' : e.velocityY < -1 ? 'Up' : null; + if (swipeDirectionFromVelocity) { + touch.el.trigger('swipe') + touch.el.trigger('swipe'+ swipeDirectionFromVelocity) + } + }) + .on('touchstart MSPointerDown pointerdown', function(e){ + if((_isPointerType = isPointerEventType(e, 'down')) && + !isPrimaryTouch(e)) return + firstTouch = _isPointerType ? e : e.touches[0] + if (e.touches && e.touches.length === 1 && touch.x2) { + // Clear out touch movement data if we have it sticking around + // This can occur if touchcancel doesn't fire due to preventDefault, etc. + touch.x2 = undefined + touch.y2 = undefined + } + now = Date.now() + delta = now - (touch.last || now) + touch.el = $('tagName' in firstTouch.target ? + firstTouch.target : firstTouch.target.parentNode) + touchTimeout && clearTimeout(touchTimeout) + touch.x1 = firstTouch.pageX + touch.y1 = firstTouch.pageY + if (delta > 0 && delta <= 250) touch.isDoubleTap = true + touch.last = now + longTapTimeout = setTimeout(longTap, longTapDelay) + // adds the current touch contact for IE gesture recognition + if (gesture && _isPointerType) gesture.addPointer(e.pointerId); + }) + .on('touchmove MSPointerMove pointermove', function(e){ + if((_isPointerType = isPointerEventType(e, 'move')) && + !isPrimaryTouch(e)) return + firstTouch = _isPointerType ? e : e.touches[0] + if( $.moveCancel ) cancelLongTap() + touch.x2 = firstTouch.pageX + touch.y2 = firstTouch.pageY + + deltaX += Math.abs(touch.x1 - touch.x2) + deltaY += Math.abs(touch.y1 - touch.y2) + }) + .on('touchend MSPointerUp pointerup', function(e){ + if((_isPointerType = isPointerEventType(e, 'up')) && + !isPrimaryTouch(e)) return + cancelLongTap() + + // swipe + if ((touch.x2 && Math.abs(touch.x1 - touch.x2) > 30) || + (touch.y2 && Math.abs(touch.y1 - touch.y2) > 30)) + + swipeTimeout = setTimeout(function() { + touch.el.trigger('swipe') + touch.el.trigger('swipe' + (swipeDirection(touch.x1, touch.x2, touch.y1, touch.y2))) + touch = {} + }, 0) + + // normal tap + else if ('last' in touch) + // don't fire tap when delta position changed by more than 30 pixels, + // for instance when moving to a point and back to origin + if (deltaX < 30 && deltaY < 30) { + // delay by one tick so we can cancel the 'tap' event if 'scroll' fires + // ('tap' fires before 'scroll') + tapTimeout = setTimeout(function() { + + // trigger universal 'tap' with the option to cancelTouch() + // (cancelTouch cancels processing of single vs double taps for faster 'tap' response) + var event = $.Event('tap') + event.cancelTouch = cancelAll + touch.el.trigger(event) + + // trigger double tap immediately + if (touch.isDoubleTap) { + if (touch.el) touch.el.trigger('doubleTap') + touch = {} + } + + // trigger single tap after 250ms of inactivity + else { + touchTimeout = setTimeout(function(){ + touchTimeout = null + if (touch.el) touch.el.trigger('singleTap') + touch = {} + }, 250) + } + }, 0) + } else { + touch = {} + } + deltaX = deltaY = 0 + + }) + // when the browser window loses focus, + // for example when a modal dialog is shown, + // cancel all ongoing events + .on('touchcancel MSPointerCancel pointercancel', cancelAll) + + // scrolling the window indicates intention of the user + // to scroll, not tap or swipe, so cancel all ongoing events + $(window).on('scroll', cancelAll) + }) + + ;['swipe', 'swipeLeft', 'swipeRight', 'swipeUp', 'swipeDown', + 'doubleTap', 'tap', 'singleTap', 'longTap'].forEach(function(eventName){ + $.fn[eventName] = function(callback){ return this.on(eventName, callback) } + }) +})(Zepto) diff --git a/Web/js/libs/yepnope.min.js b/Web/js/libs/yepnope.min.js new file mode 100644 index 0000000..73655a5 --- /dev/null +++ b/Web/js/libs/yepnope.min.js @@ -0,0 +1,2 @@ +/*yepnope1.5.x|WTFPL*/ +(function(a,b,c){function d(a){return"[object Function]"==o.call(a)}function e(a){return"string"==typeof a}function f(){}function g(a){return!a||"loaded"==a||"complete"==a||"uninitialized"==a}function h(){var a=p.shift();q=1,a?a.t?m(function(){("c"==a.t?B.injectCss:B.injectJs)(a.s,0,a.a,a.x,a.e,1)},0):(a(),h()):q=0}function i(a,c,d,e,f,i,j){function k(b){if(!o&&g(l.readyState)&&(u.r=o=1,!q&&h(),l.onload=l.onreadystatechange=null,b)){"img"!=a&&m(function(){t.removeChild(l)},50);for(var d in y[c])y[c].hasOwnProperty(d)&&y[c][d].onload()}}var j=j||B.errorTimeout,l=b.createElement(a),o=0,r=0,u={t:d,s:c,e:f,a:i,x:j};1===y[c]&&(r=1,y[c]=[]),"object"==a?l.data=c:(l.src=c,l.type=a),l.width=l.height="0",l.onerror=l.onload=l.onreadystatechange=function(){k.call(this,r)},p.splice(e,0,u),"img"!=a&&(r||2===y[c]?(t.insertBefore(l,s?null:n),m(k,j)):y[c].push(l))}function j(a,b,c,d,f){return q=0,b=b||"j",e(a)?i("c"==b?v:u,a,b,this.i++,c,d,f):(p.splice(this.i++,0,a),1==p.length&&h()),this}function k(){var a=B;return a.loader={load:j,i:0},a}var l=b.documentElement,m=a.setTimeout,n=b.getElementsByTagName("script")[0],o={}.toString,p=[],q=0,r="MozAppearance"in l.style,s=r&&!!b.createRange().compareNode,t=s?l:n.parentNode,l=a.opera&&"[object Opera]"==o.call(a.opera),l=!!b.attachEvent&&!l,u=r?"object":l?"script":"img",v=l?"script":u,w=Array.isArray||function(a){return"[object Array]"==o.call(a)},x=[],y={},z={timeout:function(a,b){return b.length&&(a.timeout=b[0]),a}},A,B;B=function(a){function b(a){var a=a.split("!"),b=x.length,c=a.pop(),d=a.length,c={url:c,origUrl:c,prefixes:a},e,f,g;for(f=0;f0?c.fn.concat.apply([],a):a}function Q(a){return a.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function R(a){return a in j?j[a]:j[a]=new RegExp("(^|\\s)"+a+"(\\s|$)")}function S(a,b){return typeof b=="number"&&!k[Q(a)]?b+"px":b}function T(a){var b,c;return i[a]||(b=h.createElement(a),h.body.appendChild(b),c=getComputedStyle(b,"").getPropertyValue("display"),b.parentNode.removeChild(b),c=="none"&&(c="block"),i[a]=c),i[a]}function U(a){return"children"in a?f.call(a.children):c.map(a.childNodes,function(a){if(a.nodeType==1)return a})}function V(c,d,e){for(b in d)e&&(L(d[b])||M(d[b]))?(L(d[b])&&!L(c[b])&&(c[b]={}),M(d[b])&&!M(c[b])&&(c[b]=[]),V(c[b],d[b],e)):d[b]!==a&&(c[b]=d[b])}function W(a,b){return b==null?c(a):c(a).filter(b)}function X(a,b,c,d){return H(b)?b.call(a,c,d):b}function Y(a,b,c){c==null?a.removeAttribute(b):a.setAttribute(b,c)}function Z(b,c){var d=b.className,e=d&&d.baseVal!==a;if(c===a)return e?d.baseVal:d;e?d.baseVal=c:b.className=c}function $(a){var b;try{return a?a=="true"||(a=="false"?!1:a=="null"?null:!/^0/.test(a)&&!isNaN(b=Number(a))?b:/^[\[\{]/.test(a)?c.parseJSON(a):a):a}catch(d){return a}}function _(a,b){b(a);for(var c in a.childNodes)_(a.childNodes[c],b)}var a,b,c,d,e=[],f=e.slice,g=e.filter,h=window.document,i={},j={},k={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},l=/^\s*<(\w+|!)[^>]*>/,m=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,n=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/ig,o=/^(?:body|html)$/i,p=/([A-Z])/g,q=["val","css","html","text","data","width","height","offset"],r=["after","prepend","before","append"],s=h.createElement("table"),t=h.createElement("tr"),u={tr:h.createElement("tbody"),tbody:s,thead:s,tfoot:s,td:t,th:t,"*":h.createElement("div")},v=/complete|loaded|interactive/,w=/^\.([\w-]+)$/,x=/^#([\w-]*)$/,y=/^[\w-]*$/,z={},A=z.toString,B={},C,D,E=h.createElement("div"),F={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"};return B.matches=function(a,b){if(!b||!a||a.nodeType!==1)return!1;var c=a.webkitMatchesSelector||a.mozMatchesSelector||a.oMatchesSelector||a.matchesSelector;if(c)return c.call(a,b);var d,e=a.parentNode,f=!e;return f&&(e=E).appendChild(a),d=~B.qsa(e,b).indexOf(a),f&&E.removeChild(a),d},C=function(a){return a.replace(/-+(.)?/g,function(a,b){return b?b.toUpperCase():""})},D=function(a){return g.call(a,function(b,c){return a.indexOf(b)==c})},B.fragment=function(b,d,e){var g,i,j;return m.test(b)&&(g=c(h.createElement(RegExp.$1))),g||(b.replace&&(b=b.replace(n,"<$1>")),d===a&&(d=l.test(b)&&RegExp.$1),d in u||(d="*"),j=u[d],j.innerHTML=""+b,g=c.each(f.call(j.childNodes),function(){j.removeChild(this)})),L(e)&&(i=c(g),c.each(e,function(a,b){q.indexOf(a)>-1?i[a](b):i.attr(a,b)})),g},B.Z=function(a,b){return a=a||[],a.__proto__=c.fn,a.selector=b||"",a},B.isZ=function(a){return a instanceof B.Z},B.init=function(b,d){var e;if(!b)return B.Z();if(typeof b=="string"){b=b.trim();if(b[0]=="<"&&l.test(b))e=B.fragment(b,RegExp.$1,d),b=null;else{if(d!==a)return c(d).find(b);e=B.qsa(h,b)}}else{if(H(b))return c(h).ready(b);if(B.isZ(b))return b;if(M(b))e=O(b);else if(K(b))e=[b],b=null;else if(l.test(b))e=B.fragment(b.trim(),RegExp.$1,d),b=null;else{if(d!==a)return c(d).find(b);e=B.qsa(h,b)}}return B.Z(e,b)},c=function(a,b){return B.init(a,b)},c.extend=function(a){var b,c=f.call(arguments,1);return typeof a=="boolean"&&(b=a,a=c.shift()),c.forEach(function(c){V(a,c,b)}),a},B.qsa=function(a,b){var c,d=b[0]=="#",e=!d&&b[0]==".",g=d||e?b.slice(1):b,h=y.test(g);return J(a)&&h&&d?(c=a.getElementById(g))?[c]:[]:a.nodeType!==1&&a.nodeType!==9?[]:f.call(h&&!d?e?a.getElementsByClassName(g):a.getElementsByTagName(b):a.querySelectorAll(b))},c.contains=function(a,b){return a!==b&&a.contains(b)},c.type=G,c.isFunction=H,c.isWindow=I,c.isArray=M,c.isPlainObject=L,c.isEmptyObject=function(a){var b;for(b in a)return!1;return!0},c.inArray=function(a,b,c){return e.indexOf.call(b,a,c)},c.camelCase=C,c.trim=function(a){return a==null?"":String.prototype.trim.call(a)},c.uuid=0,c.support={},c.expr={},c.map=function(a,b){var c,d=[],e,f;if(N(a))for(e=0;e=0?b:b+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){this.parentNode!=null&&this.parentNode.removeChild(this)})},each:function(a){return e.every.call(this,function(b,c){return a.call(b,c,b)!==!1}),this},filter:function(a){return H(a)?this.not(this.not(a)):c(g.call(this,function(b){return B.matches(b,a)}))},add:function(a,b){return c(D(this.concat(c(a,b))))},is:function(a){return this.length>0&&B.matches(this[0],a)},not:function(b){var d=[];if(H(b)&&b.call!==a)this.each(function(a){b.call(this,a)||d.push(this)});else{var e=typeof b=="string"?this.filter(b):N(b)&&H(b.item)?f.call(b):c(b);this.forEach(function(a){e.indexOf(a)<0&&d.push(a)})}return c(d)},has:function(a){return this.filter(function(){return K(a)?c.contains(this,a):c(this).find(a).size()})},eq:function(a){return a===-1?this.slice(a):this.slice(a,+a+1)},first:function(){var a=this[0];return a&&!K(a)?a:c(a)},last:function(){var a=this[this.length-1];return a&&!K(a)?a:c(a)},find:function(a){var b,d=this;return typeof a=="object"?b=c(a).filter(function(){var a=this;return e.some.call(d,function(b){return c.contains(b,a)})}):this.length==1?b=c(B.qsa(this[0],a)):b=this.map(function(){return B.qsa(this,a)}),b},closest:function(a,b){var d=this[0],e=!1;typeof a=="object"&&(e=c(a));while(d&&!(e?e.indexOf(d)>=0:B.matches(d,a)))d=d!==b&&!J(d)&&d.parentNode;return c(d)},parents:function(a){var b=[],d=this;while(d.length>0)d=c.map(d,function(a){if((a=a.parentNode)&&!J(a)&&b.indexOf(a)<0)return b.push(a),a});return W(b,a)},parent:function(a){return W(D(this.pluck("parentNode")),a)},children:function(a){return W(this.map(function(){return U(this)}),a)},contents:function(){return this.map(function(){return f.call(this.childNodes)})},siblings:function(a){return W(this.map(function(a,b){return g.call(U(b.parentNode),function(a){return a!==b})}),a)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(a){return c.map(this,function(b){return b[a]})},show:function(){return this.each(function(){this.style.display=="none"&&(this.style.display=""),getComputedStyle(this,"").getPropertyValue("display")=="none"&&(this.style.display=T(this.nodeName))})},replaceWith:function(a){return this.before(a).remove()},wrap:function(a){var b=H(a);if(this[0]&&!b)var d=c(a).get(0),e=d.parentNode||this.length>1;return this.each(function(f){c(this).wrapAll(b?a.call(this,f):e?d.cloneNode(!0):d)})},wrapAll:function(a){if(this[0]){c(this[0]).before(a=c(a));var b;while((b=a.children()).length)a=b.first();c(a).append(this)}return this},wrapInner:function(a){var b=H(a);return this.each(function(d){var e=c(this),f=e.contents(),g=b?a.call(this,d):a;f.length?f.wrapAll(g):e.append(g)})},unwrap:function(){return this.parent().each(function(){c(this).replaceWith(c(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(b){return this.each(function(){var d=c(this);(b===a?d.css("display")=="none":b)?d.show():d.hide()})},prev:function(a){return c(this.pluck("previousElementSibling")).filter(a||"*")},next:function(a){return c(this.pluck("nextElementSibling")).filter(a||"*")},html:function(a){return arguments.length===0?this.length>0?this[0].innerHTML:null:this.each(function(b){var d=this.innerHTML;c(this).empty().append(X(this,a,b,d))})},text:function(b){return arguments.length===0?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=b===a?"":""+b})},attr:function(c,d){var e;return typeof c=="string"&&d===a?this.length==0||this[0].nodeType!==1?a:c=="value"&&this[0].nodeName=="INPUT"?this.val():!(e=this[0].getAttribute(c))&&c in this[0]?this[0][c]:e:this.each(function(a){if(this.nodeType!==1)return;if(K(c))for(b in c)Y(this,b,c[b]);else Y(this,c,X(this,d,a,this.getAttribute(c)))})},removeAttr:function(a){return this.each(function(){this.nodeType===1&&Y(this,a)})},prop:function(b,c){return b=F[b]||b,c===a?this[0]&&this[0][b]:this.each(function(a){this[b]=X(this,c,a,this[b])})},data:function(b,c){var d=this.attr("data-"+b.replace(p,"-$1").toLowerCase(),c);return d!==null?$(d):a},val:function(a){return arguments.length===0?this[0]&&(this[0].multiple?c(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value):this.each(function(b){this.value=X(this,a,b,this.value)})},offset:function(a){if(a)return this.each(function(b){var d=c(this),e=X(this,a,b,d.offset()),f=d.offsetParent().offset(),g={top:e.top-f.top,left:e.left-f.left};d.css("position")=="static"&&(g.position="relative"),d.css(g)});if(this.length==0)return null;var b=this[0].getBoundingClientRect();return{left:b.left+window.pageXOffset,top:b.top+window.pageYOffset,width:Math.round(b.width),height:Math.round(b.height)}},css:function(a,d){if(arguments.length<2){var e=this[0],f=getComputedStyle(e,"");if(!e)return;if(typeof a=="string")return e.style[C(a)]||f.getPropertyValue(a);if(M(a)){var g={};return c.each(M(a)?a:[a],function(a,b){g[b]=e.style[C(b)]||f.getPropertyValue(b)}),g}}var h="";if(G(a)=="string")!d&&d!==0?this.each(function(){this.style.removeProperty(Q(a))}):h=Q(a)+":"+S(a,d);else for(b in a)!a[b]&&a[b]!==0?this.each(function(){this.style.removeProperty(Q(b))}):h+=Q(b)+":"+S(b,a[b])+";";return this.each(function(){this.style.cssText+=";"+h})},index:function(a){return a?this.indexOf(c(a)[0]):this.parent().children().indexOf(this[0])},hasClass:function(a){return a?e.some.call(this,function(a){return this.test(Z(a))},R(a)):!1},addClass:function(a){return a?this.each(function(b){d=[];var e=Z(this),f=X(this,a,b,e);f.split(/\s+/g).forEach(function(a){c(this).hasClass(a)||d.push(a)},this),d.length&&Z(this,e+(e?" ":"")+d.join(" "))}):this},removeClass:function(b){return this.each(function(c){if(b===a)return Z(this,"");d=Z(this),X(this,b,c,d).split(/\s+/g).forEach(function(a){d=d.replace(R(a)," ")}),Z(this,d.trim())})},toggleClass:function(b,d){return b?this.each(function(e){var f=c(this),g=X(this,b,e,Z(this));g.split(/\s+/g).forEach(function(b){(d===a?!f.hasClass(b):d)?f.addClass(b):f.removeClass(b)})}):this},scrollTop:function(b){if(!this.length)return;var c="scrollTop"in this[0];return b===a?c?this[0].scrollTop:this[0].pageYOffset:this.each(c?function(){this.scrollTop=b}:function(){this.scrollTo(this.scrollX,b)})},scrollLeft:function(b){if(!this.length)return;var c="scrollLeft"in this[0];return b===a?c?this[0].scrollLeft:this[0].pageXOffset:this.each(c?function(){this.scrollLeft=b}:function(){this.scrollTo(b,this.scrollY)})},position:function(){if(!this.length)return;var a=this[0],b=this.offsetParent(),d=this.offset(),e=o.test(b[0].nodeName)?{top:0,left:0}:b.offset();return d.top-=parseFloat(c(a).css("margin-top"))||0,d.left-=parseFloat(c(a).css("margin-left"))||0,e.top+=parseFloat(c(b[0]).css("border-top-width"))||0,e.left+=parseFloat(c(b[0]).css("border-left-width"))||0,{top:d.top-e.top,left:d.left-e.left}},offsetParent:function(){return this.map(function(){var a=this.offsetParent||h.body;while(a&&!o.test(a.nodeName)&&c(a).css("position")=="static")a=a.offsetParent;return a})}},c.fn.detach=c.fn.remove,["width","height"].forEach(function(b){var d=b.replace(/./,function(a){return a[0].toUpperCase()});c.fn[b]=function(e){var f,g=this[0];return e===a?I(g)?g["inner"+d]:J(g)?g.documentElement["scroll"+d]:(f=this.offset())&&f[b]:this.each(function(a){g=c(this),g.css(b,X(this,e,a,g[b]()))})}}),r.forEach(function(a,b){var d=b%2;c.fn[a]=function(){var a,e=c.map(arguments,function(b){return a=G(b),a=="object"||a=="array"||b==null?b:B.fragment(b)}),f,g=this.length>1;return e.length<1?this:this.each(function(a,h){f=d?h:h.parentNode,h=b==0?h.nextSibling:b==1?h.firstChild:b==2?h:null,e.forEach(function(a){if(g)a=a.cloneNode(!0);else if(!f)return c(a).remove();_(f.insertBefore(a,h),function(a){a.nodeName!=null&&a.nodeName.toUpperCase()==="SCRIPT"&&(!a.type||a.type==="text/javascript")&&!a.src&&window.eval.call(window,a.innerHTML)})})})},c.fn[d?a+"To":"insert"+(b?"Before":"After")]=function(b){return c(b)[a](this),this}}),B.Z.prototype=c.fn,B.uniq=D,B.deserializeValue=$,c.zepto=B,c}();window.Zepto=Zepto,window.$===undefined&&(window.$=Zepto),function(a){function m(a){return a._zid||(a._zid=c++)}function n(a,b,c,d){b=o(b);if(b.ns)var e=p(b.ns);return(h[m(a)]||[]).filter(function(a){return a&&(!b.e||a.e==b.e)&&(!b.ns||e.test(a.ns))&&(!c||m(a.fn)===m(c))&&(!d||a.sel==d)})}function o(a){var b=(""+a).split(".");return{e:b[0],ns:b.slice(1).sort().join(" ")}}function p(a){return new RegExp("(?:^| )"+a.replace(" "," .* ?")+"(?: |$)")}function q(a,b){return a.del&&!j&&a.e in k||!!b}function r(a){return l[a]||j&&k[a]||a}function s(b,c,e,f,g,i,j){var k=m(b),n=h[k]||(h[k]=[]);c.split(/\s/).forEach(function(c){if(c=="ready")return a(document).ready(e);var h=o(c);h.fn=e,h.sel=g,h.e in l&&(e=function(b){var c=b.relatedTarget;if(!c||c!==this&&!a.contains(this,c))return h.fn.apply(this,arguments)}),h.del=i;var k=i||e;h.proxy=function(a){a=y(a);if(a.isImmediatePropagationStopped())return;a.data=f;var c=k.apply(b,a._args==d?[a]:[a].concat(a._args));return c===!1&&(a.preventDefault(),a.stopPropagation()),c},h.i=n.length,n.push(h),"addEventListener"in b&&b.addEventListener(r(h.e),h.proxy,q(h,j))})}function t(a,b,c,d,e){var f=m(a);(b||"").split(/\s/).forEach(function(b){n(a,b,c,d).forEach(function(b){delete h[f][b.i],"removeEventListener"in a&&a.removeEventListener(r(b.e),b.proxy,q(b,e))})})}function y(b,c){if(c||!b.isDefaultPrevented){c||(c=b),a.each(x,function(a,d){var e=c[a];b[a]=function(){return this[d]=u,e&&e.apply(c,arguments)},b[d]=v});if(c.defaultPrevented!==d?c.defaultPrevented:"returnValue"in c?c.returnValue===!1:c.getPreventDefault&&c.getPreventDefault())b.isDefaultPrevented=u}return b}function z(a){var b,c={originalEvent:a};for(b in a)!w.test(b)&&a[b]!==d&&(c[b]=a[b]);return y(c,a)}var b=a.zepto.qsa,c=1,d,e=Array.prototype.slice,f=a.isFunction,g=function(a){return typeof a=="string"},h={},i={},j="onfocusin"in window,k={focus:"focusin",blur:"focusout"},l={mouseenter:"mouseover",mouseleave:"mouseout"};i.click=i.mousedown=i.mouseup=i.mousemove="MouseEvents",a.event={add:s,remove:t},a.proxy=function(b,c){if(f(b)){var d=function(){return b.apply(c,arguments)};return d._zid=m(b),d}if(g(c))return a.proxy(b[c],b);throw new TypeError("expected function")},a.fn.bind=function(a,b,c){return this.on(a,b,c)},a.fn.unbind=function(a,b){return this.off(a,b)},a.fn.one=function(a,b,c,d){return this.on(a,b,c,d,1)};var u=function(){return!0},v=function(){return!1},w=/^([A-Z]|returnValue$|layer[XY]$)/,x={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};a.fn.delegate=function(a,b,c){return this.on(b,a,c)},a.fn.undelegate=function(a,b,c){return this.off(b,a,c)},a.fn.live=function(b,c){return a(document.body).delegate(this.selector,b,c),this},a.fn.die=function(b,c){return a(document.body).undelegate(this.selector,b,c),this},a.fn.on=function(b,c,h,i,j){var k,l,m=this;if(b&&!g(b))return a.each(b,function(a,b){m.on(a,c,h,b,j)}),m;!g(c)&&!f(i)&&i!==!1&&(i=h,h=c,c=d);if(f(h)||h===!1)i=h,h=d;return i===!1&&(i=v),m.each(function(d,f){j&&(k=function(a){return t(f,a.type,i),i.apply(this,arguments)}),c&&(l=function(b){var d,g=a(b.target).closest(c,f).get(0);if(g&&g!==f)return d=a.extend(z(b),{currentTarget:g,liveFired:f}),(k||i).apply(g,[d].concat(e.call(arguments,1)))}),s(f,b,i,h,c,l||k)})},a.fn.off=function(b,c,e){var h=this;return b&&!g(b)?(a.each(b,function(a,b){h.off(a,c,b)}),h):(!g(c)&&!f(e)&&e!==!1&&(e=c,c=d),e===!1&&(e=v),h.each(function(){t(this,b,e,c)}))},a.fn.trigger=function(b,c){return b=g(b)||a.isPlainObject(b)?a.Event(b):y(b),b._args=c,this.each(function(){"dispatchEvent"in this?this.dispatchEvent(b):a(this).triggerHandler(b,c)})},a.fn.triggerHandler=function(b,c){var d,e;return this.each(function(f,h){d=z(g(b)?a.Event(b):b),d._args=c,d.target=h,a.each(n(h,b.type||b),function(a,b){e=b.proxy(d);if(d.isImmediatePropagationStopped())return!1})}),e},"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(b){a.fn[b]=function(a){return a?this.bind(b,a):this.trigger(b)}}),["focus","blur"].forEach(function(b){a.fn[b]=function(a){return a?this.bind(b,a):this.each(function(){try{this[b]()}catch(a){}}),this}}),a.Event=function(a,b){g(a)||(b=a,a=b.type);var c=document.createEvent(i[a]||"Events"),d=!0;if(b)for(var e in b)e=="bubbles"?d=!!b[e]:c[e]=b[e];return c.initEvent(a,d,!0),y(c)}}(Zepto),function($){function triggerAndReturn(a,b,c){var d=$.Event(b);return $(a).trigger(d,c),!d.isDefaultPrevented()}function triggerGlobal(a,b,c,d){if(a.global)return triggerAndReturn(b||document,c,d)}function ajaxStart(a){a.global&&$.active++===0&&triggerGlobal(a,null,"ajaxStart")}function ajaxStop(a){a.global&&!--$.active&&triggerGlobal(a,null,"ajaxStop")}function ajaxBeforeSend(a,b){var c=b.context;if(b.beforeSend.call(c,a,b)===!1||triggerGlobal(b,c,"ajaxBeforeSend",[a,b])===!1)return!1;triggerGlobal(b,c,"ajaxSend",[a,b])}function ajaxSuccess(a,b,c,d){var e=c.context,f="success";c.success.call(e,a,f,b),d&&d.resolveWith(e,[a,f,b]),triggerGlobal(c,e,"ajaxSuccess",[b,c,a]),ajaxComplete(f,b,c)}function ajaxError(a,b,c,d,e){var f=d.context;d.error.call(f,c,b,a),e&&e.rejectWith(f,[c,b,a]),triggerGlobal(d,f,"ajaxError",[c,d,a||b]),ajaxComplete(b,c,d)}function ajaxComplete(a,b,c){var d=c.context;c.complete.call(d,b,a),triggerGlobal(c,d,"ajaxComplete",[b,c]),ajaxStop(c)}function empty(){}function mimeToDataType(a){return a&&(a=a.split(";",2)[0]),a&&(a==htmlType?"html":a==jsonType?"json":scriptTypeRE.test(a)?"script":xmlTypeRE.test(a)&&"xml")||"text"}function appendQuery(a,b){return b==""?a:(a+"&"+b).replace(/[&?]{1,2}/,"?")}function serializeData(a){a.processData&&a.data&&$.type(a.data)!="string"&&(a.data=$.param(a.data,a.traditional)),a.data&&(!a.type||a.type.toUpperCase()=="GET")&&(a.url=appendQuery(a.url,a.data),a.data=undefined)}function parseArguments(a,b,c,d){var e=!$.isFunction(b);return{url:a,data:e?b:undefined,success:e?$.isFunction(c)?c:undefined:b,dataType:e?d||c:c}}function serialize(a,b,c,d){var e,f=$.isArray(b),g=$.isPlainObject(b);$.each(b,function(b,h){e=$.type(h),d&&(b=c?d:d+"["+(g||e=="object"||e=="array"?b:"")+"]"),!d&&f?a.add(h.name,h.value):e=="array"||!c&&e=="object"?serialize(a,h,c,b):a.add(b,h)})}var jsonpID=0,document=window.document,key,name,rscript=/)<[^<]*)*<\/script>/gi,scriptTypeRE=/^(?:text|application)\/javascript/i,xmlTypeRE=/^(?:text|application)\/xml/i,jsonType="application/json",htmlType="text/html",blankRE=/^\s*$/;$.active=0,$.ajaxJSONP=function(a,b){if("type"in a){var c=a.jsonpCallback,d=($.isFunction(c)?c():c)||"jsonp"+ ++jsonpID,e=document.createElement("script"),f=window[d],g,h=function(a){$(e).triggerHandler("error",a||"abort")},i={abort:h},j;return b&&b.promise(i),$(e).on("load error",function(c,h){clearTimeout(j),$(e).off().remove(),c.type=="error"||!g?ajaxError(null,h||"error",i,a,b):ajaxSuccess(g[0],i,a,b),window[d]=f,g&&$.isFunction(f)&&f(g[0]),f=g=undefined}),ajaxBeforeSend(i,a)===!1?(h("abort"),i):(window[d]=function(){g=arguments},e.src=a.url.replace(/=\?/,"="+d),document.head.appendChild(e),a.timeout>0&&(j=setTimeout(function(){h("timeout")},a.timeout)),i)}return $.ajax(a)},$.ajaxSettings={type:"GET",beforeSend:empty,success:empty,error:empty,complete:empty,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:jsonType,xml:"application/xml, text/xml",html:htmlType,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},$.ajax=function(options){var settings=$.extend({},options||{}),deferred=$.Deferred&&$.Deferred();for(key in $.ajaxSettings)settings[key]===undefined&&(settings[key]=$.ajaxSettings[key]);ajaxStart(settings),settings.crossDomain||(settings.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(settings.url)&&RegExp.$2!=window.location.host),settings.url||(settings.url=window.location.toString()),serializeData(settings),settings.cache===!1&&(settings.url=appendQuery(settings.url,"_="+Date.now()));var dataType=settings.dataType,hasPlaceholder=/=\?/.test(settings.url);if(dataType=="jsonp"||hasPlaceholder)return hasPlaceholder||(settings.url=appendQuery(settings.url,settings.jsonp?settings.jsonp+"=?":settings.jsonp===!1?"":"callback=?")),$.ajaxJSONP(settings,deferred);var mime=settings.accepts[dataType],headers={},setHeader=function(a,b){headers[a.toLowerCase()]=[a,b]},protocol=/^([\w-]+:)\/\//.test(settings.url)?RegExp.$1:window.location.protocol,xhr=settings.xhr(),nativeSetHeader=xhr.setRequestHeader,abortTimeout;deferred&&deferred.promise(xhr),settings.crossDomain||setHeader("X-Requested-With","XMLHttpRequest"),setHeader("Accept",mime||"*/*");if(mime=settings.mimeType||mime)mime.indexOf(",")>-1&&(mime=mime.split(",",2)[0]),xhr.overrideMimeType&&xhr.overrideMimeType(mime);(settings.contentType||settings.contentType!==!1&&settings.data&&settings.type.toUpperCase()!="GET")&&setHeader("Content-Type",settings.contentType||"application/x-www-form-urlencoded");if(settings.headers)for(name in settings.headers)setHeader(name,settings.headers[name]);xhr.setRequestHeader=setHeader,xhr.onreadystatechange=function(){if(xhr.readyState==4){xhr.onreadystatechange=empty,clearTimeout(abortTimeout);var result,error=!1;if(xhr.status>=200&&xhr.status<300||xhr.status==304||xhr.status==0&&protocol=="file:"){dataType=dataType||mimeToDataType(settings.mimeType||xhr.getResponseHeader("content-type")),result=xhr.responseText;try{dataType=="script"?(1,eval)(result):dataType=="xml"?result=xhr.responseXML:dataType=="json"&&(result=blankRE.test(result)?null:$.parseJSON(result))}catch(e){error=e}error?ajaxError(error,"parsererror",xhr,settings,deferred):ajaxSuccess(result,xhr,settings,deferred)}else ajaxError(xhr.statusText||null,xhr.status?"error":"abort",xhr,settings,deferred)}};if(ajaxBeforeSend(xhr,settings)===!1)return xhr.abort(),ajaxError(null,"abort",xhr,settings,deferred),xhr;if(settings.xhrFields)for(name in settings.xhrFields)xhr[name]=settings.xhrFields[name];var async="async"in settings?settings.async:!0;xhr.open(settings.type,settings.url,async,settings.username,settings.password);for(name in headers)nativeSetHeader.apply(xhr,headers[name]);return settings.timeout>0&&(abortTimeout=setTimeout(function(){xhr.onreadystatechange=empty,xhr.abort(),ajaxError(null,"timeout",xhr,settings,deferred)},settings.timeout)),xhr.send(settings.data?settings.data:null),xhr},$.get=function(a,b,c,d){return $.ajax(parseArguments.apply(null,arguments))},$.post=function(a,b,c,d){var e=parseArguments.apply(null,arguments);return e.type="POST",$.ajax(e)},$.getJSON=function(a,b,c){var d=parseArguments.apply(null,arguments);return d.dataType="json",$.ajax(d)},$.fn.load=function(a,b,c){if(!this.length)return this;var d=this,e=a.split(/\s/),f,g=parseArguments(a,b,c),h=g.success;return e.length>1&&(g.url=e[0],f=e[1]),g.success=function(a){d.html(f?$("
    ").html(a.replace(rscript,"")).find(f):a),h&&h.apply(d,arguments)},$.ajax(g),this};var escape=encodeURIComponent;$.param=function(a,b){var c=[];return c.add=function(a,b){this.push(escape(a)+"="+escape(b))},serialize(c,a,b),c.join("&").replace(/%20/g,"+")}}(Zepto),function(a){a.fn.serializeArray=function(){var b=[],c;return a([].slice.call(this.get(0).elements)).each(function(){c=a(this);var d=c.attr("type");this.nodeName.toLowerCase()!="fieldset"&&!this.disabled&&d!="submit"&&d!="reset"&&d!="button"&&(d!="radio"&&d!="checkbox"||this.checked)&&b.push({name:c.attr("name"),value:c.val()})}),b},a.fn.serialize=function(){var a=[];return this.serializeArray().forEach(function(b){a.push(encodeURIComponent(b.name)+"="+encodeURIComponent(b.value))}),a.join("&")},a.fn.submit=function(b){if(b)this.bind("submit",b);else if(this.length){var c=a.Event("submit");this.eq(0).trigger(c),c.isDefaultPrevented()||this.get(0).submit()}return this}}(Zepto),function(a){"__proto__"in{}||a.extend(a.zepto,{Z:function(b,c){return b=b||[],a.extend(b,a.fn),b.selector=c||"",b.__Z=!0,b},isZ:function(b){return a.type(b)==="array"&&"__Z"in b}});try{getComputedStyle(undefined)}catch(b){var c=getComputedStyle;window.getComputedStyle=function(a){try{return c(a)}catch(b){return null}}}}(Zepto) \ No newline at end of file diff --git a/js/main.js b/Web/js/main.js similarity index 84% rename from js/main.js rename to Web/js/main.js index dbab896..4dcd0eb 100644 --- a/js/main.js +++ b/Web/js/main.js @@ -31,8 +31,8 @@ $(document).ready(function() { yepnope({ test: window.mobile, - yep : ['js/libs/touch.js', 'js/mobile-events.js', 'js/libs/color-picker-touch.js'], - nope: ['js/events.js', 'js/libs/color-picker.js'] + yep : ['js/libs/touch.js', 'js/mobile.js', 'js/libs/color-picker-touch.js'], + nope: ['js/desktop.js', 'js/libs/color-picker.js'] }) }) diff --git a/js/mobile-events.js b/Web/js/mobile.js similarity index 86% rename from js/mobile-events.js rename to Web/js/mobile.js index 438972c..c0c1ed8 100644 --- a/js/mobile-events.js +++ b/Web/js/mobile.js @@ -1,5 +1,25 @@ "use strict"; +$(document).ready(function() { + +// Open External Links in browser + +$('*').click(function(e) { + e.preventDefault(); +}) + +$('a[href^="http"]').on('tap', function(e) { + e.preventDefault(); + var href = $(this).attr('href'); + var view = new MozActivity({ + name: 'view', + data: { + type: 'url', + url: href + } + }) +}) + function save() { switch(save.background) { case 'white': { @@ -41,10 +61,10 @@ function save() { c.putImageData(window.points.history[window.points.history.last].data, 0, 0); } - $('.menu').on('tap', function() { + $('.menu').tap(function() { $('#menu').toggleClass('pulled'); }) - $('.save').on('tap', function() { + $('.save').tap(function() { $('#save').removeClass('hidden'); }) $c.last().on('touchstart', function(e) { @@ -80,7 +100,7 @@ function save() { var $single = $('form[data-type="value-selector"].single'); - $single.find('li').on('tap', function(e) { + $single.find('li').tap(function(e) { e.preventDefault(); $(this).parent().find('li[aria-selected]').removeAttr('aria-selected'); $(this).attr('aria-selected', 'true'); @@ -104,11 +124,11 @@ function save() { var $confirm = $('form[data-type="value-selector"].confirm'); - $confirm.find('li').on('tap', function(e) { + $confirm.find('li').tap(function(e) { $(this).parent().find('li[aria-selected]').removeAttr('aria-selected'); $(this).attr('aria-selected', 'true'); }) - $confirm.find('button').last().on('tap', function(e) { + $confirm.find('button').last().tap(function(e) { e.preventDefault(); var v = $(this).parents('form').attr('id'); $(this).parents('form').find('h1').each(function(i) { @@ -123,7 +143,7 @@ function save() { $(this).parents('form').addClass('hidden'); window[v](); }) - $confirm.find('button').first().on('tap', function(e) { + $confirm.find('button').first().tap(function(e) { e.preventDefault(); $(this).parents('form').addClass('hidden'); }) @@ -134,11 +154,11 @@ function save() { $btn.each(function() { var target = /set(.*)/.exec($(this).attr('id'))[1]; if( target == 'color' ) { - return $(this).on('tap', function() { + return $(this).tap(function() { $('.picker').removeClass('hidden'); }) } - $(this).on('tap', function(e) { + $(this).tap(function(e) { e.preventDefault(); $('form[id="' + target + '"]').removeClass('hidden'); }) @@ -171,13 +191,13 @@ function save() { // Color Picker - $('#closePicker').on('tap', function() { - $('.picker').addClass('hidden'); + $('.close').tap(function() { + $(this).parent().addClass('hidden'); }) // Bottom - $('#clear').on('tap', function() { + $('#clear').tap(function() { c.clearRect(0, 0, width(), height()); var h = window.points.history; window.points = []; @@ -193,6 +213,11 @@ function save() { window.points.history.last = window.points.history.length-1; }) - $('#undo').on('tap', undo); - $('#redo').on('tap', redo); + $('#undo').tap(undo); + $('#redo').tap(redo); + $('#about').tap(function() { + $('.about').removeClass('hidden'); + }) + +}); diff --git a/manifest-web.webapp b/Web/manifest-web.webapp similarity index 100% rename from manifest-web.webapp rename to Web/manifest-web.webapp diff --git a/changelog b/changelog new file mode 100644 index 0000000..e69de29