From fc081add6f353b3b6a6d097840b40dfe5e7e214b Mon Sep 17 00:00:00 2001 From: hudaokeji Date: Sun, 24 Sep 2017 20:06:48 +0900 Subject: [PATCH] use skylarkjs --- lib/particles.js | 2 +- lib/skylark-jquery-all.min.js | 8 - lib/skylark-jquery.js | 1140 +++ lib/skylark-jquery/ajax.js | 496 -- lib/skylark-jquery/callbacks.js | 127 - lib/skylark-jquery/core.js | 292 - lib/skylark-jquery/deferred.js | 131 - lib/skylark/async.js | 5 - lib/skylark/browser.js | 5 - lib/skylark/css.js | 5 - lib/skylark/datax.js | 5 - lib/skylark/dnd.js | 5 - lib/skylark/eventer.js | 5 - lib/skylark/filer.js | 5 - lib/skylark/finder.js | 5 - lib/skylark/fx.js | 5 - lib/skylark/geom.js | 5 - lib/skylark/langx.js | 5 - lib/skylark/main.js | 24 - lib/skylark/mover.js | 5 - lib/skylark/noder.js | 5 - lib/skylark/query.js | 5 - lib/skylark/router.js | 5 - lib/skylark/scripter.js | 5 - lib/skylark/skylark.js | 5 - lib/skylark/spa.js | 311 - lib/skylark/styler.js | 5 - lib/skylark/velm.js | 5 - lib/skylarkjs-all.min.js | 11 - lib/skylarkjs.js | 7030 +++++++++++++++++ src/scripts/helpers/AceEditor.js | 2 +- src/scripts/helpers/FolderTreeDomEvent.js | 2 +- src/scripts/helpers/FolderTreeStore.js | 2 +- src/scripts/helpers/Partial.js | 2 +- src/scripts/main.js | 22 +- .../plugins/navbar/NavbarController.js | 6 +- .../plugins/search/SearchController.js | 8 +- src/scripts/routes/api/ApiController.js | 9 +- .../routes/examples/ExamplesController.js | 13 +- src/scripts/routes/guide/GuideController.js | 9 +- src/scripts/routes/home/HomeController.js | 8 +- src/scripts/routes/home/home.html | 2 +- 42 files changed, 8211 insertions(+), 1541 deletions(-) delete mode 100644 lib/skylark-jquery-all.min.js create mode 100644 lib/skylark-jquery.js delete mode 100644 lib/skylark-jquery/ajax.js delete mode 100644 lib/skylark-jquery/callbacks.js delete mode 100644 lib/skylark-jquery/core.js delete mode 100644 lib/skylark-jquery/deferred.js delete mode 100644 lib/skylark/async.js delete mode 100644 lib/skylark/browser.js delete mode 100644 lib/skylark/css.js delete mode 100644 lib/skylark/datax.js delete mode 100644 lib/skylark/dnd.js delete mode 100644 lib/skylark/eventer.js delete mode 100644 lib/skylark/filer.js delete mode 100644 lib/skylark/finder.js delete mode 100644 lib/skylark/fx.js delete mode 100644 lib/skylark/geom.js delete mode 100644 lib/skylark/langx.js delete mode 100644 lib/skylark/main.js delete mode 100644 lib/skylark/mover.js delete mode 100644 lib/skylark/noder.js delete mode 100644 lib/skylark/query.js delete mode 100644 lib/skylark/router.js delete mode 100644 lib/skylark/scripter.js delete mode 100644 lib/skylark/skylark.js delete mode 100644 lib/skylark/spa.js delete mode 100644 lib/skylark/styler.js delete mode 100644 lib/skylark/velm.js delete mode 100644 lib/skylarkjs-all.min.js create mode 100644 lib/skylarkjs.js diff --git a/lib/particles.js b/lib/particles.js index 12ecdd6..c15fbc9 100644 --- a/lib/particles.js +++ b/lib/particles.js @@ -7,7 +7,7 @@ /* v2.0.0 /* ----------------------------------------------- */ define([ - "skylark/query", + "skylarkjs/query", ], function($) { var shapeSize = { w: 100, h: 100 }, number = { v: 80, d: 800 }, diff --git a/lib/skylark-jquery-all.min.js b/lib/skylark-jquery-all.min.js deleted file mode 100644 index a800c87..0000000 --- a/lib/skylark-jquery-all.min.js +++ /dev/null @@ -1,8 +0,0 @@ -/** - * skylark-jquery - The skylark plugin library for fully compatible API with jquery. - * @author Hudaokeji Co.,Ltd - * @version v0.9.0 - * @link www.skylarkjs.org - * @license MIT - */ -!function(e,t){var n=t.define,r=t.require,i="function"==typeof n&&n.amd,a=!i&&"undefined"!=typeof exports;if(!i&&!n){var o={};n=t.define=function(e,t,n){"function"==typeof n?(o[e]={factory:n,deps:t,exports:null},r(e)):resolved[e]=n},r=t.require=function(e){if(!o.hasOwnProperty(e))throw new Error("Module "+e+" has not been defined");var t=o[e];if(!t.exports){var n=[];t.deps.forEach(function(e){n.push(r(e))}),t.exports=t.factory.apply(window,n)}return t.exports}}if(e(n,r),i)n(["skylark-jquery/core","skylark-jquery/callbacks","skylark-jquery/deferred","skylark-jquery/ajax"],function(e){return e});else{var s;r(["skylark-jquery/core","skylark-jquery/callbacks","skylark-jquery/deferred","skylark-jquery/ajax"],function(e){s=e}),a?exports=s:t.jQuery=t.$=s}}(function(e,t){e("skylark-jquery/core",["skylark/langx","skylark/noder","skylark/datax","skylark/eventer","skylark/finder","skylark/styler","skylark/query"],function(e,t,n,r,i,a,o){var s=Array.prototype.filter,u=Array.prototype.slice;return function(t){t.fn.jquery="2.2.0",t.camelCase=e.camelize,t.each=e.each,t.extend=function(t){var n,r=u.call(arguments,1);return"boolean"==typeof t&&(n=t,t=r.shift()),0==r.length&&(r=[t],t=this),r.forEach(function(r){e.mixin(t,r,n)}),t},t.grep=function(e,t){return s.call(e,t)},t.isArray=e.isArray,t.isEmptyObject=e.isEmptyObject,t.isFunction=e.isFunction,t.isWindow=e.isWindow,t.isPlainObject=e.isPlainObject,t.inArray=e.inArray,t.makeArray=e.makeArray,t.map=e.map,t.noop=function(){},t.parseJSON=window.JSON.parse,t.proxy=e.proxy,t.trim=e.trim,t.type=e.type,t.fn.extend=function(n){e.mixin(t.fn,n)},t.fn.serializeArray=function(){var n,r,i=[],a=function(e){return e.forEach?e.forEach(a):void i.push({name:n,value:e})};return this[0]&&e.each(this[0].elements,function(e,i){r=i.type,n=i.name,n&&"fieldset"!=i.nodeName.toLowerCase()&&!i.disabled&&"submit"!=r&&"reset"!=r&&"button"!=r&&"file"!=r&&("radio"!=r&&"checkbox"!=r||i.checked)&&a(t(i).val())}),i},t.fn.serialize=function(){var e=[];return this.serializeArray().forEach(function(t){e.push(encodeURIComponent(t.name)+"="+encodeURIComponent(t.value))}),e.join("&")}}(o),function(t){t.Event=function(t,n){return t&&!e.isString(t)&&(n=t,t=n.type),r.create(t,n)},t.event={},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this},t.fn.triggerHandler=t.fn.trigger,t.fn.delegate=function(e,t,n){return this.on(t,e,n)},t.fn.undelegate=function(e,t,n){return this.off(t,e,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.bind=function(e,t,n,r){return this.on(e,t,n,r)},t.fn.unbind=function(e,t){return this.off(e,t)},t.fn.ready=function(e){return r.ready(e),this},t.fn.hover=function(e,t){return this.mouseenter(e).mouseleave(t||e)},t.fn.stop=function(){return this},t.fn.moveto=function(e,t){return this.animate({left:e+"px",top:t+"px"},.4)},t.ready=r.ready,t.on=r.on,t.off=r.off}(o),function(e){e.uuid=0,e.support={},e.expr={},e.expr[":"]=e.expr.pseudos=e.expr.filters=i.pseudos,e.contains=t.contains,e.css=a.css,e.data=n.data,e.offset={},e.offset.setOffset=function(t,n,r){var i=e.css(t,"position");"static"===i&&(t.style.position="relative");var a,o,s=e(t),u=s.offset(),c=e.css(t,"top"),l=e.css(t,"left"),f=("absolute"===i||"fixed"===i)&&e.inArray("auto",[c,l])>-1,p={},d={};f?(d=s.position(),a=d.top,o=d.left):(a=parseFloat(c)||0,o=parseFloat(l)||0),e.isFunction(n)&&(n=n.call(t,r,u)),null!=n.top&&(p.top=n.top-u.top+a),null!=n.left&&(p.left=n.left-u.left+o),"using"in n?n.using.call(t,p):s.css(p)}}(o),function(e){e.event.special=e.event.special||{};var t=e.fn.on;e.fn.on=function(n,r,i,a,o){if("object"==typeof n)return t.apply(this,[n,r,i,a,o]);var s,u=this,c=(e(u),n);return null==a&&(a=i,i=null),e.each(n.split(/\s/),function(t,n){n=n.split(/\./)[0],n in e.event.special&&(s=e.event.special[n],c=s.bindType||c,s._init||(s._init=!0,s.originalHandler=s.handler||s.handle,s.handler=function(){var t=Array.prototype.slice.call(arguments);t[0]=e.extend({},t[0]),e.event.handle=function(){var t=Array.prototype.slice.call(arguments),n=t[0],r=e(n.target);r.trigger.apply(r,arguments)},s.originalHandler.apply(this,t)}),s.setup&&s.setup.apply(u,[i]))}),t.apply(this,[c,r,i,a,o])}}(o),window.jQuery=window.$=o}),e("skylark-jquery/deferred",["skylark-jquery/core"],function(e){function t(n){var r=[["resolve","done",e.Callbacks({once:1,memory:1}),"resolved"],["reject","fail",e.Callbacks({once:1,memory:1}),"rejected"],["notify","progress",e.Callbacks({memory:1})]],i="pending",a={state:function(){return i},always:function(){return o.done(arguments).fail(arguments),this},then:function(){var n=arguments;return t(function(t){e.each(r,function(r,i){var s=e.isFunction(n[r])&&n[r];o[i[1]](function(){var n=s&&s.apply(this,arguments);if(n&&e.isFunction(n.promise))n.promise().done(t.resolve).fail(t.reject).progress(t.notify);else{var r=this===a?t.promise():this,o=s?[n]:arguments;t[i[0]+"With"](r,o)}})}),n=null}).promise()},promise:function(t){return null!=t?e.extend(t,a):a}},o={};return e.each(r,function(e,t){var n=t[2],s=t[3];a[t[1]]=n.add,s&&n.add(function(){i=s},r[1^e][2].disable,r[2][2].lock),o[t[0]]=function(){return o[t[0]+"With"](this===o?a:this,arguments),this},o[t[0]+"With"]=n.fireWith}),a.promise(o),n&&n.call(o,o),o}var n=Array.prototype.slice;return e.when=function(r){var i,a,o,s=n.call(arguments),u=s.length,c=0,l=1!==u||r&&e.isFunction(r.promise)?u:0,f=1===l?r:t(),p=function(e,t,r){return function(a){t[e]=this,r[e]=arguments.length>1?n.call(arguments):a,r===i?f.notifyWith(t,r):--l||f.resolveWith(t,r)}};if(u>1)for(i=new Array(u),a=new Array(u),o=new Array(u);c-1;)u.splice(r,1),i&&(r<=o&&--o,r<=s&&--s)}),this},has:function(t){return!(!u||!(t?e.inArray(t,u)>-1:u.length))},empty:function(){return o=u.length=0,this},disable:function(){return u=c=n=void 0,this},disabled:function(){return!u},lock:function(){return c=void 0,n||f.disable(),this},locked:function(){return!c},fireWith:function(e,t){return!u||r&&!c||(t=t||[],t=[e,t.slice?t.slice():t],i?c.push(t):l(t)),this},fire:function(){return f.fireWith(this,arguments)},fired:function(){return!!r}};return f},e}),e("skylark-jquery/ajax",["skylark-jquery/core","skylark-jquery/deferred"],function(e){function t(t,n,r){var i=e.Event(n);return e(t).trigger(i,r),!i.isDefaultPrevented()}function n(e,n,r,i){if(e.global)return t(n||g,r,i)}function r(t){t.global&&0===e.active++&&n(t,null,"ajaxStart")}function i(t){t.global&&!--e.active&&n(t,null,"ajaxStop")}function a(e,t){var r=t.context;return t.beforeSend.call(r,e,t)!==!1&&n(t,r,"ajaxBeforeSend",[e,t])!==!1&&void n(t,r,"ajaxSend",[e,t])}function o(e,t,r,i){var a=r.context,o="success";r.success.call(a,e,o,t),i&&i.resolveWith(a,[e,o,t]),n(r,a,"ajaxSuccess",[t,r,e]),u(o,t,r)}function s(e,t,r,i,a){var o=i.context;i.error.call(o,r,t,e),a&&a.rejectWith(o,[r,t,e]),n(i,o,"ajaxError",[r,i,e||t]),u(t,r,i)}function u(e,t,r){var a=r.context;r.complete.call(a,t,e),n(r,a,"ajaxComplete",[t,r]),i(r)}function c(){}function l(e){return e&&(e=e.split(";",2)[0]),e&&(e==S?"html":e==q?"json":b.test(e)?"script":w.test(e)&&"xml")||"text"}function f(e,t){return""==t?e:(e+"&"+t).replace(/[&?]{1,2}/,"?")}function p(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()||(t.url=f(t.url,t.data),t.data=void 0)}function d(t,n,r,i){return e.isFunction(n)&&(i=r,r=n,n=void 0),e.isFunction(r)||(i=r,r=void 0),{url:t,data:n,success:r,dataType:i}}function y(t,n,r,i){var a,o=e.isArray(n),s=e.isPlainObject(n);e.each(n,function(n,u){a=e.type(u),i&&(n=r?i:i+"["+(s||"object"==a||"array"==a?n:"")+"]"),!i&&o?t.add(u.name,u.value):"array"==a||!r&&"object"==a?y(t,u,r,n):t.add(n,u)})}function h(e){return function(t,n){"string"!=typeof t&&(n=t,t="*");var r,i=0,a=t.toLowerCase().match(O)||[];if(jQuery.isFunction(n))for(;r=a[i++];)"+"===r[0]?(r=r.slice(1)||"*",(e[r]=e[r]||[]).unshift(n)):(e[r]=e[r]||[]).push(n)}}function m(e,t){var n,r,i=jQuery.ajaxSettings.flatOptions||{};for(n in t)void 0!==t[n]&&((i[n]?e:r||(r={}))[n]=t[n]);return r&&jQuery.extend(!0,e,r),e}var v,x,j=0,g=window.document,k=/)<[^<]*)*<\/script>/gi,b=/^(?:text|application)\/javascript/i,w=/^(?:text|application)\/xml/i,q="application/json",S="text/html",T=/^\s*$/,A=g.createElement("a");A.href=window.location.href,e.active=0,e.ajaxJSONP=function(t,n){if(!("type"in t))return e.ajax(t);var r,i,u=t.jsonpCallback,c=(e.isFunction(u)?u():u)||"jsonp"+ ++j,l=g.createElement("script"),f=window[c],p=function(t){e(l).triggerHandler("error",t||"abort")},d={abort:p};return n&&n.promise(d),e(l).on("load error",function(a,u){clearTimeout(i),e(l).off().remove(),"error"!=a.type&&r?o(r[0],d,t,n):s(null,u||"error",d,t,n),window[c]=f,r&&e.isFunction(f)&&f(r[0]),f=r=void 0}),a(d,t)===!1?(p("abort"),d):(window[c]=function(){r=arguments},l.src=t.url.replace(/\?(.+)=\?/,"?$1="+c),g.head.appendChild(l),t.timeout>0&&(i=setTimeout(function(){p("timeout")},t.timeout)),d)},e.ajaxSettings={type:"GET",beforeSend:c,success:c,error:c,complete:c,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:q,xml:"application/xml, text/xml",html:S,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},e.ajax=function(t){var n,i=e.extend({},t||{}),u=e.Deferred&&e.Deferred();for(v in e.ajaxSettings)void 0===i[v]&&(i[v]=e.ajaxSettings[v]);r(i),i.crossDomain||(n=g.createElement("a"),n.href=i.url,n.href=n.href,i.crossDomain=A.protocol+"//"+A.host!=n.protocol+"//"+n.host),i.url||(i.url=window.location.toString()),p(i);var d=i.dataType,y=/\?.+=\?/.test(i.url);if(y&&(d="jsonp"),i.cache!==!1&&(t&&t.cache===!0||"script"!=d&&"jsonp"!=d)||(i.url=f(i.url,"_="+Date.now())),"jsonp"==d)return y||(i.url=f(i.url,i.jsonp?i.jsonp+"=?":i.jsonp===!1?"":"callback=?")),e.ajaxJSONP(i,u);var h,m=i.accepts[d],j={},k=function(e,t){j[e.toLowerCase()]=[e,t]},b=/^([\w-]+:)\/\//.test(i.url)?RegExp.$1:window.location.protocol,w=i.xhr(),q=w.setRequestHeader;if(u&&u.promise(w),i.crossDomain||k("X-Requested-With","XMLHttpRequest"),k("Accept",m||"*/*"),(m=i.mimeType||m)&&(m.indexOf(",")>-1&&(m=m.split(",",2)[0]),w.overrideMimeType&&w.overrideMimeType(m)),(i.contentType||i.contentType!==!1&&i.data&&"GET"!=i.type.toUpperCase())&&k("Content-Type",i.contentType||"application/x-www-form-urlencoded"),i.headers)for(x in i.headers)k(x,i.headers[x]);if(w.setRequestHeader=k,w.onreadystatechange=function(){if(4==w.readyState){w.onreadystatechange=c,clearTimeout(h);var t,n=!1;if(w.status>=200&&w.status<300||304==w.status||0==w.status&&"file:"==b){d=d||l(i.mimeType||w.getResponseHeader("content-type")),t=w.responseText;try{"script"==d?(0,eval)(t):"xml"==d?t=w.responseXML:"json"==d&&(t=T.test(t)?null:e.parseJSON(t))}catch(r){n=r}n?s(n,"parsererror",w,i,u):o(t,w,i,u)}else s(w.statusText||null,w.status?"error":"abort",w,i,u)}},a(w,i)===!1)return w.abort(),s(null,"abort",w,i,u),w;if(i.xhrFields)for(x in i.xhrFields)w[x]=i.xhrFields[x];var S=!("async"in i)||i.async;w.open(i.type,i.url,S,i.username,i.password);for(x in j)q.apply(w,j[x]);return i.timeout>0&&(h=setTimeout(function(){w.onreadystatechange=c,w.abort(),s(null,"timeout",w,i,u)},i.timeout)),w.send(i.data?i.data:null),w},e.get=function(){return e.ajax(d.apply(null,arguments))},e.post=function(){var t=d.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=d.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,n,r){if(!this.length)return this;var i,a=this,o=t.split(/\s/),s=d(t,n,r),u=s.success;return o.length>1&&(s.url=o[0],i=o[1]),s.success=function(t){a.html(i?e("
").html(t.replace(k,"")).find(i):t),u&&u.apply(a,arguments)},e.ajax(s),this};var E=encodeURIComponent;e.param=function(t,n){var r=[];return r.add=function(t,n){e.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(E(t)+"="+E(n))},y(r,t,n),r.join("&").replace(/%20/g,"+")};var F={},C={},O=/\S+/g;return e.ajaxPrefilter=h(F),e.ajaxTransport=h(C),e.ajaxSetup=function(e,t){return t?m(m(e,jQuery.ajaxSettings),t):m(jQuery.ajaxSettings,e)},e})},this); \ No newline at end of file diff --git a/lib/skylark-jquery.js b/lib/skylark-jquery.js new file mode 100644 index 0000000..632f6e2 --- /dev/null +++ b/lib/skylark-jquery.js @@ -0,0 +1,1140 @@ +/** + * skylark-jquery - The skylark plugin library for fully compatible API with jquery. + * @author Hudaokeji Co.,Ltd + * @version v0.9.3 + * @link www.skylarkjs.org + * @license MIT + */ +(function(factory,globals) { + var define = globals.define, + require = globals.require, + isAmd = (typeof define === 'function' && define.amd), + isCmd = (!isAmd && typeof exports !== 'undefined'); + + if (!isAmd && !define) { + var map = {}; + function absolute(relative, base) { + if (relative[0]!==".") { + return relative; + } + var stack = base.split("/"), + parts = relative.split("/"); + stack.pop(); + for (var i=0; i -1, + props = {}, + curPosition = {}, + curTop, curLeft; + + // need to be able to calculate position if either top or left is auto and position is either absolute or fixed + if (calculatePosition) { + curPosition = curElem.position(); + curTop = curPosition.top; + curLeft = curPosition.left; + } else { + curTop = parseFloat(curCSSTop) || 0; + curLeft = parseFloat(curCSSLeft) || 0; + } + + if ($.isFunction(options)) { + options = options.call(elem, i, curOffset); + } + + if (options.top != null) { + props.top = (options.top - curOffset.top) + curTop; + } + if (options.left != null) { + props.left = (options.left - curOffset.left) + curLeft; + } + + if ("using" in options) { + options.using.call(elem, props); + } else { + curElem.css(props); + } + }; + })(query); + + (function($){ + /** + * @license Copyright 2013 Enideo. Released under dual MIT and GPL licenses. + * https://github.com/Enideo/zepto-events-special + */ + + $.event.special = $.event.special || {}; + + var bindBeforeSpecialEvents = $.fn.on; + + // $.fn.on = function (eventName, data, callback) { + $.fn.on = function(eventName, selector, data, callback, one) { + if (typeof eventName === "object") return bindBeforeSpecialEvents.apply(this, [eventName, selector, data, callback, one]); + var el = this, + $this = $(el), + specialEvent, + bindEventName = eventName; + + if (callback == null) { + callback = data; + data = null; + } + + $.each(eventName.split(/\s/), function(i, eventName) { + eventName = eventName.split(/\./)[0]; + if ((eventName in $.event.special)) { + specialEvent = $.event.special[eventName]; + bindEventName = specialEvent.bindType || bindEventName; + /// init enable special events on Zepto + if (!specialEvent._init) { + specialEvent._init = true; + /// intercept and replace the special event handler to add functionality + specialEvent.originalHandler = specialEvent.handler || specialEvent.handle; + specialEvent.handler = function() { + /// make event argument writeable, like on jQuery + var args = Array.prototype.slice.call(arguments); + args[0] = $.extend({}, args[0]); + /// define the event handle, $.event.dispatch is only for newer versions of jQuery + $.event.handle = function() { + /// make context of trigger the event element + var args = Array.prototype.slice.call(arguments), + event = args[0], + $target = $(event.target); + $target.trigger.apply($target, arguments); + } + specialEvent.originalHandler.apply(this, args); + } + } + /// setup special events on Zepto + specialEvent.setup && specialEvent.setup.apply(el, [data]); + } + }); + + return bindBeforeSpecialEvents.apply(this, [bindEventName, selector, data, callback, one]); + + }; + })(query); + + query.skylark = skylark; + + return window.jQuery = window.$ = query; +}); +define('skylark-jquery', ['skylark-jquery/core'], function (main) { return main; }); + +define('skylark-jquery/deferred',[ + "./core" +], function($) { + + /* + (function ($) { + $.Deferred = async.Deferred; + $.when = async.when; + })(Zepto); + */ + + // This module is borrow from zepto.deferred.js + // (c) 2010-2014 Thomas Fuchs + // Zepto.js may be freely distributed under the MIT license. + // + // Some code (c) 2005, 2013 jQuery Foundation, Inc. and other contributors + + var slice = Array.prototype.slice + + function Deferred(func) { + var tuples = [ + // action, add listener, listener list, final state + ["resolve", "done", $.Callbacks({ once: 1, memory: 1 }), "resolved"], + ["reject", "fail", $.Callbacks({ once: 1, memory: 1 }), "rejected"], + ["notify", "progress", $.Callbacks({ memory: 1 })] + ], + state = "pending", + promise = { + state: function() { + return state + }, + always: function() { + deferred.done(arguments).fail(arguments) + return this + }, + then: function( /* fnDone [, fnFailed [, fnProgress]] */ ) { + var fns = arguments + return Deferred(function(defer) { + $.each(tuples, function(i, tuple) { + var fn = $.isFunction(fns[i]) && fns[i] + deferred[tuple[1]](function() { + var returned = fn && fn.apply(this, arguments) + if (returned && $.isFunction(returned.promise)) { + returned.promise() + .done(defer.resolve) + .fail(defer.reject) + .progress(defer.notify) + } else { + var context = this === promise ? defer.promise() : this, + values = fn ? [returned] : arguments + defer[tuple[0] + "With"](context, values) + } + }) + }) + fns = null + }).promise() + }, + + promise: function(obj) { + return obj != null ? $.extend(obj, promise) : promise + } + }, + deferred = {} + + $.each(tuples, function(i, tuple) { + var list = tuple[2], + stateString = tuple[3] + + promise[tuple[1]] = list.add + + if (stateString) { + list.add(function() { + state = stateString + }, tuples[i ^ 1][2].disable, tuples[2][2].lock) + } + + deferred[tuple[0]] = function() { + deferred[tuple[0] + "With"](this === deferred ? promise : this, arguments) + return this + } + deferred[tuple[0] + "With"] = list.fireWith + }) + + promise.promise(deferred) + if (func) func.call(deferred, deferred) + return deferred + } + + $.when = function(sub) { + var resolveValues = slice.call(arguments), + len = resolveValues.length, + i = 0, + remain = len !== 1 || (sub && $.isFunction(sub.promise)) ? len : 0, + deferred = remain === 1 ? sub : Deferred(), + progressValues, progressContexts, resolveContexts, + updateFn = function(i, ctx, val) { + return function(value) { + ctx[i] = this + val[i] = arguments.length > 1 ? slice.call(arguments) : value + if (val === progressValues) { + deferred.notifyWith(ctx, val) + } else if (!(--remain)) { + deferred.resolveWith(ctx, val) + } + } + } + + if (len > 1) { + progressValues = new Array(len) + progressContexts = new Array(len) + resolveContexts = new Array(len) + for (; i < len; ++i) { + if (resolveValues[i] && $.isFunction(resolveValues[i].promise)) { + resolveValues[i].promise() + .done(updateFn(i, resolveContexts, resolveValues)) + .fail(deferred.reject) + .progress(updateFn(i, progressContexts, progressValues)) + } else { + --remain + } + } + } + if (!remain) deferred.resolveWith(resolveContexts, resolveValues) + return deferred.promise() + } + + $.Deferred = Deferred + + return $; + +}); + +define('skylark-jquery/ajax',[ + "./core", + "./deferred" +], function($) { + // zepto.ajax.js + // (c) 2010-2014 Thomas Fuchs + // Zepto.js may be freely distributed under the MIT license. + + 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*$/, + originAnchor = document.createElement('a'); + + originAnchor.href = window.location.href; + + // trigger a custom event and return false if it was cancelled + function triggerAndReturn(context, eventName, data) { + var event = $.Event(eventName) + $(context).trigger(event, data) + return !event.isDefaultPrevented() + } + + // trigger an Ajax "global" event + function triggerGlobal(settings, context, eventName, data) { + if (settings.global) return triggerAndReturn(context || document, eventName, data) + } + + // Number of active Ajax requests + $.active = 0; + + function ajaxStart(settings) { + if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart') + } + + function ajaxStop(settings) { + if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop') + } + + // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable + function ajaxBeforeSend(xhr, settings) { + var context = settings.context + if (settings.beforeSend.call(context, xhr, settings) === false || + triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false) + return false + + triggerGlobal(settings, context, 'ajaxSend', [xhr, settings]) + } + + function ajaxSuccess(data, xhr, settings, deferred) { + var context = settings.context, + status = 'success' + settings.success.call(context, data, status, xhr) + if (deferred) deferred.resolveWith(context, [data, status, xhr]) + triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data]) + ajaxComplete(status, xhr, settings) + } + // type: "timeout", "error", "abort", "parsererror" + function ajaxError(error, type, xhr, settings, deferred) { + var context = settings.context + settings.error.call(context, xhr, type, error) + if (deferred) deferred.rejectWith(context, [xhr, type, error]) + triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error || type]) + ajaxComplete(type, xhr, settings) + } + // status: "success", "notmodified", "error", "timeout", "abort", "parsererror" + function ajaxComplete(status, xhr, settings) { + var context = settings.context + settings.complete.call(context, xhr, status) + triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings]) + ajaxStop(settings) + } + + // Empty function, used as default callback + function empty() {} + + $.ajaxJSONP = function(options, deferred) { + if (!('type' in options)) return $.ajax(options) + + var _callbackName = options.jsonpCallback, + callbackName = ($.isFunction(_callbackName) ? + _callbackName() : _callbackName) || ('jsonp' + (++jsonpID)), + script = document.createElement('script'), + originalCallback = window[callbackName], + responseData, + abort = function(errorType) { + $(script).triggerHandler('error', errorType || 'abort') + }, + xhr = { abort: abort }, + abortTimeout + + if (deferred) deferred.promise(xhr) + + $(script).on('load error', function(e, errorType) { + clearTimeout(abortTimeout) + $(script).off().remove() + + if (e.type == 'error' || !responseData) { + ajaxError(null, errorType || 'error', xhr, options, deferred) + } else { + ajaxSuccess(responseData[0], xhr, options, deferred) + } + + window[callbackName] = originalCallback + if (responseData && $.isFunction(originalCallback)) + originalCallback(responseData[0]) + + originalCallback = responseData = undefined + }) + + if (ajaxBeforeSend(xhr, options) === false) { + abort('abort') + return xhr + } + + window[callbackName] = function() { + responseData = arguments + } + + script.src = options.url.replace(/\?(.+)=\?/, '?$1=' + callbackName) + document.head.appendChild(script) + + if (options.timeout > 0) abortTimeout = setTimeout(function() { + abort('timeout') + }, options.timeout) + + return xhr; + } + + $.ajaxSettings = { + // Default type of request + type: 'GET', + // Callback that is executed before request + beforeSend: empty, + // Callback that is executed if the request succeeds + success: empty, + // Callback that is executed the the server drops error + error: empty, + // Callback that is executed on request complete (both: error and success) + complete: empty, + // The context for the callbacks + context: null, + // Whether to trigger "global" Ajax events + global: true, + // Transport + xhr: function() { + return new window.XMLHttpRequest() + }, + // MIME types mapping + // IIS returns Javascript as "application/x-javascript" + accepts: { + script: 'text/javascript, application/javascript, application/x-javascript', + json: jsonType, + xml: 'application/xml, text/xml', + html: htmlType, + text: 'text/plain' + }, + // Whether the request is to another domain + crossDomain: false, + // Default timeout + timeout: 0, + // Whether data should be serialized to string + processData: true, + // Whether the browser should be allowed to cache GET responses + cache: true + } + + function mimeToDataType(mime) { + if (mime) mime = mime.split(';', 2)[0] + return mime && (mime == htmlType ? 'html' : + mime == jsonType ? 'json' : + scriptTypeRE.test(mime) ? 'script' : + xmlTypeRE.test(mime) && 'xml') || 'text' + } + + function appendQuery(url, query) { + if (query == '') return url + return (url + '&' + query).replace(/[&?]{1,2}/, '?') + } + + // serialize payload and append it to the URL for GET requests + function serializeData(options) { + if (options.processData && options.data && $.type(options.data) != "string") + options.data = $.param(options.data, options.traditional) + if (options.data && (!options.type || options.type.toUpperCase() == 'GET')) + options.url = appendQuery(options.url, options.data), options.data = undefined + } + + $.ajax = function(options) { + var settings = $.extend({}, options || {}), + deferred = $.Deferred && $.Deferred(), + urlAnchor + for (key in $.ajaxSettings) + if (settings[key] === undefined) settings[key] = $.ajaxSettings[key] + + ajaxStart(settings) + + if (!settings.crossDomain) { + urlAnchor = document.createElement('a') + urlAnchor.href = settings.url + urlAnchor.href = urlAnchor.href + settings.crossDomain = (originAnchor.protocol + '//' + originAnchor.host) !== (urlAnchor.protocol + '//' + urlAnchor.host) + } + + if (!settings.url) settings.url = window.location.toString() + serializeData(settings) + + var dataType = settings.dataType, + hasPlaceholder = /\?.+=\?/.test(settings.url) + if (hasPlaceholder) dataType = 'jsonp' + + if (settings.cache === false || ( + (!options || options.cache !== true) && + ('script' == dataType || 'jsonp' == dataType) + )) + settings.url = appendQuery(settings.url, '_=' + Date.now()) + + if ('jsonp' == dataType) { + if (!hasPlaceholder) + settings.url = appendQuery(settings.url, + settings.jsonp ? (settings.jsonp + '=?') : settings.jsonp === false ? '' : 'callback=?') + return $.ajaxJSONP(settings, deferred) + } + + var mime = settings.accepts[dataType], + headers = {}, + setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value] }, + protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol, + xhr = settings.xhr(), + nativeSetHeader = xhr.setRequestHeader, + abortTimeout + + if (deferred) deferred.promise(xhr) + + if (!settings.crossDomain) setHeader('X-Requested-With', 'XMLHttpRequest') + setHeader('Accept', mime || '*/*') + if (mime = settings.mimeType || mime) { + if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0] + xhr.overrideMimeType && xhr.overrideMimeType(mime) + } + if (settings.contentType || (settings.contentType !== false && 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 = false + 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 { + // http://perfectionkills.com/global-eval-what-are-the-options/ + if (dataType == 'script')(1, eval)(result) + else if (dataType == 'xml') result = xhr.responseXML + else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result) + } catch (e) { error = e } + + if (error) ajaxError(error, 'parsererror', xhr, settings, deferred) + else ajaxSuccess(result, xhr, settings, deferred) + } else { + ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred) + } + } + } + + if (ajaxBeforeSend(xhr, settings) === false) { + xhr.abort() + ajaxError(null, 'abort', xhr, settings, deferred) + return xhr + } + + if (settings.xhrFields) + for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name] + + var async = 'async' in settings ? settings.async : true + xhr.open(settings.type, settings.url, async, settings.username, settings.password) + + for (name in headers) nativeSetHeader.apply(xhr, headers[name]) + + if (settings.timeout > 0) abortTimeout = setTimeout(function() { + xhr.onreadystatechange = empty + xhr.abort() + ajaxError(null, 'timeout', xhr, settings, deferred) + }, settings.timeout) + + // avoid sending empty string (#319) + xhr.send(settings.data ? settings.data : null) + return xhr + } + + // handle optional data/success arguments + function parseArguments(url, data, success, dataType) { + if ($.isFunction(data)) dataType = success, success = data, data = undefined + if (!$.isFunction(success)) dataType = success, success = undefined + return { + url: url, + data: data, + success: success, + dataType: dataType + } + } + + $.get = function( /* url, data, success, dataType */ ) { + return $.ajax(parseArguments.apply(null, arguments)) + } + + $.post = function( /* url, data, success, dataType */ ) { + var options = parseArguments.apply(null, arguments) + options.type = 'POST' + return $.ajax(options) + } + + $.getJSON = function( /* url, data, success */ ) { + var options = parseArguments.apply(null, arguments) + options.dataType = 'json' + return $.ajax(options) + } + + $.fn.load = function(url, data, success) { + if (!this.length) return this + var self = this, + parts = url.split(/\s/), + selector, + options = parseArguments(url, data, success), + callback = options.success + if (parts.length > 1) options.url = parts[0], selector = parts[1] + options.success = function(response) { + self.html(selector ? + $('
').html(response.replace(rscript, "")).find(selector) : response) + callback && callback.apply(self, arguments) + } + $.ajax(options) + return this + } + + var escape = encodeURIComponent + + function serialize(params, obj, traditional, scope) { + var type, array = $.isArray(obj), + hash = $.isPlainObject(obj) + $.each(obj, function(key, value) { + type = $.type(value) + if (scope) key = traditional ? scope : + scope + '[' + (hash || type == 'object' || type == 'array' ? key : '') + ']' + // handle data in serializeArray() format + if (!scope && array) params.add(value.name, value.value) + // recurse into nested objects + else if (type == "array" || (!traditional && type == "object")) + serialize(params, value, traditional, key) + else params.add(key, value) + }) + } + + $.param = function(obj, traditional) { + var params = [] + params.add = function(key, value) { + if ($.isFunction(value)) value = value() + if (value == null) value = "" + this.push(escape(key) + '=' + escape(value)) + } + serialize(params, obj, traditional) + return params.join('&').replace(/%20/g, '+') + }; + + var + /* Prefilters + * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) + * 2) These are called: + * - BEFORE asking for a transport + * - AFTER param serialization (s.data is a string if s.processData is true) + * 3) key is the dataType + * 4) the catchall symbol "*" can be used + * 5) execution will start with transport dataType and THEN continue down to "*" if needed + */ + prefilters = {}, + + /* Transports bindings + * 1) key is the dataType + * 2) the catchall symbol "*" can be used + * 3) selection will start with transport dataType and THEN go to "*" if needed + */ + transports = {}, + rnotwhite = (/\S+/g); + + + // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport + function addToPrefiltersOrTransports(structure) { + + // dataTypeExpression is optional and defaults to "*" + return function(dataTypeExpression, func) { + + if (typeof dataTypeExpression !== "string") { + func = dataTypeExpression; + dataTypeExpression = "*"; + } + + var dataType, + i = 0, + dataTypes = dataTypeExpression.toLowerCase().match(rnotwhite) || []; + + if (jQuery.isFunction(func)) { + + // For each dataType in the dataTypeExpression + while ((dataType = dataTypes[i++])) { + + // Prepend if requested + if (dataType[0] === "+") { + dataType = dataType.slice(1) || "*"; + (structure[dataType] = structure[dataType] || []).unshift(func); + + // Otherwise append + } else { + (structure[dataType] = structure[dataType] || []).push(func); + } + } + } + }; + } + + $.ajaxPrefilter = addToPrefiltersOrTransports(prefilters); + $.ajaxTransport = addToPrefiltersOrTransports(transports); + + // A special extend for ajax options + // that takes "flat" options (not to be deep extended) + // Fixes #9887 + function ajaxExtend(target, src) { + var key, deep, + flatOptions = jQuery.ajaxSettings.flatOptions || {}; + + for (key in src) { + if (src[key] !== undefined) { + (flatOptions[key] ? target : (deep || (deep = {})))[key] = src[key]; + } + } + if (deep) { + jQuery.extend(true, target, deep); + } + + return target; + } + + // Creates a full fledged settings object into target + // with both ajaxSettings and settings fields. + // If target is omitted, writes into ajaxSettings. + $.ajaxSetup = function(target, settings) { + return settings ? + + // Building a settings object + ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) : + + // Extending ajaxSettings + ajaxExtend(jQuery.ajaxSettings, target); + }; + + // Base inspection function for prefilters and transports + function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) { + + var inspected = {}, + seekingTransport = (structure === transports); + + function inspect(dataType) { + var selected; + inspected[dataType] = true; + jQuery.each(structure[dataType] || [], function(_, prefilterOrFactory) { + var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR); + if (typeof dataTypeOrTransport === "string" && + !seekingTransport && !inspected[dataTypeOrTransport]) { + + options.dataTypes.unshift(dataTypeOrTransport); + inspect(dataTypeOrTransport); + return false; + } else if (seekingTransport) { + return !(selected = dataTypeOrTransport); + } + }); + return selected; + } + + return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*"); + } + + return $; + +}); + +define('skylark-jquery/callbacks',[ + "./core" +], function($) { + + // This module is borrow from zepto.callback.js + // (c) 2010-2014 Thomas Fuchs + // Zepto.js may be freely distributed under the MIT license. + + // Create a collection of callbacks to be fired in a sequence, with configurable behaviour + // Option flags: + // - once: Callbacks fired at most one time. + // - memory: Remember the most recent context and arguments + // - stopOnFalse: Cease iterating over callback list + // - unique: Permit adding at most one instance of the same callback + $.Callbacks = function(options) { + options = $.extend({}, options) + + var memory, // Last fire value (for non-forgettable lists) + fired, // Flag to know if list was already fired + firing, // Flag to know if list is currently firing + firingStart, // First callback to fire (used internally by add and fireWith) + firingLength, // End of the loop when firing + firingIndex, // Index of currently firing callback (modified by remove if needed) + list = [], // Actual callback list + stack = !options.once && [], // Stack of fire calls for repeatable lists + fire = function(data) { + memory = options.memory && data + fired = true + firingIndex = firingStart || 0 + firingStart = 0 + firingLength = list.length + firing = true + for (; list && firingIndex < firingLength; ++firingIndex) { + if (list[firingIndex].apply(data[0], data[1]) === false && options.stopOnFalse) { + memory = false + break + } + } + firing = false + if (list) { + if (stack) stack.length && fire(stack.shift()) + else if (memory) list.length = 0 + else Callbacks.disable() + } + }, + + Callbacks = { + add: function() { + if (list) { + var start = list.length, + add = function(args) { + $.each(args, function(_, arg) { + if (typeof arg === "function") { + if (!options.unique || !Callbacks.has(arg)) list.push(arg) + } else if (arg && arg.length && typeof arg !== 'string') add(arg) + }) + } + add(arguments) + if (firing) firingLength = list.length + else if (memory) { + firingStart = start + fire(memory) + } + } + return this + }, + remove: function() { + if (list) { + $.each(arguments, function(_, arg) { + var index + while ((index = $.inArray(arg, list, index)) > -1) { + list.splice(index, 1) + // Handle firing indexes + if (firing) { + if (index <= firingLength) --firingLength + if (index <= firingIndex) --firingIndex + } + } + }) + } + return this + }, + has: function(fn) { + return !!(list && (fn ? $.inArray(fn, list) > -1 : list.length)) + }, + empty: function() { + firingLength = list.length = 0 + return this + }, + disable: function() { + list = stack = memory = undefined + return this + }, + disabled: function() { + return !list + }, + lock: function() { + stack = undefined; + if (!memory) Callbacks.disable() + return this + }, + locked: function() { + return !stack + }, + fireWith: function(context, args) { + if (list && (!fired || stack)) { + args = args || [] + args = [context, args.slice ? args.slice() : args] + if (firing) stack.push(args) + else fire(args) + } + return this + }, + fire: function() { + return Callbacks.fireWith(this, arguments) + }, + fired: function() { + return !!fired + } + } + + return Callbacks + }; + + return $; + +}); + + +},this); \ No newline at end of file diff --git a/lib/skylark-jquery/ajax.js b/lib/skylark-jquery/ajax.js deleted file mode 100644 index 2ae200d..0000000 --- a/lib/skylark-jquery/ajax.js +++ /dev/null @@ -1,496 +0,0 @@ -define("skylark-jquery/ajax",[ - "skylark-jquery/core", - "skylark-jquery/deferred" -], function($) { - // zepto.ajax.js - // (c) 2010-2014 Thomas Fuchs - // Zepto.js may be freely distributed under the MIT license. - - 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*$/, - originAnchor = document.createElement('a'); - - originAnchor.href = window.location.href; - - // trigger a custom event and return false if it was cancelled - function triggerAndReturn(context, eventName, data) { - var event = $.Event(eventName) - $(context).trigger(event, data) - return !event.isDefaultPrevented() - } - - // trigger an Ajax "global" event - function triggerGlobal(settings, context, eventName, data) { - if (settings.global) return triggerAndReturn(context || document, eventName, data) - } - - // Number of active Ajax requests - $.active = 0; - - function ajaxStart(settings) { - if (settings.global && $.active++ === 0) triggerGlobal(settings, null, 'ajaxStart') - } - - function ajaxStop(settings) { - if (settings.global && !(--$.active)) triggerGlobal(settings, null, 'ajaxStop') - } - - // triggers an extra global event "ajaxBeforeSend" that's like "ajaxSend" but cancelable - function ajaxBeforeSend(xhr, settings) { - var context = settings.context - if (settings.beforeSend.call(context, xhr, settings) === false || - triggerGlobal(settings, context, 'ajaxBeforeSend', [xhr, settings]) === false) - return false - - triggerGlobal(settings, context, 'ajaxSend', [xhr, settings]) - } - - function ajaxSuccess(data, xhr, settings, deferred) { - var context = settings.context, - status = 'success' - settings.success.call(context, data, status, xhr) - if (deferred) deferred.resolveWith(context, [data, status, xhr]) - triggerGlobal(settings, context, 'ajaxSuccess', [xhr, settings, data]) - ajaxComplete(status, xhr, settings) - } - // type: "timeout", "error", "abort", "parsererror" - function ajaxError(error, type, xhr, settings, deferred) { - var context = settings.context - settings.error.call(context, xhr, type, error) - if (deferred) deferred.rejectWith(context, [xhr, type, error]) - triggerGlobal(settings, context, 'ajaxError', [xhr, settings, error || type]) - ajaxComplete(type, xhr, settings) - } - // status: "success", "notmodified", "error", "timeout", "abort", "parsererror" - function ajaxComplete(status, xhr, settings) { - var context = settings.context - settings.complete.call(context, xhr, status) - triggerGlobal(settings, context, 'ajaxComplete', [xhr, settings]) - ajaxStop(settings) - } - - // Empty function, used as default callback - function empty() {} - - $.ajaxJSONP = function(options, deferred) { - if (!('type' in options)) return $.ajax(options) - - var _callbackName = options.jsonpCallback, - callbackName = ($.isFunction(_callbackName) ? - _callbackName() : _callbackName) || ('jsonp' + (++jsonpID)), - script = document.createElement('script'), - originalCallback = window[callbackName], - responseData, - abort = function(errorType) { - $(script).triggerHandler('error', errorType || 'abort') - }, - xhr = { abort: abort }, - abortTimeout - - if (deferred) deferred.promise(xhr) - - $(script).on('load error', function(e, errorType) { - clearTimeout(abortTimeout) - $(script).off().remove() - - if (e.type == 'error' || !responseData) { - ajaxError(null, errorType || 'error', xhr, options, deferred) - } else { - ajaxSuccess(responseData[0], xhr, options, deferred) - } - - window[callbackName] = originalCallback - if (responseData && $.isFunction(originalCallback)) - originalCallback(responseData[0]) - - originalCallback = responseData = undefined - }) - - if (ajaxBeforeSend(xhr, options) === false) { - abort('abort') - return xhr - } - - window[callbackName] = function() { - responseData = arguments - } - - script.src = options.url.replace(/\?(.+)=\?/, '?$1=' + callbackName) - document.head.appendChild(script) - - if (options.timeout > 0) abortTimeout = setTimeout(function() { - abort('timeout') - }, options.timeout) - - return xhr; - } - - $.ajaxSettings = { - // Default type of request - type: 'GET', - // Callback that is executed before request - beforeSend: empty, - // Callback that is executed if the request succeeds - success: empty, - // Callback that is executed the the server drops error - error: empty, - // Callback that is executed on request complete (both: error and success) - complete: empty, - // The context for the callbacks - context: null, - // Whether to trigger "global" Ajax events - global: true, - // Transport - xhr: function() { - return new window.XMLHttpRequest() - }, - // MIME types mapping - // IIS returns Javascript as "application/x-javascript" - accepts: { - script: 'text/javascript, application/javascript, application/x-javascript', - json: jsonType, - xml: 'application/xml, text/xml', - html: htmlType, - text: 'text/plain' - }, - // Whether the request is to another domain - crossDomain: false, - // Default timeout - timeout: 0, - // Whether data should be serialized to string - processData: true, - // Whether the browser should be allowed to cache GET responses - cache: true - } - - function mimeToDataType(mime) { - if (mime) mime = mime.split(';', 2)[0] - return mime && (mime == htmlType ? 'html' : - mime == jsonType ? 'json' : - scriptTypeRE.test(mime) ? 'script' : - xmlTypeRE.test(mime) && 'xml') || 'text' - } - - function appendQuery(url, query) { - if (query == '') return url - return (url + '&' + query).replace(/[&?]{1,2}/, '?') - } - - // serialize payload and append it to the URL for GET requests - function serializeData(options) { - if (options.processData && options.data && $.type(options.data) != "string") - options.data = $.param(options.data, options.traditional) - if (options.data && (!options.type || options.type.toUpperCase() == 'GET')) - options.url = appendQuery(options.url, options.data), options.data = undefined - } - - $.ajax = function(options) { - var settings = $.extend({}, options || {}), - deferred = $.Deferred && $.Deferred(), - urlAnchor - for (key in $.ajaxSettings) - if (settings[key] === undefined) settings[key] = $.ajaxSettings[key] - - ajaxStart(settings) - - if (!settings.crossDomain) { - urlAnchor = document.createElement('a') - urlAnchor.href = settings.url - urlAnchor.href = urlAnchor.href - settings.crossDomain = (originAnchor.protocol + '//' + originAnchor.host) !== (urlAnchor.protocol + '//' + urlAnchor.host) - } - - if (!settings.url) settings.url = window.location.toString() - serializeData(settings) - - var dataType = settings.dataType, - hasPlaceholder = /\?.+=\?/.test(settings.url) - if (hasPlaceholder) dataType = 'jsonp' - - if (settings.cache === false || ( - (!options || options.cache !== true) && - ('script' == dataType || 'jsonp' == dataType) - )) - settings.url = appendQuery(settings.url, '_=' + Date.now()) - - if ('jsonp' == dataType) { - if (!hasPlaceholder) - settings.url = appendQuery(settings.url, - settings.jsonp ? (settings.jsonp + '=?') : settings.jsonp === false ? '' : 'callback=?') - return $.ajaxJSONP(settings, deferred) - } - - var mime = settings.accepts[dataType], - headers = {}, - setHeader = function(name, value) { headers[name.toLowerCase()] = [name, value] }, - protocol = /^([\w-]+:)\/\//.test(settings.url) ? RegExp.$1 : window.location.protocol, - xhr = settings.xhr(), - nativeSetHeader = xhr.setRequestHeader, - abortTimeout - - if (deferred) deferred.promise(xhr) - - if (!settings.crossDomain) setHeader('X-Requested-With', 'XMLHttpRequest') - setHeader('Accept', mime || '*/*') - if (mime = settings.mimeType || mime) { - if (mime.indexOf(',') > -1) mime = mime.split(',', 2)[0] - xhr.overrideMimeType && xhr.overrideMimeType(mime) - } - if (settings.contentType || (settings.contentType !== false && 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 = false - 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 { - // http://perfectionkills.com/global-eval-what-are-the-options/ - if (dataType == 'script')(1, eval)(result) - else if (dataType == 'xml') result = xhr.responseXML - else if (dataType == 'json') result = blankRE.test(result) ? null : $.parseJSON(result) - } catch (e) { error = e } - - if (error) ajaxError(error, 'parsererror', xhr, settings, deferred) - else ajaxSuccess(result, xhr, settings, deferred) - } else { - ajaxError(xhr.statusText || null, xhr.status ? 'error' : 'abort', xhr, settings, deferred) - } - } - } - - if (ajaxBeforeSend(xhr, settings) === false) { - xhr.abort() - ajaxError(null, 'abort', xhr, settings, deferred) - return xhr - } - - if (settings.xhrFields) - for (name in settings.xhrFields) xhr[name] = settings.xhrFields[name] - - var async = 'async' in settings ? settings.async : true - xhr.open(settings.type, settings.url, async, settings.username, settings.password) - - for (name in headers) nativeSetHeader.apply(xhr, headers[name]) - - if (settings.timeout > 0) abortTimeout = setTimeout(function() { - xhr.onreadystatechange = empty - xhr.abort() - ajaxError(null, 'timeout', xhr, settings, deferred) - }, settings.timeout) - - // avoid sending empty string (#319) - xhr.send(settings.data ? settings.data : null) - return xhr - } - - // handle optional data/success arguments - function parseArguments(url, data, success, dataType) { - if ($.isFunction(data)) dataType = success, success = data, data = undefined - if (!$.isFunction(success)) dataType = success, success = undefined - return { - url: url, - data: data, - success: success, - dataType: dataType - } - } - - $.get = function( /* url, data, success, dataType */ ) { - return $.ajax(parseArguments.apply(null, arguments)) - } - - $.post = function( /* url, data, success, dataType */ ) { - var options = parseArguments.apply(null, arguments) - options.type = 'POST' - return $.ajax(options) - } - - $.getJSON = function( /* url, data, success */ ) { - var options = parseArguments.apply(null, arguments) - options.dataType = 'json' - return $.ajax(options) - } - - $.fn.load = function(url, data, success) { - if (!this.length) return this - var self = this, - parts = url.split(/\s/), - selector, - options = parseArguments(url, data, success), - callback = options.success - if (parts.length > 1) options.url = parts[0], selector = parts[1] - options.success = function(response) { - self.html(selector ? - $('
').html(response.replace(rscript, "")).find(selector) : response) - callback && callback.apply(self, arguments) - } - $.ajax(options) - return this - } - - var escape = encodeURIComponent - - function serialize(params, obj, traditional, scope) { - var type, array = $.isArray(obj), - hash = $.isPlainObject(obj) - $.each(obj, function(key, value) { - type = $.type(value) - if (scope) key = traditional ? scope : - scope + '[' + (hash || type == 'object' || type == 'array' ? key : '') + ']' - // handle data in serializeArray() format - if (!scope && array) params.add(value.name, value.value) - // recurse into nested objects - else if (type == "array" || (!traditional && type == "object")) - serialize(params, value, traditional, key) - else params.add(key, value) - }) - } - - $.param = function(obj, traditional) { - var params = [] - params.add = function(key, value) { - if ($.isFunction(value)) value = value() - if (value == null) value = "" - this.push(escape(key) + '=' + escape(value)) - } - serialize(params, obj, traditional) - return params.join('&').replace(/%20/g, '+') - }; - - var - /* Prefilters - * 1) They are useful to introduce custom dataTypes (see ajax/jsonp.js for an example) - * 2) These are called: - * - BEFORE asking for a transport - * - AFTER param serialization (s.data is a string if s.processData is true) - * 3) key is the dataType - * 4) the catchall symbol "*" can be used - * 5) execution will start with transport dataType and THEN continue down to "*" if needed - */ - prefilters = {}, - - /* Transports bindings - * 1) key is the dataType - * 2) the catchall symbol "*" can be used - * 3) selection will start with transport dataType and THEN go to "*" if needed - */ - transports = {}, - rnotwhite = (/\S+/g); - - - // Base "constructor" for jQuery.ajaxPrefilter and jQuery.ajaxTransport - function addToPrefiltersOrTransports(structure) { - - // dataTypeExpression is optional and defaults to "*" - return function(dataTypeExpression, func) { - - if (typeof dataTypeExpression !== "string") { - func = dataTypeExpression; - dataTypeExpression = "*"; - } - - var dataType, - i = 0, - dataTypes = dataTypeExpression.toLowerCase().match(rnotwhite) || []; - - if (jQuery.isFunction(func)) { - - // For each dataType in the dataTypeExpression - while ((dataType = dataTypes[i++])) { - - // Prepend if requested - if (dataType[0] === "+") { - dataType = dataType.slice(1) || "*"; - (structure[dataType] = structure[dataType] || []).unshift(func); - - // Otherwise append - } else { - (structure[dataType] = structure[dataType] || []).push(func); - } - } - } - }; - } - - $.ajaxPrefilter = addToPrefiltersOrTransports(prefilters); - $.ajaxTransport = addToPrefiltersOrTransports(transports); - - // A special extend for ajax options - // that takes "flat" options (not to be deep extended) - // Fixes #9887 - function ajaxExtend(target, src) { - var key, deep, - flatOptions = jQuery.ajaxSettings.flatOptions || {}; - - for (key in src) { - if (src[key] !== undefined) { - (flatOptions[key] ? target : (deep || (deep = {})))[key] = src[key]; - } - } - if (deep) { - jQuery.extend(true, target, deep); - } - - return target; - } - - // Creates a full fledged settings object into target - // with both ajaxSettings and settings fields. - // If target is omitted, writes into ajaxSettings. - $.ajaxSetup = function(target, settings) { - return settings ? - - // Building a settings object - ajaxExtend(ajaxExtend(target, jQuery.ajaxSettings), settings) : - - // Extending ajaxSettings - ajaxExtend(jQuery.ajaxSettings, target); - }; - - // Base inspection function for prefilters and transports - function inspectPrefiltersOrTransports(structure, options, originalOptions, jqXHR) { - - var inspected = {}, - seekingTransport = (structure === transports); - - function inspect(dataType) { - var selected; - inspected[dataType] = true; - jQuery.each(structure[dataType] || [], function(_, prefilterOrFactory) { - var dataTypeOrTransport = prefilterOrFactory(options, originalOptions, jqXHR); - if (typeof dataTypeOrTransport === "string" && - !seekingTransport && !inspected[dataTypeOrTransport]) { - - options.dataTypes.unshift(dataTypeOrTransport); - inspect(dataTypeOrTransport); - return false; - } else if (seekingTransport) { - return !(selected = dataTypeOrTransport); - } - }); - return selected; - } - - return inspect(options.dataTypes[0]) || !inspected["*"] && inspect("*"); - } - - return $; - -}); diff --git a/lib/skylark-jquery/callbacks.js b/lib/skylark-jquery/callbacks.js deleted file mode 100644 index 2ad9fb9..0000000 --- a/lib/skylark-jquery/callbacks.js +++ /dev/null @@ -1,127 +0,0 @@ -define("skylark-jquery/callbacks",[ - "skylark-jquery/core" -], function($) { - - // This module is borrow from zepto.callback.js - // (c) 2010-2014 Thomas Fuchs - // Zepto.js may be freely distributed under the MIT license. - - // Create a collection of callbacks to be fired in a sequence, with configurable behaviour - // Option flags: - // - once: Callbacks fired at most one time. - // - memory: Remember the most recent context and arguments - // - stopOnFalse: Cease iterating over callback list - // - unique: Permit adding at most one instance of the same callback - $.Callbacks = function(options) { - options = $.extend({}, options) - - var memory, // Last fire value (for non-forgettable lists) - fired, // Flag to know if list was already fired - firing, // Flag to know if list is currently firing - firingStart, // First callback to fire (used internally by add and fireWith) - firingLength, // End of the loop when firing - firingIndex, // Index of currently firing callback (modified by remove if needed) - list = [], // Actual callback list - stack = !options.once && [], // Stack of fire calls for repeatable lists - fire = function(data) { - memory = options.memory && data - fired = true - firingIndex = firingStart || 0 - firingStart = 0 - firingLength = list.length - firing = true - for (; list && firingIndex < firingLength; ++firingIndex) { - if (list[firingIndex].apply(data[0], data[1]) === false && options.stopOnFalse) { - memory = false - break - } - } - firing = false - if (list) { - if (stack) stack.length && fire(stack.shift()) - else if (memory) list.length = 0 - else Callbacks.disable() - } - }, - - Callbacks = { - add: function() { - if (list) { - var start = list.length, - add = function(args) { - $.each(args, function(_, arg) { - if (typeof arg === "function") { - if (!options.unique || !Callbacks.has(arg)) list.push(arg) - } else if (arg && arg.length && typeof arg !== 'string') add(arg) - }) - } - add(arguments) - if (firing) firingLength = list.length - else if (memory) { - firingStart = start - fire(memory) - } - } - return this - }, - remove: function() { - if (list) { - $.each(arguments, function(_, arg) { - var index - while ((index = $.inArray(arg, list, index)) > -1) { - list.splice(index, 1) - // Handle firing indexes - if (firing) { - if (index <= firingLength) --firingLength - if (index <= firingIndex) --firingIndex - } - } - }) - } - return this - }, - has: function(fn) { - return !!(list && (fn ? $.inArray(fn, list) > -1 : list.length)) - }, - empty: function() { - firingLength = list.length = 0 - return this - }, - disable: function() { - list = stack = memory = undefined - return this - }, - disabled: function() { - return !list - }, - lock: function() { - stack = undefined; - if (!memory) Callbacks.disable() - return this - }, - locked: function() { - return !stack - }, - fireWith: function(context, args) { - if (list && (!fired || stack)) { - args = args || [] - args = [context, args.slice ? args.slice() : args] - if (firing) stack.push(args) - else fire(args) - } - return this - }, - fire: function() { - return Callbacks.fireWith(this, arguments) - }, - fired: function() { - return !!fired - } - } - - return Callbacks - }; - - return $; - -}); diff --git a/lib/skylark-jquery/core.js b/lib/skylark-jquery/core.js deleted file mode 100644 index 0b75667..0000000 --- a/lib/skylark-jquery/core.js +++ /dev/null @@ -1,292 +0,0 @@ -define("skylark-jquery/core",[ - "skylark/skylark", - "skylark/langx", - "skylark/noder", - "skylark/datax", - "skylark/eventer", - "skylark/finder", - "skylark/styler", - "skylark/query" -],function(skylark,langx,noder,datax,eventer,finder,styler,query){ - var filter = Array.prototype.filter, - slice = Array.prototype.slice; - - (function($){ - $.fn.jquery = '2.2.0'; - - $.camelCase = langx.camelCase; - - $.each = langx.each; - - $.extend = function(target) { - var deep, args = slice.call(arguments, 1); - if (typeof target == 'boolean') { - deep = target - target = args.shift() - } - if (args.length == 0) { - args = [target]; - target = this; - } - args.forEach(function(arg) { - langx.mixin(target, arg, deep); - }); - return target; - }; - - $.grep = function(elements, callback) { - return filter.call(elements, callback) - }; - - $.isArray = langx.isArray; - $.isEmptyObject = langx.isEmptyObject; - $.isFunction = langx.isFunction; - $.isWindow = langx.isWindow; - $.isPlainObject = langx.isPlainObject; - - $.inArray = langx.inArray; - - $.makeArray = langx.makeArray; - $.map = langx.map; - - $.noop = function() { - }; - - $.parseJSON = window.JSON.parse; - - $.proxy = langx.proxy; - - $.trim = langx.trim; - $.type = langx.type; - - $.fn.extend = function(props) { - langx.mixin($.fn, props); - }; - - $.fn.serializeArray = function() { - var name, type, result = [], - add = function(value) { - if (value.forEach) return value.forEach(add) - result.push({ name: name, value: value }) - } - if (this[0]) langx.each(this[0].elements, function(_, field) { - type = field.type, name = field.name - if (name && field.nodeName.toLowerCase() != 'fieldset' && - !field.disabled && type != 'submit' && type != 'reset' && type != 'button' && type != 'file' && - ((type != 'radio' && type != 'checkbox') || field.checked)) - add($(field).val()) - }) - return result - }; - - $.fn.serialize = function() { - var result = [] - this.serializeArray().forEach(function(elm) { - result.push(encodeURIComponent(elm.name) + '=' + encodeURIComponent(elm.value)) - }) - return result.join('&') - }; - })(query); - - (function($){ - $.Event = function Event(type, props) { - if (type && !langx.isString(type)) { - props = type; - type = props.type; - } - return eventer.create(type, props); - }; - - $.event = {}; - - $.fn.submit = function(callback) { - if (0 in arguments) this.bind('submit', callback) - else if (this.length) { - var event = $.Event('submit') - this.eq(0).trigger(event) - if (!event.isDefaultPrevented()) this.get(0).submit() - } - return this - }; - - // event - $.fn.triggerHandler = $.fn.trigger; - - $.fn.delegate = function(selector, event, callback) { - return this.on(event, selector, callback) - }; - - $.fn.undelegate = function(selector, event, callback) { - return this.off(event, selector, callback) - }; - - $.fn.live = function(event, callback) { - $(document.body).delegate(this.selector, event, callback) - return this - }; - - $.fn.die = function(event, callback) { - $(document.body).undelegate(this.selector, event, callback) - return this - }; - - $.fn.bind = function(event, selector, data, callback) { - return this.on(event, selector, data, callback) - }; - - $.fn.unbind = function(event, callback) { - return this.off(event, callback) - }; - - $.fn.ready = function(callback) { - eventer.ready(callback); - return this; - }; - - $.fn.hover = function(fnOver, fnOut) { - return this.mouseenter(fnOver).mouseleave(fnOut || fnOver); - }; - - $.fn.stop = function() { - // todo - return this; - }; - - $.fn.moveto = function(x, y) { - return this.animate({ - left: x + "px", - top: y + "px" - }, 0.4); - - }; - - $.ready = eventer.ready; - - $.on = eventer.on; - - $.off = eventer.off; - })(query); - - (function($){ - // plugin compatibility - $.uuid = 0; - $.support = {}; - $.expr = {}; - - $.expr[":"] = $.expr.pseudos = $.expr.filters = finder.pseudos; - - $.contains = noder.contains; - - $.css = styler.css; - - $.data = datax.data; - - $.offset = {}; - $.offset.setOffset = function(elem, options, i) { - var position = $.css(elem, "position"); - - // set position first, in-case top/left are set even on static elem - if (position === "static") { - elem.style.position = "relative"; - } - - var curElem = $(elem), - curOffset = curElem.offset(), - curCSSTop = $.css(elem, "top"), - curCSSLeft = $.css(elem, "left"), - calculatePosition = (position === "absolute" || position === "fixed") && $.inArray("auto", [curCSSTop, curCSSLeft]) > -1, - props = {}, - curPosition = {}, - curTop, curLeft; - - // need to be able to calculate position if either top or left is auto and position is either absolute or fixed - if (calculatePosition) { - curPosition = curElem.position(); - curTop = curPosition.top; - curLeft = curPosition.left; - } else { - curTop = parseFloat(curCSSTop) || 0; - curLeft = parseFloat(curCSSLeft) || 0; - } - - if ($.isFunction(options)) { - options = options.call(elem, i, curOffset); - } - - if (options.top != null) { - props.top = (options.top - curOffset.top) + curTop; - } - if (options.left != null) { - props.left = (options.left - curOffset.left) + curLeft; - } - - if ("using" in options) { - options.using.call(elem, props); - } else { - curElem.css(props); - } - }; - })(query); - - (function($){ - /** - * @license Copyright 2013 Enideo. Released under dual MIT and GPL licenses. - * https://github.com/Enideo/zepto-events-special - */ - - $.event.special = $.event.special || {}; - - var bindBeforeSpecialEvents = $.fn.on; - - // $.fn.on = function (eventName, data, callback) { - $.fn.on = function(eventName, selector, data, callback, one) { - if (typeof eventName === "object") return bindBeforeSpecialEvents.apply(this, [eventName, selector, data, callback, one]); - var el = this, - $this = $(el), - specialEvent, - bindEventName = eventName; - - if (callback == null) { - callback = data; - data = null; - } - - $.each(eventName.split(/\s/), function(i, eventName) { - eventName = eventName.split(/\./)[0]; - if ((eventName in $.event.special)) { - specialEvent = $.event.special[eventName]; - bindEventName = specialEvent.bindType || bindEventName; - /// init enable special events on Zepto - if (!specialEvent._init) { - specialEvent._init = true; - /// intercept and replace the special event handler to add functionality - specialEvent.originalHandler = specialEvent.handler || specialEvent.handle; - specialEvent.handler = function() { - /// make event argument writeable, like on jQuery - var args = Array.prototype.slice.call(arguments); - args[0] = $.extend({}, args[0]); - /// define the event handle, $.event.dispatch is only for newer versions of jQuery - $.event.handle = function() { - /// make context of trigger the event element - var args = Array.prototype.slice.call(arguments), - event = args[0], - $target = $(event.target); - $target.trigger.apply($target, arguments); - } - specialEvent.originalHandler.apply(this, args); - } - } - /// setup special events on Zepto - specialEvent.setup && specialEvent.setup.apply(el, [data]); - } - }); - - return bindBeforeSpecialEvents.apply(this, [bindEventName, selector, data, callback, one]); - - }; - })(query); - - query.skylark = skylark; - - return window.jQuery = window.$ = query; -}); \ No newline at end of file diff --git a/lib/skylark-jquery/deferred.js b/lib/skylark-jquery/deferred.js deleted file mode 100644 index ed92ee5..0000000 --- a/lib/skylark-jquery/deferred.js +++ /dev/null @@ -1,131 +0,0 @@ -define("skylark-jquery/deferred",[ - "skylark-jquery/core" -], function($) { - - /* - (function ($) { - $.Deferred = async.Deferred; - $.when = async.when; - })(Zepto); - */ - - // This module is borrow from zepto.deferred.js - // (c) 2010-2014 Thomas Fuchs - // Zepto.js may be freely distributed under the MIT license. - // - // Some code (c) 2005, 2013 jQuery Foundation, Inc. and other contributors - - var slice = Array.prototype.slice - - function Deferred(func) { - var tuples = [ - // action, add listener, listener list, final state - ["resolve", "done", $.Callbacks({ once: 1, memory: 1 }), "resolved"], - ["reject", "fail", $.Callbacks({ once: 1, memory: 1 }), "rejected"], - ["notify", "progress", $.Callbacks({ memory: 1 })] - ], - state = "pending", - promise = { - state: function() { - return state - }, - always: function() { - deferred.done(arguments).fail(arguments) - return this - }, - then: function( /* fnDone [, fnFailed [, fnProgress]] */ ) { - var fns = arguments - return Deferred(function(defer) { - $.each(tuples, function(i, tuple) { - var fn = $.isFunction(fns[i]) && fns[i] - deferred[tuple[1]](function() { - var returned = fn && fn.apply(this, arguments) - if (returned && $.isFunction(returned.promise)) { - returned.promise() - .done(defer.resolve) - .fail(defer.reject) - .progress(defer.notify) - } else { - var context = this === promise ? defer.promise() : this, - values = fn ? [returned] : arguments - defer[tuple[0] + "With"](context, values) - } - }) - }) - fns = null - }).promise() - }, - - promise: function(obj) { - return obj != null ? $.extend(obj, promise) : promise - } - }, - deferred = {} - - $.each(tuples, function(i, tuple) { - var list = tuple[2], - stateString = tuple[3] - - promise[tuple[1]] = list.add - - if (stateString) { - list.add(function() { - state = stateString - }, tuples[i ^ 1][2].disable, tuples[2][2].lock) - } - - deferred[tuple[0]] = function() { - deferred[tuple[0] + "With"](this === deferred ? promise : this, arguments) - return this - } - deferred[tuple[0] + "With"] = list.fireWith - }) - - promise.promise(deferred) - if (func) func.call(deferred, deferred) - return deferred - } - - $.when = function(sub) { - var resolveValues = slice.call(arguments), - len = resolveValues.length, - i = 0, - remain = len !== 1 || (sub && $.isFunction(sub.promise)) ? len : 0, - deferred = remain === 1 ? sub : Deferred(), - progressValues, progressContexts, resolveContexts, - updateFn = function(i, ctx, val) { - return function(value) { - ctx[i] = this - val[i] = arguments.length > 1 ? slice.call(arguments) : value - if (val === progressValues) { - deferred.notifyWith(ctx, val) - } else if (!(--remain)) { - deferred.resolveWith(ctx, val) - } - } - } - - if (len > 1) { - progressValues = new Array(len) - progressContexts = new Array(len) - resolveContexts = new Array(len) - for (; i < len; ++i) { - if (resolveValues[i] && $.isFunction(resolveValues[i].promise)) { - resolveValues[i].promise() - .done(updateFn(i, resolveContexts, resolveValues)) - .fail(deferred.reject) - .progress(updateFn(i, progressContexts, progressValues)) - } else { - --remain - } - } - } - if (!remain) deferred.resolveWith(resolveContexts, resolveValues) - return deferred.promise() - } - - $.Deferred = Deferred - - return $; - -}); diff --git a/lib/skylark/async.js b/lib/skylark/async.js deleted file mode 100644 index d949352..0000000 --- a/lib/skylark/async.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/async" -], function(async) { - return async; -}); diff --git a/lib/skylark/browser.js b/lib/skylark/browser.js deleted file mode 100644 index 8def9d5..0000000 --- a/lib/skylark/browser.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/browser" -], function(browser) { - return browser; -}); diff --git a/lib/skylark/css.js b/lib/skylark/css.js deleted file mode 100644 index 73b3ffb..0000000 --- a/lib/skylark/css.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/css" -], function(css) { - return css; -}); diff --git a/lib/skylark/datax.js b/lib/skylark/datax.js deleted file mode 100644 index 412347a..0000000 --- a/lib/skylark/datax.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/datax" -], function(datax) { - return datax; -}); diff --git a/lib/skylark/dnd.js b/lib/skylark/dnd.js deleted file mode 100644 index 2c37cb0..0000000 --- a/lib/skylark/dnd.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/dnd" -], function(dnd) { - return dnd; -}); diff --git a/lib/skylark/eventer.js b/lib/skylark/eventer.js deleted file mode 100644 index 1396a27..0000000 --- a/lib/skylark/eventer.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/eventer" -], function(eventer) { - return eventer; -}); diff --git a/lib/skylark/filer.js b/lib/skylark/filer.js deleted file mode 100644 index ad124cb..0000000 --- a/lib/skylark/filer.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/filer" -], function(filer) { - return filer; -}); diff --git a/lib/skylark/finder.js b/lib/skylark/finder.js deleted file mode 100644 index 6b09ac2..0000000 --- a/lib/skylark/finder.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/finder" -], function(finder) { - return finder; -}); diff --git a/lib/skylark/fx.js b/lib/skylark/fx.js deleted file mode 100644 index 2529e1e..0000000 --- a/lib/skylark/fx.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/fx" -], function(fx) { - return fx; -}); diff --git a/lib/skylark/geom.js b/lib/skylark/geom.js deleted file mode 100644 index ef32ce0..0000000 --- a/lib/skylark/geom.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/geom" -], function(geom) { - return geom; -}); diff --git a/lib/skylark/langx.js b/lib/skylark/langx.js deleted file mode 100644 index dd1c6b1..0000000 --- a/lib/skylark/langx.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/langx" -], function(langx) { - return langx; -}); diff --git a/lib/skylark/main.js b/lib/skylark/main.js deleted file mode 100644 index 86537cd..0000000 --- a/lib/skylark/main.js +++ /dev/null @@ -1,24 +0,0 @@ -define([ - "./skylark", - "./async", - "./browser", - "./css", - "./datax", - "./dnd", - "./eventer", - "./filer", - "./finder", - "./fx", - "./geom", - "./mover", - "./noder", - "./query", - "./router", - "./scripter", - "./spa", - "./styler", - "./langx", - "./velm" -], function(skylark) { - return skylark; -}) diff --git a/lib/skylark/mover.js b/lib/skylark/mover.js deleted file mode 100644 index e7a9e3d..0000000 --- a/lib/skylark/mover.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/mover" -], function(mover) { - return mover; -}); diff --git a/lib/skylark/noder.js b/lib/skylark/noder.js deleted file mode 100644 index f65676d..0000000 --- a/lib/skylark/noder.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/noder" -], function(noder) { - return noder; -}); diff --git a/lib/skylark/query.js b/lib/skylark/query.js deleted file mode 100644 index d1c006b..0000000 --- a/lib/skylark/query.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/query" -], function(query) { - return query; -}); diff --git a/lib/skylark/router.js b/lib/skylark/router.js deleted file mode 100644 index 5c9cbcb..0000000 --- a/lib/skylark/router.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-router/router" -], function(router) { - return router; -}); diff --git a/lib/skylark/scripter.js b/lib/skylark/scripter.js deleted file mode 100644 index aa9b5a6..0000000 --- a/lib/skylark/scripter.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/scripter" -], function(scripter) { - return scripter; -}); diff --git a/lib/skylark/skylark.js b/lib/skylark/skylark.js deleted file mode 100644 index a450078..0000000 --- a/lib/skylark/skylark.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/skylark" -], function(skylark) { - return skylark; -}); diff --git a/lib/skylark/spa.js b/lib/skylark/spa.js deleted file mode 100644 index ca4254a..0000000 --- a/lib/skylark/spa.js +++ /dev/null @@ -1,311 +0,0 @@ -define([ - "skylark-utils/skylark", - "skylark-utils/langx", - "skylark-utils/eventer", - "skylark-router/router", - "skylark-utils/velm", - "skylark-utils/finder", - "skylark-utils/noder", - "skylark-utils/async" -], function(skylark, langx, eventer, router, velm, finder, noder, async) { - var Deferred = async.Deferred; - - var Route = router.Route = router.Route.inherit({ - klassName: "SpaRoute", - - init: function(name, setting) { - this.overrided(name, setting); - this.content = setting.content; - this.data = setting.data; - //this.lazy = !!setting.lazy; - var self = this; - ["preparing", "rendering", "rendered"].forEach(function(eventName) { - if (langx.isFunction(setting[eventName])) { - self.on(eventName, setting[eventName]); - } - }); - }, - - _entering: function(ctx) { - if (!this._prepared) { - return this.prepare(); - } - return this; - }, - - getConfigData: function(key) { - return key ? this.data[key] : this.data; - }, - - prepare: function() { - var d = new Deferred(), - setting = this._setting, - controllerSetting = setting.controller, - controller = this.controller, - - self = this, - content = setting.content, - contentPath = setting.contentPath; - - if (controllerSetting && !controller) { - require([controllerSetting.type], function(type) { - controller = self.controller = new type(controllerSetting); - d.resolve(); - }); - } else { - d.resolve(); - } - - return d.then(function() { - var e = eventer.create("preparing", { - route: self, - result: true - }); - eventer.trigger(self, e); - - return Deferred.when(e.result).then(function() { - eventer.trigger(router.hub(), "prepared", { - route: self - }); - self._prepared = true; - }); - }); - }, - - render: function(ctx) { - var e = eventer.create("rendering", { - route: this, - context: ctx, - content: this.content - }); - eventer.trigger(this, e); - return e.content; - }, - - trigger: function(e) { - var controller = this.controller; - if (controller) { - return controller.perform(e); - } else { - return this.overrided(e); - } - } - }); - - var RouteController = langx.klass({ - klassName: "SpaRouteController", - - init: function(route, setting) { - setting = setting || {}; - this.content = setting.content; - this.data = setting.data; - }, - - getConfigData: function(key) { - return key ? this.data[key] : this.data; - }, - - perform: function(e) { - var eventName = e.type; - if (this[eventName]) { - return this[eventName].call(this, e); - } - - } - }); - - var Page = langx.klass({ - klassName: "SpaPage", - - init: function(params) { - params = langx.mixin({ - "routeViewer": "body" - }, params); - - this._params = params; - this._$rvc = velm.find(params.routeViewer); - this._router = router; - - router.on("routing", langx.proxy(this, "refresh")); - }, - - prepare: function() { - - }, - - //Refreshes the route - refresh: function() { - var curCtx = router.current(), - prevCtx = router.previous(); - this._$rvc.html(curCtx.route.render(curCtx)); - //eventer.trigger(curCtx.route, "rendered", { - // route: curCtx.route, - // node: this._$rvc.domNode - //}); - } - }); - - var Plugin = langx.klass({ - klassName: "SpaPlugin", - - init: function(name, setting) { - this.name = name; - this._setting = setting; - }, - - prepare: function() { - var d = new Deferred(), - setting = this._setting, - controllerSetting = setting.controller, - controller = this.controller, - self = this; - - if (controllerSetting && !controller) { - require([controllerSetting.type], function(type) { - controller = self.controller = new type(controllerSetting); - router.on(setting.hookers, { - plugin: self - }, langx.proxy(controller.perform, controller)); - d.resolve(); - }); - } else { - langx.each(setting.hookers, function(eventName, hooker) { - router.on(eventName, { - plugin: self - }, hooker); - }); - d.resolve(); - } - - return d.then(function() { - var e = eventer.create("preparing", { - result: true - }); - eventer.trigger(self, e); - return Deferred.when(e.result).then(function() { - self._prepared = true; - }); - }); - }, - - trigger: function(type, props) { - eventer.trigger(new langx.Evented(), type, props); - return this; - } - }); - - var PluginController = langx.klass({ - klassName: "SpaPluginController", - - init: function(plugin) { - this.plugin = plugin; - }, - - perform: function(e) { - var eventName = e.type; - if (this[eventName]) { - return this[eventName].call(this, e); - } - - } - }); - - var Application = langx.Evented.inherit({ - klassName: "SpaApplication", - - init: function(config) { - if (app) { - return app; - } - var plugins = this._plugins = {}; - - config = this._config = langx.mixin({ - plugins: {} - }, config, true); - - langx.each(config.plugins, function(pluginName, setting) { - plugins[pluginName] = new Plugin(pluginName, setting); - }); - - router.routes(config.routes); - - this._router = router; - - this._page = new spa.Page(config.page); - - document.title = config.title; - var baseUrl = config.baseUrl; - if (baseUrl === undefined) { - baseUrl = config.baseUrl = require.toUrl(""); - } - router.baseUrl(baseUrl); - - if (config.homePath) { - router.homePath(config.homePath); - } - - app = this; - }, - - getConfig: function(key) { - return key ? this._config[key] : this._config; - }, - - go: function(path) { - router.go(path); - return this; - }, - - page: function() { - return this._page; - }, - - prepare: function() { - var self = this; - var promises1 = langx.map(router.routes(), function(route, name) { - if (route.lazy === false) { - return route.prepare(); - } - }), - promises2 = langx.map(this._plugins, function(plugin, name) { - return plugin.prepare(); - }); - - - return Deferred.all(promises1.concat(promises2)).then(function() { - return eventer.trigger(router, "starting", { - spa: self - }); - }); - }, - - run: function() { - this._router.start(); - } - }); - - var app; - var spa = function(config) { - if (!app) { - window[config.name || "app"] = app = new spa.Application(config); - } - - return app; - } - - langx.mixin(spa, { - "Application": Application, - - "Page": Page, - - "Plugin": Plugin, - "PluginController": PluginController, - - "Route": Route, - "RouteController": RouteController, - - "velm": velm - }); - - return skylark.spa = spa; -}); diff --git a/lib/skylark/styler.js b/lib/skylark/styler.js deleted file mode 100644 index 00b6d06..0000000 --- a/lib/skylark/styler.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/styler" -], function(styler) { - return styler; -}); diff --git a/lib/skylark/velm.js b/lib/skylark/velm.js deleted file mode 100644 index 924372d..0000000 --- a/lib/skylark/velm.js +++ /dev/null @@ -1,5 +0,0 @@ -define([ - "skylark-utils/velm" -], function(velm) { - return velm; -}); diff --git a/lib/skylarkjs-all.min.js b/lib/skylarkjs-all.min.js deleted file mode 100644 index 9490c5d..0000000 --- a/lib/skylarkjs-all.min.js +++ /dev/null @@ -1,11 +0,0 @@ -/** - * skylarkjs - An Elegant JavaScript Library and HTML5 Application Framework. - * @author Hudaokeji Co.,Ltd - * @version v0.9.0 - * @link www.skylarkjs.org - * @license MIT - */ -!function(e,t){function n(e,t){if("."!==e[0])return e;var n=t.split("/"),r=e.split("/");n.pop();for(var i=0;i1&&t[1].split("&").forEach(function(e){var t=e.split("=");n[t[0]]=t[1]}),n}function u(e,t){if(!t)return-1;var n;if(t.indexOf)return t.indexOf(e);for(n=t.length;n--;)if(t[n]===e)return n;return-1}function l(e){return e instanceof Array}function c(e){return!v(e)&&"number"==typeof e.length}function f(e){return"boolean"==typeof e}function h(e){return null!=e&&e.nodeType==e.DOCUMENT_NODE}function d(e){return"function"==W(e)}function p(e){return"object"==W(e)}function g(e){return p(e)&&!m(e)&&Object.getPrototypeOf(e)==Object.prototype}function v(e){return"string"==typeof e}function m(e){return e&&e==e.window}function y(e){return"undefined"!=typeof e}function k(e){return"number"==typeof e}function b(e){if(e){var t=location.protocol+"//"+location.hostname;return location.port&&(t+=":"+location.port),e.startsWith(t)}}function w(e){var t;for(t in e)if(null!==e[t])return!1;return!0}function x(e,t,n){return(n||[]).concat(Array.prototype.slice.call(e,t||0))}function C(e,t){var n,r,i,a=[];if(c(e))for(r=0;r0},listenTo:function(e,t,n,r){if(!e)return this;v(n)&&(n=this[n]),r?e.one(t,n,this):e.on(t,n,this);for(var i,o=this._listeningTo||(this._listeningTo=[]),a=0;a1?t?t(e):e:(new o).resolve(e);if(!a){var s=new o(e.cancel);e.then(s.resolve,s.reject,s.progress),e=s.promise}return t||n||r?e.then(t,n,r):e},o.reject=function(e){var t=new o;return t.reject(e),t.promise},o.resolve=function(e){var t=new o;return t.resolve(e),t.promise},o.immediate=o.resolve,t.mixin(i,{all:o.all,debounce:n,Deferred:o,first:o.first,nextTick:r,reject:o.reject,resolve:o.resolve,when:o.when}),e.async=i}),e("skylarkjs/async",["skylark-utils/async"],function(e){return e}),e("skylark-utils/browser",["./skylark","./langx"],function(e,t){function n(e){return c?c+e:e.toLowerCase()}function r(e){return h[e]||e}function i(e){return f[e]||e}function o(){return o}var a,s,u="",l="",c="",f={},h={},d=/^(Webkit|webkit|O|Moz|moz|ms)(.*)$/,p=window.document,g=p.createElement("div"),v=g.webkitMatchesSelector||g.mozMatchesSelector||g.oMatchesSelector||g.matchesSelector,m=g.style;for(var y in m){var k=y.match(s||d);if(k){s||(a=k[1],s=new RegExp("^("+a+")(.*)$"),l=a,u="-"+a.toLowerCase()+"-",c=a.toLowerCase()),f[t.lowerFirst(k[2])]=y;var b=t.dasherize(k[2]);h[b]=u+b}}return t.mixin(o,{css3PropPrefix:u,normalizeStyleProperty:i,normalizeCssProperty:r,normalizeCssEvent:n,matchesSelector:v,location:function(){return window.location}}),g=null,e.browser=o}),e("skylarkjs/browser",["skylark-utils/browser"],function(e){return e}),e("skylark-utils/noder",["./skylark","./langx"],function(e,t){function n(e,n){return t.isArrayLike(e)||(e=[e]),n&&(e=$.call(e,function(e){return e.cloneNode(!0)})),e}function r(e,t){var n=e.nodeName&&e.nodeName.toLowerCase();return void 0!==t?n===t.toLowerCase():n}function i(e){return r(e,"iframe")?e.contentDocument:e.childNodes}function o(e,n){if(void 0===n)return e.innerHTML;if(this.empty(e),n=n||"",t.isString(n)||t.isNumber(n))e.innerHTML=n;else if(t.isArrayLike(n))for(var r=0;r0;n--)if(n>0){var r=e.children[n];e.insertBefore(r,t)}}function S(e,n){t.isString(n)&&(n=this.createFragment(n).firstChild),e.parentNode.insertBefore(n,e),n.appendChild(e)}function T(e,t){var n=F.call(e.childNodes);e.appendChild(t);for(var r=0;r]*>/,O=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,j=document.createElement("div"),R=document.createElement("table"),D=document.createElement("tbody"),z=document.createElement("tr"),L={tr:D,tbody:R,thead:R,tfoot:R,td:z,th:z,"*":j},$=Array.prototype.map,F=Array.prototype.slice;return t.mixin(A,{clone:a,contents:i,createElement:s,createFragment:u,contains:l,createTextNode:c,doc:f,empty:h,html:o,isChildOf:d,isDoc:p,ownerDoc:g,after:v,before:m,prepend:y,append:k,remove:b,replace:w,throb:x,traverse:C,reverse:E,wrapper:S,wrapperInner:T,unwrap:_}),e.noder=A}),e("skylark-utils/css",["./skylark","./langx","./noder"],function(e,t,n){function r(){var e=document.createElement("link"),t=s++;return e.rel="stylesheet",e.type="text/css",e.async=!1,e.defer=!1,a.appendChild(e),l[t]=e,t}function i(){return i}var o,a=document.getElementsByTagName("head")[0],s=0,u={},l={},c=r(),f=l[c],h="cssRules"in f?"cssRules":"rules",d=f.deleteRule||f.removeRule;if(f.insertRule){var p=f.insertRule;o=function(e,t,n){p.call(this,e+"{"+t+"}",n)}}else o=f.addRule;return t.mixin(i,{createStyleSheet:function(e){return r()},loadStyleSheet:function(e,t,n){var i=u[e];if(i||(i=u[e]={state:0,loadedCallbacks:[],errorCallbacks:[]}),i.loadedCallbacks.push(t),i.errorCallbacks.push(n),1===i.state)i.node.onload();else if(i.state===-1)i.node.onerror();else{i.id=r();var o=i.node=l[i.id];startTime=(new Date).getTime(),o.onload=function(){i.state=1,i.state=-1;for(var e=i.loadedCallbacks,t=e.length;t--;)e[t]();i.loadedCallbacks=[],i.errorCallbacks=[]},o.onerror=function(){i.state=-1;for(var e=i.errorCallbacks,t=e.length;t--;)e[t]();i.loadedCallbacks=[],i.errorCallbacks=[]},o.href=i.url=e,u[o.url]=i}return i.id},deleteSheetRule:function(e,n){var r=l[e];t.isNumber(n)?d.call(r,n):t.each(r[h],function(e,t){if(n===t)return d.call(r,e),!1})},deleteRule:function(e){return this.deleteSheetRule(c,e),this},removeStyleSheet:function(e){if(e===c)throw new Error("The default stylesheet can not be deleted");var t=l[e];return delete l[e],n.remove(t),this},findRules:function(e,t){var n=[],r=parseSelector(e);return $(document.styleSheets).each(function(e,t){filterStyleSheet(r.styleSheet,t)&&$.merge(n,$(t[_rules]).filter(function(){return matchSelector(this,r.selectorText,"*"===r.styleSheet)}).map(function(){return normalizeRule($.support.nativeCSSStyleRule?this:new CSSStyleRule(this),t)}))}),n.reverse()},insertRule:function(e,t,n){return this.insertSheetRule(c,e,t,n)},insertSheetRule:function(e,t,n,r){if(!t||!n)return-1;var i=l[e];return r=r||i[h].length,o.call(i,t,n,r)}}),e.css=i}),e("skylarkjs/css",["skylark-utils/css"],function(e){return e}),e("skylark-utils/finder",["./skylark","./langx","./browser","./noder"],function(e,t,n,r,i){function o(e,t,n){for(;e=e.parentNode;){if(v(e,t))return e;if(e==n)break}return null}function a(e,t){for(var n=[];(e=e.parentNode)&&(v(e,t)&&n.push(e),e!=n););return n}function s(e,t){return t=t||r.doc(),t.getElementById(e)}function u(e,t){for(var n=e.childNodes,r=[],i=0;i0?r[0]:null}function h(e){return f(document.body,e)}function d(e){return c(document.body,e)}function p(e,t,n){for(var r=e.childNodes,i=r[0];i;){if(1==i.nodeType){if(!t||v(i,t))return i;if(n)break}i=i.nextSibling}return null}function g(e,t,n){for(var r=e.childNodes,i=r[r.length-1];i;){if(1==i.nodeType){if(!t||v(i,t))return i;if(n)break}i=i.previousSibling}return null}function v(e,n){if(!n||!e||1!==e.nodeType)return!1;if(t.isString(n)){try{return T.call(e,n.replace(/\[([^=]+)=\s*([^'"\]]+?)\s*\]/g,'[$1="$2"]'))}catch(r){}return C.match(e,n)}return C.check(e,n)}function m(e,t,n){for(var r=e.nextSibling;r;){if(1==r.nodeType){if(!t||v(r,t))return r;if(n)break}r=r.nextSibling}return null}function y(e,t){for(var n=e.nextSibling,r=[];n;)1==n.nodeType&&(t&&!v(n,t)||r.push(n)),n=n.nextSibling;return r}function k(e,t){var n=e.parentNode;return!n||t&&!v(n,t)?null:n}function b(e,t,n){for(var r=e.previousSibling;r;){if(1==r.nodeType){if(!t||v(r,t))return r;if(n)break}r=r.previousSibling}return null}function w(e,t){for(var n=e.previousSibling,r=[];n;)1==n.nodeType&&(t&&!v(n,t)||r.push(n)),n=n.previousSibling;return r}function x(e,t){for(var n=e.parentNode.firstChild,r=[];n;)1==n.nodeType&&n!==e&&(t&&!v(n,t)||r.push(n)),n=n.nextSibling;return r}var C={},E=Array.prototype.filter,S=Array.prototype.slice,T=n.matchesSelector;(function(){function e(e,o,a,u,c,h,d,p,g,v,m,y,k,b,w,x){if((o||n===-1)&&(t.expressions[++n]=[],r=-1,o))return"";if(a||u||r===-1){a=a||" ";var C=t.expressions[n];i&&C[r]&&(C[r].reverseCombinator=l(a)),C[++r]={combinator:a,tag:"*"}}var E=t.expressions[n][r];if(c)E.tag=c.replace(s,"");else if(h)E.id=h.replace(s,"");else if(d)d=d.replace(s,""),E.classList||(E.classList=[]),E.classes||(E.classes=[]),E.classList.push(d),E.classes.push({value:d,regexp:new RegExp("(^|\\s)"+f(d)+"(\\s|$)")});else if(k)x=x||w,x=x?x.replace(s,""):null,E.pseudos||(E.pseudos=[]),E.pseudos.push({key:k.replace(s,""),value:x,type:1==y.length?"class":"element"});else if(p){p=p.replace(s,""),m=(m||"").replace(s,"");var S,T;switch(g){case"^=":T=new RegExp("^"+f(m));break;case"$=":T=new RegExp(f(m)+"$");break;case"~=":T=new RegExp("(^|\\s)"+f(m)+"(\\s|$)");break;case"|=":T=new RegExp("^"+f(m)+"(-|$)");break;case"=":S=function(e){return m==e};break;case"*=":S=function(e){return e&&e.indexOf(m)>-1};break;case"!=":S=function(e){return m!=e};break;default:S=function(e){return!!e}}""==m&&/^[*$^]=$/.test(g)&&(S=function(){return!1}),S||(S=function(e){return e&&T.test(e)}),E.attributes||(E.attributes=[]),E.attributes.push({key:p,operator:g,value:m,test:S})}return""}var t,n,r,i,o={},a={},s=/\\/g,u=function(r,s){if(null==r)return null;if(r.Slick===!0)return r;r=(""+r).replace(/^\s+|\s+$/g,""),i=!!s;var l=i?a:o;if(l[r])return l[r];for(t={Slick:!0,expressions:[],raw:r,reverse:function(){return u(this.raw,!0)}},n=-1;r!=(r=r.replace(h,e)););return t.length=t.expressions.length,l[t.raw]=i?c(t):t},l=function(e){return"!"===e?" ":" "===e?"!":/^!/.test(e)?e.replace(/^!/,""):"!"+e},c=function(e){for(var t=e.expressions,n=0;n+)\\s*|(\\s+)|(+|\\*)|\\#(+)|\\.(+)|\\[\\s*(+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)".replace(//,"["+f(">+~`!@$%^&={}\\;/g,"(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])").replace(//g,"(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])")),d=this.Slick||{};d.parse=function(e){return u(e)},d.escapeRegExp=f,this.Slick||(this.Slick=d)}).apply(C);var S=Array.prototype.slice;C.parseSelector=C.Slick.parse,C.pseudos={checked:function(e){return!!e.checked},contains:function(e,t,n,r){if($(this).text().indexOf(r)>-1)return this},disabled:function(e){return!!e.disabled},enabled:function(e){return!e.disabled},eq:function(e,t,n,r){return t===r},focus:function(e){return document.activeElement===e&&(e.href||e.type||e.tabindex)},first:function(e,t){return 0===t},has:function(e,t,n,r){return C.querySelector(e,r).length>0},hidden:function(e){return!C.pseudos.visible(e)},last:function(e,t,n){return t===n.length-1},parent:function(e){return!!e.parentNode},selected:function(e){return!!e.selected},visible:function(e){return e.offsetWidth&&e.offsetWidth}},C.divide=function(e){var t,n,r,i,o,a="",s=[];if((n=e.id)&&(a+="#"+n),r=e.classes)for(var u=r.length;u--;)a+="."+r[u].value;if(i=e.attributes)for(var u=0;u":o=u(e,i);break;case"+":n=m(e,i,!0),n&&o.push(n);break;case"^":n=p(e,i,!0),n&&o.push(n);break;case"~":o=y(e,i);break;case"++":var s=b(e,i,!0),l=m(e,i,!0);s&&o.push(s),l&&o.push(l);break;case"~~":o=x(e,i);break;case"!":o=a(e,i);break;case"!>":n=k(e,i),n&&o.push(n);break;case"!+":o=b(e,i,!0);break;case"!^":n=g(e,i,!0),n&&o.push(n);break;case"!~":o=w(e,i);break;default:var c=this.divide(t);if(o=S.call(e.querySelectorAll(c.nativeSelector)),c.customPseudos)for(var f=c.customPseudos.length-1;f>=0;f--)o=E.call(o,function(e,t){return C.check(e,{pseudos:[c.customPseudos[f]]},t,o)})}return o},C.query=function(e,n,r){for(var i,o,a=this.Slick.parse(n),s=[],u=a.expressions,l=0;i=u[l];l++){for(var c,f=[e],h=0;o=i[h];h++)c=t.map(f,function(e,t){return C.combine(e,o)}),c&&(f=c);c&&(s=s.concat(c))}return s};var _=function(){return _};return t.mixin(_,{ancestor:o,ancestors:a,byId:s,children:u,closest:l,descendant:f,descendants:c,find:h,findAll:d,firstChild:p,lastChild:g,matches:v,nextSibling:m,nextSiblings:y,parent:k,previousSibling:b,previousSiblings:w,pseudos:C.pseudos,siblings:x}),e.finder=_}),e("skylark-utils/datax",["./skylark","./langx","./finder"],function(e,t,n){function r(e,t,n){null==n?e.removeAttribute(t):e.setAttribute(t,n)}function i(e,t,n){if(void 0!==n)return e.setAttribute(t,n),this;if("object"==typeof t){for(var r in t)i(e,r,t[r]);return this}return e.hasAttribute(t)?e.getAttribute(t):void 0}function o(e){var n={};return t.each(e.attributes||[],function(e,t){0==t.name.indexOf("data-")&&(n[k(t.name.replace("data-",""))]=b(t.value))}),n}function a(e,t){var n=e._$_store;return!n&&t&&(n=e._$_store=o(e)),n}function s(e,t){if(void 0===t)return a(e,!0);var n=a(e);if(n){if(t in n)return n[t];var r=k(t);if(r in n)return n[r]}var o="data-"+t.replace(w,"-$1").toLowerCase();return i(e,o)}function u(e,t,n){var r=a(e,!0);r[k(t)]=n}function l(e,t,n){if(void 0===n){if("object"==typeof t){for(var r in t)u(e,r,t[r]);return this}return s(e,t)}return u(e,t,n),this}function c(e,n){t.isString(n)&&(n=n.split(/\s+/));var r=a(e,!0);return n.forEach(function(e){delete r[e]}),this}function f(e,t){return m.call(e,function(e){return e[t]})}function h(e,t,n){return t=x[t]||t,void 0===n?e[t]:(e[t]=n,this)}function d(e,t){return t.split(" ").forEach(function(t){r(e,t)}),this}function p(e,t){return void 0===t?e.textContent:(e.textContent=null==t?"":""+t,this)}function g(e,t){if(void 0===t){if(e.multiple){var r=y.call(n.find(e,"option"),function(e){return e.selected});return f(r,"value")}return e.value}return e.value=t,this}function v(){return v}var m=Array.prototype.map,y=Array.prototype.filter,k=t.camelCase,b=t.deserializeValue,w=/([A-Z])/g,x={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 t.mixin(v,{attr:i,data:l,pluck:f,prop:h,removeAttr:d,removeData:c,text:p,val:g}),e.datax=v}),e("skylarkjs/datax",["skylark-utils/datax"],function(e){return e}),e("skylark-utils/styler",["./skylark","./langx"],function(e,t){function n(e,t){return"number"!=typeof t||m[v(e)]?t:t+"px"}function r(e){return e in y?y[e]:y[e]=new RegExp("(^|\\s)"+e+"(\\s|$)")}function i(e,t){var n=e.className||"",r=n&&void 0!==n.baseVal;return void 0===t?r?n.baseVal:n:void(r?n.baseVal=t:e.className=t)}function o(e){var t,n;return k[e]||(t=document.createElement(e),document.body.appendChild(t),n=getComputedStyle(t,"").getPropertyValue("display"),t.parentNode.removeChild(t),"none"==n&&(n="block"),k[e]=n),k[e]}function a(e){return b.css(e,"display",""),"none"==b.css(e,"display")&&b.css(e,"display",o(e.nodeName)),this}function s(e){return"none"==b.css(e,"display")||0==b.css(e,"opacity")}function u(e){return b.css(e,"display","none"),this}function l(e,n){if(!n)return this;var o,a=i(e);return o=t.isString(n)?n.split(/\s+/g):n,o.forEach(function(e){var t=r(e);a.match(t)||(a+=(a?" ":"")+e)}),i(e,a),this}function c(e,r,i){if(arguments.length<3){var o,o=getComputedStyle(e,"");if(t.isString(r))return e.style[g(r)]||o.getPropertyValue(r);if(t.isArrayLike(r)){var a={};return p.call(r,function(t){a[t]=e.style[g(t)]||o.getPropertyValue(t)}),a}}var s="";if("string"==typeof r)i||0===i?s=v(r)+":"+n(r,i):e.style.removeProperty(v(r));else for(key in r)void 0!==r[key]&&(r[key]||0===r[key]?s+=v(key)+":"+n(key,r[key])+";":e.style.removeProperty(v(key)));return e.style.cssText+=";"+s,this}function f(e,t){var n=r(t);return e.className&&e.className.match(n)}function h(e,n){var o,a=i(e);return o=t.isString(n)?n.split(/\s+/g):n,o.forEach(function(e){var t=r(e);a.match(t)&&(a=a.replace(t," "))}),i(e,a.trim()),this}function d(e,t,n){var r=this;return t.split(/\s+/g).forEach(function(t){void 0===n&&(n=!r.hasClass(e,t)),n?r.addClass(e,t):r.removeClass(e,t)}),r}var p=(Array.prototype.every,Array.prototype.forEach),g=t.camelCase,v=t.dasherize,m={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},y={},k={},b=function(){return b};return t.mixin(b,{autocssfix:!0,addClass:l,className:i,css:c,hasClass:f,hide:u,isInvisible:s,removeClass:h,show:a,toggleClass:d}),e.styler=b}),e("skylark-utils/geom",["./skylark","./langx","./styler"],function(e,t,n){function r(e){for(var t=e.offsetParent||document.body;t&&!S.test(t.nodeName)&&"static"==n.css(t,"position");)t=t.offsetParent;return t}function i(e){var t=getComputedStyle(e);return{left:T(t.borderLeftWidth,e),top:T(t.borderTopWidth,e),right:T(t.borderRightWidth,e),bottom:T(t.borderBottomWidth,e)}}function o(e,t){if(void 0===t)return S.test(e.nodeName)?{top:0,left:0}:e.getBoundingClientRect();var n=r(e),a=o(n),s=d(e),u=i(n);return m(e,{top:t.top-a.top-s.top-u.top,left:t.left-a.left-s.left-u.left}),this}function a(e,t){return void 0===t?e.getBoundingClientRect():(o(e,t),x(e,t),this)}function s(e,t){return void 0==t?u(e).height:u(e,{height:t})}function u(e,t){if(void 0==t)return{width:e.clientWidth,height:e.clientHeight};var r="border-box"===n.css(e,"box-sizing"),o={width:t.width,height:t.height};if(r){var a=i(e);void 0!==o.width&&(o.width=o.width+a.left+a.right),void 0!==o.height&&(o.height=o.height+a.top+a.bottom)}else{var s=p(e);void 0!==o.width&&(o.width=o.width-s.left-s.right),void 0!==o.height&&(o.height=o.height-s.top-s.bottom)}return n.css(e,o),this}function l(e,t){return void 0==t?u(e).width:(u(e,{width:t}),this)}function c(e){var t=u(e),n=p(e);return{left:n.left,top:n.top,width:t.width-n.left-n.right,height:t.height-n.top-n.bottom}}function f(e){var t=e.documentElement,n=e.body,r=Math.max,i=r(t.scrollWidth,n.scrollWidth),o=r(t.clientWidth,n.clientWidth),a=r(t.offsetWidth,n.offsetWidth),s=r(t.scrollHeight,n.scrollHeight),u=r(t.clientHeight,n.clientHeight),l=r(t.offsetHeight,n.offsetHeight);return{width:i-1?n.split(","):n.split(/\s/));var a=N(e);return n&&n.forEach(function(e){a.unregister(e,i,{selector:r})}),this}function c(e,n,r,i,o,a){if(t.isPlainObject(n))return t.each(n,function(t,n){c(e,t,r,i,n,a)}),this;t.isString(r)||t.isFunction(o)||(o=i,i=r,r=void 0),t.isFunction(i)&&(o=i,i=void 0),o===!1&&(o=t.returnFalse),"string"==typeof n&&(n=n.indexOf(",")>-1?n.split(","):n.split(/\s/));var s=N(e);return n.forEach(function(e){return"ready"==e?p(o):void s.register(e,o,{data:i,selector:r,one:!!a})}),this}function f(e,t,n,r,i){return c(e,t,n,r,i,1),this}function h(e){return window.document.all&&(e.keyCode=0),e.preventDefault&&(e.preventDefault(),e.stopPropagation()),this}function d(e,t,n){var r;return r=t instanceof Event?t:w(t,n),r._args=n,(e.dispatchEvent||e.trigger).call(e,r),this}function p(e){return b.test(document.readyState)&&document.body?e():document.addEventListener("DOMContentLoaded",e,!1),this}function g(e){var t=o.data(e,"shortcuts");if(!t){t={},o.data(e,"shortcuts",t);var n=function(e,t){var n=t.metaKey||t.ctrlKey;if(e.ctrl==n&&e.alt==t.altKey&&e.shift==t.shiftKey&&(t.keyCode==e.keyCode||t.charCode&&t.charCode==e.charCode))return t.preventDefault(),"keydown"==t.type&&e.fn(t),!0};c(e,"keyup keypress keydown",function(e){if(!/INPUT|TEXTAREA/.test(e.target.nodeName))for(var r in t)n(t[r],e)})}return{add:function(e,n){var r;r=e.indexOf(",")>-1?e.toLowerCase().split(","):e.toLowerCase().split(" "),r.forEach(function(e){var r={fn:n,alt:!1,ctrl:!1,shift:!1};e.split("+").forEach(function(e){switch(e){case"alt":case"ctrl":case"shift":r[e]=!0;break;default:r.charCode=e.charCodeAt(0),r.keyCode=P[e]||e.toUpperCase().charCodeAt(0)}});var i=(r.ctrl?"ctrl":"")+","+(r.alt?"alt":"")+","+(r.shift?"shift":"")+","+r.keyCode;t[i]=r})}}}function v(){return v}var m=(t.mixin,t.each,Array.prototype.slice,t.uid),y=/^([A-Z]|returnValue$|layer[XY]$)/,k={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"},b=/complete|loaded|interactive/,w=function(){function e(e){var t=r[e];return t||(t=0),n[t]}var n=[window.CustomEvent,window.CompositionEvent,window.DragEvent,window.Event,window.FocusEvent,window.KeyboardEvent,window.MessageEvent,window.MouseEvent,window.MouseScrollEvent,window.MouseWheelEvent,window.MutationEvent,window.ProgressEvent,window.TextEvent,window.TouchEvent,window.UIEvent,window.WheelEvent],r={compositionstart:1,compositionend:1,compositionupdate:1,beforecopy:2,beforecut:2,beforepaste:2,copy:2,cut:2,paste:2,drag:2,dragend:2,dragenter:2,dragexit:2,dragleave:2,dragover:2,dragstart:2,drop:2,abort:3,change:3,error:3,selectionchange:3,submit:3,reset:3,focus:4,blur:4,focusin:4,focusout:4,keydown:5,keypress:5,keyup:5,message:6,click:7,contextmenu:7,dblclick:7,mousedown:7,mouseup:7,mousemove:7,mouseover:7,mouseout:7,mouseenter:7,mouseleave:7,textInput:12,touchstart:13,touchmove:13,touchend:13,load:14,resize:14,select:14,scroll:14,unload:14,wheel:15};return function(n,r){t.isString(n)?r=r||{}:(r=n,n=r.type);var i=s(n);n=i.type,r=t.mixin({bubbles:!1,cancelable:!0},r),i.ns&&(r.namespace=i.ns);var o=e(n),u=new o(n,r);return t.safeMixin(u,r),a(u)}}(),x="onfocusin"in window,C={focus:"focusin",blur:"focusout"},E={mouseenter:"mouseover",mouseleave:"mouseout"},S=function(e){return E[e]||x&&C[e]||e},T={},_=t.klass({init:function(e,t){this._target=e,this._event=t,this._bindings=[]},add:function(e,n){var o=this._bindings,a={fn:e,options:t.mixin({},n)};o.push(a);var s=this;if(!s._listener){s._listener=function(e){var n=this,i=u(e),a=e._args,l=(s._bindings,i.namespace);a=t.isDefined(a)?[i].concat(a):[i],o.some(function(e){var o=n;if(i.isImmediatePropagationStopped&&i.isImmediatePropagationStopped())return!0;var u=e.fn,c=e.options||{},f=c.selector,h=c.one,d=c.data;if(l&&l!=c.ns)return!1;if(f){if(o=r.closest(i.target,f),!o||o===n)return!1;t.mixin(i,{currentTarget:o,liveFired:n})}t.isDefined(d)&&(i.data=d),h&&s.remove(u,c);var p=u.apply(o,a);return p===!1&&(i.preventDefault(),i.stopPropagation()),!1})};var l=s._event;if(l in E){var c=s._listener;s._listener=function(e){var t=e.relatedTarget;if(!t||t!==this&&!i.contains(this,t))return c.apply(this,arguments)}}s._target.addEventListener?s._target.addEventListener(S(l),s._listener,!1):console.warn("invalid eventer object",s._target)}},remove:function(e,n){function r(e){return new RegExp("(?:^| )"+e.replace(" "," .* ?")+"(?: |$)")}n=t.mixin({},n);var i;n.ns&&(i=r(n.ns)),this._bindings=this._bindings.filter(function(t){var r=(!e||e===t.fn)&&(!i||i.test(t.options.ns))&&(!n.selector||n.selector==t.options.selector);return!r}),0==this._bindings.length&&(this._target.removeEventListener&&this._target.removeEventListener(S(this._event),this._listener,!1),this._listener=null)}}),A=t.klass({init:function(e){this._target=e,this._handler={}},register:function(e,n,r){var i=s(e);e=i.type;var o=this._handler;void 0===o[e]&&(o[e]=new _(this._target,e)),o[e].add(n,t.mixin({ns:i.ns},r))},unregister:function(e,n,r){var i=this._handler,o=s(e);e=o.type;var a=i[e];a&&a.remove(n,t.mixin({ns:o.ns},r))}}),N=function(e){var t=m(e),n=T[t];return n||(n=T[t]=new A(e)),n},P={"delete":46};return t.mixin(v,{create:w,off:l,on:c,one:f,proxy:u,ready:p,shortcuts:g,stop:h,trigger:d}),e.eventer=v}),e("skylark-utils/dnd",["./skylark","./langx","./noder","./datax","./geom","./eventer","./styler"],function(e,t,n,r,i,o,a){function s(e,t){return new h(e,t)}function u(e,t){return new d(e,t)}function l(){return l}var c=(o.on,o.off,r.attr,r.removeAttr,i.pagePosition,a.addClass,i.height,t.Evented.inherit({klassName:"DndManager",init:function(){},start:function(e,n){var r=i.pagePosition(e.elm);this.draggingOffsetX=parseInt(n.pageX-r.left),this.draggingOffsetY=parseInt(n.pageY-r.top);var a=o.create("started",{ghost:null,transfer:{}});e.trigger(a),this.dragging=e,this.draggingGhost=a.ghost,this.draggingGhost||(this.draggingGhost=e.elm),this.draggingTransfer=a.transfer,this.draggingTransfer&&t.each(this.draggingTransfer,function(e,t){n.dataTransfer.setData(e,t)}),n.dataTransfer.setDragImage(this.draggingGhost,this.draggingOffsetX,this.draggingOffsetY),n.dataTransfer.effectAllowed="copyMove",this.trigger(a)},end:function(){var e=o.create("ended",{});this.trigger(e),this.dragging=null,this.draggingTransfer=null,this.draggingGhost=null,this.draggingOffsetX=null,this.draggingOffsetY=null}})),f=new c,h=t.Evented.inherit({klassName:"Draggable",init:function(e,n){var i=this,s=n.draggingClass||"dragging",u=!1;i.elm=e,i._params=n,["started","ended","moving"].forEach(function(e){t.isFunction(n[e])&&i.on(e,n[e])}),o.on(e,{mousedown:function(e){u===!0&&r.prop(i.elm,"draggable",!0)},mouseup:function(e){r.prop(i.elm,"draggable",!1)},dragstart:function(e){f.start(i,e),a.addClass(i.elm,s)},dragend:function(e){o.stop(e),f.dragging&&(a.removeClass(i.elm,s),f.end())}}),n.handle?o.on(e,{mouseenter:function(e){u=!0},mouseleave:function(e){u=!1}},n.handle):u=!0}}),d=t.Evented.inherit({klassName:"Droppable",init:function(e,n){var r,i,s=this,u=(n.draggingClass||"dragging",!0);s.elm=e,s._params=n,["started","ended","entered","leaved","dropped","overing"].forEach(function(e){t.isFunction(n[e])&&s.on(e,n[e])}),o.on(e,{dragover:function(e){if(e.stopPropagation(),u){var t=o.create("overing",{transfer:f.draggingTransfer});s.trigger(t),e.preventDefault(),e.dataTransfer.dropEffect="copyMove"}},dragenter:function(e){var t=(s._params,s.elm),n=o.create("entered",{transfer:f.draggingTransfer});s.trigger(n),e.stopPropagation(),r&&u&&a.addClass(t,r)},dragleave:function(e){var t=(s._params,s.elm);if(!u)return!1;var n=o.create("leaved",{transfer:f.draggingTransfer});s.trigger(n),e.stopPropagation(),r&&u&&a.removeClass(t,r)},drop:function(e){var t=(s._params,s.elm);if(o.stop(e),f.dragging){r&&u&&a.addClass(t,r);var n=o.create("dropped",{transfer:f.draggingTransfer});s.trigger(n),f.end()}}}),f.on("started",function(t){var n=o.create("started",{transfer:f.draggingTransfer,acceptable:!1});s.trigger(n),u=n.acceptable,r=n.hoverClass,i=n.activeClass,i&&u&&a.addClass(e,i)}).on("ended",function(t){var n=o.create("ended",{transfer:f.draggingTransfer,acceptable:!1});s.trigger(n),r&&u&&a.removeClass(e,r),i&&u&&a.removeClass(e,i),u=!1,i=null,r=null})}});return t.mixin(l,{draggable:s,droppable:u,manager:f}),e.dnd=l}),e("skylarkjs/dnd",["skylark-utils/dnd"],function(e){return e}),e("skylarkjs/eventer",["skylark-utils/eventer"],function(e){return e}),e("skylark-utils/filer",["./skylark","./langx","./eventer"],function(e,t,n){function r(e){function t(e){for(var t=e.length;t--;)e[t].size>s&&e.splice(t,1);o(e)}if(o=e,!i){var n=i=document.createElement("input");n.type="file",n.style.position="fixed",n.style.left=0,n.style.top=0,n.style.opacity=.001,document.body.appendChild(n),n.onchange=function(e){t(Array.prototype.slice.call(e.target.files)),n.value=""}}n.click()}var i,o,a=n.on,s=(n.attr,1/0),u=function(){return u};return t.mixin(u,{picker:function(e,t){t=t||{};var n=t.picked;return a(e,"click",function(e){e.preventDefault(),r(n)}),this},dropzone:function(e,t){t=t||{};var n=t.dropped;return a(e,"dragover,dragend",function(e){return!1}),a(e,"drop",function(e){e.preventDefault(),n&&n(e.dataTransfer.files)}),this}}),e.filer=u}),e("skylarkjs/filer",["skylark-utils/filer"],function(e){return e}),e("skylarkjs/finder",["skylark-utils/finder"],function(e){return e}),e("skylark-utils/fx",["./skylark","./langx","./browser","./styler","./eventer","./async"],function(e,t,n,r,i,o){function a(e,n,a,s,u,c){var f,h,d,p={},k=[],N="",P=this,O=!1,j=!1;if(t.isPlainObject(a)&&(s=a.easing,u=a.complete,c=a.delay,a=a.duration),t.isString(a)&&(a=g.speeds[a]),void 0===a&&(a=g.speeds.normal),a/=1e3,g.off&&(a=0),t.isFunction(s)?(u=s,eace="swing"):s=s||"swing",c?c/=1e3:c=0,t.isString(n))p[v]=n,p[m]=a+"s",p[y]=s,h=E;else{for(f in n)T.test(f)?N+=f+"("+n[f]+") ":("scrollTop"===f&&(j=!0),p[f]=n[f],k.push(t.dasherize(f)));h=S}return N&&(p[_]=N,k.push(_)),a>0&&t.isPlainObject(n)&&(p[b]=k.join(", "),p[w]=a+"s",p[C]=c+"s",p[x]=s),d=function(t){if(O=!0,t){if(t.target!==t.currentTarget)return;i.off(t.target,h,d)}else i.off(e,E,d);r.css(e,A),u&&u.call(this)},a>0&&(i.on(e,h,d),o.debounce(function(){O||d.call(P)},1e3*(a+c)+25)()),e.clientLeft,r.css(e,p),a<=0&&o.debounce(function(){O||d.call(P)},0)(),j&&l(e,n.scrollTop,a,u),this}function s(e,n,i){return r.show(e),n&&(!i&&t.isFunction(n)&&(i=n,n="normal"),r.css(e,"opacity",0),a(e,{opacity:1,scale:"1,1"},n,i)),this}function u(e,n,i){return n?(!i&&t.isFunction(n)&&(i=n,n="normal"),a(e,{opacity:0,scale:"0,0"},n,function(){r.hide(e),i&&i.call(e)})):r.hide(e),this}function l(e,t,n,r){var i=parseInt(e.scrollTop),a=0,s=5,u=1e3*n/s,l=parseInt(t),c=setInterval(function(){a++,a<=u&&(e.scrollTop=(l-i)/u*a+i),a>=u+1&&(clearInterval(c),r&&o.debounce(r,1e3)())},s)}function c(e,t,n){return r.isInvisible(e)?s(e,t,n):u(e,t,n),this}function f(e,t,n,r){return a(e,{opacity:n},t,r),this}function h(e,t,n){var i=r.css(e,"opacity");return i>0?r.css(e,"opacity",0):i=1,r.show(e),f(e,t,i,n),this}function d(e,t,n){return f(e,t,0,function(){r.hide(e),n&&n.call(e)}),this}function p(e,t,n){return r.isInvisible(e)?h(e,t,n):d(e,t,n),this}function g(){return g}var v,m,y,k,b,w,x,C,E=n.normalizeCssEvent("AnimationEnd"),S=n.normalizeCssEvent("TransitionEnd"),T=/^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i,_=n.css3PropPrefix+"transform",A={};return A[v=n.normalizeCssProperty("animation-name")]=A[m=n.normalizeCssProperty("animation-duration")]=A[k=n.normalizeCssProperty("animation-delay")]=A[y=n.normalizeCssProperty("animation-timing-function")]="",A[b=n.normalizeCssProperty("transition-property")]=A[w=n.normalizeCssProperty("transition-duration")]=A[C=n.normalizeCssProperty("transition-delay")]=A[x=n.normalizeCssProperty("transition-timing-function")]="",t.mixin(g,{off:!1,speeds:{normal:400,fast:200,slow:600},animate:a,fadeIn:h,fadeOut:d,fadeTo:f,fadeToggle:p,hide:u,scrollToTop:l,show:s,toggle:c}),e.fx=g}),e("skylarkjs/fx",["skylark-utils/fx"],function(e){return e}),e("skylarkjs/geom",["skylark-utils/geom"],function(e){return e}),e("skylark-utils/mover",["./skylark","./langx","./noder","./datax","./geom","./eventer","./styler"],function(e,t,n,r,i,o,a){function s(e,t){function r(e){var t,n;if(e.changedTouches)for(t="screenX screenY pageX pageY clientX clientY".split(" "),n=0;nv.maxX&&(n=v.maxX),ov.maxY&&(o=v.maxY)),i.relativePosition(e,{left:n,top:o}),t.preventDefault(),k&&k(t)},c=function(e){r(e),o.off(m,"mousemove touchmove",w).off(m,"mouseup touchend",c),n.remove(s),b&&b(e)};return o.on(g,"mousedown touchstart",l),{remove:function(){o.off(g)}}}function u(){return u}o.on,o.off,r.attr,r.removeAttr,i.pagePosition,a.addClass,i.height;return t.mixin(u,{movable:s}),e.mover=u}),e("skylarkjs/mover",["skylark-utils/mover"],function(e){return e}),e("skylarkjs/noder",["skylark-utils/noder"],function(e){return e}),e("skylark-utils/query",["./skylark","./langx","./async","./noder","./datax","./eventer","./finder","./geom","./styler","./fx"],function(e,t,n,r,i,o,a,s,u,l){function c(e,t){return function(){var n=this,r=b.call(arguments),i=$.map(n,function(n,i){return e.apply(t,[n].concat(r))});return $(_(i))}}function f(e,t,n){return function(r){var i=(b.call(arguments),this.map(function(i,o){return e.apply(t,n?[o]:[o,r])}));return n&&r?i.filter(r):i}}function h(e,t){return function(){var n=this,r=b.call(arguments);return this.each(function(n){e.apply(t,[this].concat(r))}),n}}function d(e,t,n){return function(r){var i=this,o=b.call(arguments);return x.call(i,function(i,a){E(i,r,a,n(i));e.apply(t,[i,r].concat(o.slice(1)))}),i}}function p(e,t){return function(){var n=this,r=b.call(arguments);return y.call(n,function(n){return e.apply(t,[n].concat(r))})}}function g(e,n,r){return function(i,o){var a=this,s=b.call(arguments);return t.isPlainObject(i)||t.isDefined(o)?(x.call(a,function(t,i){var a;a=r?E(t,o,i,r(t)):o,e.apply(n,[t].concat(s))}),a):a[0]?e.apply(n,[a[0],i]):void 0}}function v(e,n,r){return function(i){var o=this;return t.isDefined(i)?(x.call(o,function(t,o){var a;a=r?E(t,i,o,r(t)):i,e.apply(n,[t,a])}),o):o[0]?e.apply(n,[o[0]]):void 0}}var m,y=Array.prototype.some,k=Array.prototype.push,b=(Array.prototype.every,Array.prototype.concat,Array.prototype.slice),w=(Array.prototype.map,Array.prototype.filter),x=Array.prototype.forEach,C=/^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/,E=t.funcArg,S=t.isArrayLike,T=t.isString,_=t.uniq,A=t.isFunction,N=t.type,P=t.isArray,O=(t.isWindow,t.isDocument),j=t.isObject,R=(t.isPlainObject,t.compact,t.flatten,t.camelCase,t.dasherize,a.children,t.klass({klassName:"SkNodeList",init:function(e,n){var i,o,s,u,l=this;return e&&(l.context=n=n||r.doc(),T(e)?(l.selector=e,i="<"===e.charAt(0)&&">"===e.charAt(e.length-1)&&e.length>=3?[null,e,null]:C.exec(e),i?i[1]?(o=r.createFragment(e),t.isPlainObject(n)&&(u=n)):(s=a.byId(i[2],r.ownerDoc(n)),s&&(o=[s])):o=a.descendants(n,e)):o=P(e)?e:[e]),o&&(k.apply(l,o),u&&l.attr(u)),l}},Array)),D=function(){function e(e,n,i){return function(i){var o,a=t.map(arguments,function(e){return o=N(e),"object"==o||"array"==o||null==e?e:r.createFragment(e)});return a.length<1?this:(this.each(function(t){e.apply(n,[this,a,t>0])}),this)}}m=function(e){return e instanceof R},init=function(e,t){return new R(e,t)};var n=function(e,t){return A(e)?void o.ready(function(){e(n)}):m(e)?e:t&&m(t)&&T(e)?t.find(e):init(e,t)};n.fn=R.prototype,t.mixin(n.fn,{map:function(e){return n(t.map(this,function(t,n){return e.call(t,n,t)}))},slice:function(){return n(b.apply(this,arguments))},get:function(e){return void 0===e?b.call(this):this[e>=0?e:e+this.length]},toArray:function(){return b.call(this)},size:function(){return this.length},remove:h(r.remove,r),each:function(e){return t.each(this,e),this},filter:function(e){return A(e)?this.not(this.not(e)):n(w.call(this,function(t){return a.matches(t,e)}))},add:function(e,t){return n(_(this.concat(n(e,t))))},is:function(e){return this.length>0&&a.matches(this[0],e)},not:function(e){var t=[];if(A(e)&&void 0!==e.call)this.each(function(n){e.call(this,n)||t.push(this)});else{var r="string"==typeof e?this.filter(e):S(e)&&A(e.item)?b.call(e):n(e);this.forEach(function(e){r.indexOf(e)<0&&t.push(e)})}return n(t)},has:function(e){return this.filter(function(){return j(e)?r.contains(this,e):n(this).find(e).size()})},eq:function(e){return e===-1?this.slice(e):this.slice(e,+e+1)},first:function(){return this.eq(0)},last:function(){return this.eq(-1)},find:f(a.descendants,a),closest:function(e,t){var r=this[0],i=!1;for("object"==typeof e&&(i=n(e));r&&!(i?i.indexOf(r)>=0:a.matches(r,e));)r=r!==t&&!O(r)&&r.parentNode;return n(r)},parents:f(a.ancestors,a),parent:f(a.parent,a),children:f(a.children,a),contents:c(r.contents,r),siblings:f(a.siblings,a),empty:h(r.empty,r),pluck:function(e){return t.map(this,function(t){return t[e]})},show:h(l.show,l),replaceWith:function(e){return this.before(e).remove()},wrap:function(e){var t=A(e);if(this[0]&&!t)var r=n(e).get(0),i=r.parentNode||this.length>1;return this.each(function(o){n(this).wrapAll(t?e.call(this,o):i?r.cloneNode(!0):r)})},wrapAll:function(e){if(this[0]){n(this[0]).before(e=n(e));for(var t;(t=e.children()).length;)e=t.first();n(e).append(this)}return this},wrapInner:function(e){var t=A(e);return this.each(function(r){var i=n(this),o=i.contents(),a=t?e.call(this,r):e;o.length?o.wrapAll(a):i.append(a)})},unwrap:function(e){return 0===this.parent().children().length?this.parent(e).not("body").each(function(){n(this).replaceWith(document.createTextNode(this.childNodes[0].textContent))}):this.parent().each(function(){n(this).replaceWith(n(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:h(l.hide,l),toggle:function(e){return this.each(function(){var t=n(this);(void 0===e?"none"==t.css("display"):e)?t.show():t.hide()})},prev:function(e){return n(this.pluck("previousElementSibling")).filter(e||"*")},next:function(e){return n(this.pluck("nextElementSibling")).filter(e||"*")},html:v(r.html,r,r.html),text:v(i.text,i,i.text),attr:g(i.attr,i,i.attr),removeAttr:h(i.removeAttr,i),prop:g(i.prop,i,i.prop),data:g(i.data,i,i.data),removeData:h(i.removeData,i),val:v(i.val,i,i.val),offset:v(s.pageRect,s,s.pageRect),style:g(u.css,u),css:g(u.css,u),index:function(e){return e?this.indexOf(n(e)[0]):this.parent().children().indexOf(this[0])},hasClass:p(u.hasClass,u),addClass:d(u.addClass,u,u.className),removeClass:d(u.removeClass,u,u.className),toggleClass:d(u.toggleClass,u,u.className),scrollTop:v(s.scrollTop,s),scrollLeft:v(s.scrollLeft,s),position:function(){if(this.length){var e=this[0];return s.relativePosition(e)}},offsetParent:c(s.offsetParent,s)}),n.fn.detach=n.fn.remove,n.fn.size=v(s.size,s),n.fn.width=v(s.width,s,s.width),n.fn.height=v(s.height,s,s.height),["width","height"].forEach(function(e){var t=e.replace(/./,function(e){return e[0].toUpperCase()});n.fn["outer"+t]=function(t,n){if(arguments.length?"boolean"!=typeof t&&(n=t,t=!1):(t=!1,n=void 0),void 0===n){var r=this[0],i=s.size(r);if(t){var o=s.marginExtents(r);i.width=i.width+o.left+o.right,i.height=i.height+o.top+o.bottom}return"width"===e?i.width:i.height}return this.each(function(r,i){var o={},a=s.marginExtents(i);"width"===e?(o.width=n,t&&(o.width=o.width-a.left-a.right)):(o.height=n,t&&(o.height=o.height-a.top-a.bottom)),s.size(i,o)})}}),n.fn.innerWidth=v(s.width,s,s.width),n.fn.innerHeight=v(s.height,s,s.height);r.traverse;return n.fn.after=e(r.after,r),n.fn.prepend=e(r.prepend,r),n.fn.before=e(r.before,r),n.fn.append=e(r.append,r),n.fn.insertAfter=function(e){return n(e).after(this),this},n.fn.insertBefore=function(e){return n(e).before(this),this},n.fn.appendTo=function(e){return n(e).append(this),this},n.fn.prependTo=function(e){return n(e).prepend(this),this},n}();return function(e){e.fn.on=h(o.on,o),e.fn.off=h(o.off,o),e.fn.trigger=h(o.trigger,o),"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(t){e.fn[t]=function(e,n){return 0 in arguments?this.on(t,e,n):this.trigger(t)}}),e.fn.one=function(e,n,r,i){return t.isString(n)||t.isFunction(i)||(i=r,r=n,n=null),t.isFunction(r)&&(i=r,r=null),this.on(e,n,r,i,1)},e.fn.animate=h(l.animate,l),e.fn.show=h(l.show,l),e.fn.hide=h(l.hide,l),e.fn.toogle=h(l.toogle,l),e.fn.fadeTo=h(l.fadeTo,l),e.fn.fadeIn=h(l.fadeIn,l),e.fn.fadeOut=h(l.fadeOut,l),e.fn.fadeToggle=h(l.fadeToggle,l)}(D),function(e){e.fn.end=function(){return this.prevObject||e()},e.fn.andSelf=function(){return this.add(this.prevObject||e())},"filter,add,not,eq,first,last,find,closest,parents,parent,children,siblings".split(",").forEach(function(t){var n=e.fn[t];e.fn[t]=function(){var e=n.apply(this,arguments);return e.prevObject=this,e}})}(D),function(e){e.fn.query=e.fn.find,e.fn.place=function(e,n){return t.isString(e)?e=a.descendant(e):m(e)&&(e=e[0]),this.each(function(t,i){switch(n){case"before":r.before(e,i);break;case"after":r.after(e,i);break;case"replace":r.replace(e,i);break;case"only":r.empty(e),r.append(e,i);break;case"first":r.prepend(e,i);break;default:r.append(e,i)}})},e.fn.addContent=function(e,n){return e.template&&(e=t.substitute(e.template,e)),this.append(e)},e.fn.replaceClass=function(e,t){return this.removeClass(t),this.addClass(e),this}}(D),e.query=D}),e("skylarkjs/query",["skylark-utils/query"],function(e){return e}),e("skylark-router/router",["skylark-utils/skylark","skylark-utils/langx","skylark-utils/browser","skylark-utils/datax","skylark-utils/eventer","skylark-utils/async"],function(e,t,n,r,i,o){function a(){return y}function s(e){if(k){var t=k.route.exit({path:k.path,params:k.params},!0);if(!t)return}if(k=y,y=e,!y.route){var n=l(y.path);y.route=n.route,y.params=n.params}var r=y.route.enter({path:y.path,params:y.params},!0);o.Deferred.when(r).then(function(){i.trigger(E,"routing",{current:y,previous:k}),y.route.enter({path:y.path,params:y.params},!1),k&&k.route.exit({path:k.path,params:k.params},!1),i.trigger(E,"routed",{current:y,previous:k})})}function u(e,t){if(!t&&y&&y.path==e)return!1;var n=l(e);if(n)if(n.path=e,T.useHistoryApi){var r={path:e};window.history.pushState(r,document.title,(b+e).replace("//","/")),i.trigger(window,i.create("popstate",{state:r}))}else if(T.useHashbang){var o="#!"+e;window.location.hash!==o?window.location.hash=o:s(n)}else s(n);return!0}function l(e,n){var r=!1;return!n&&(r=C[e])?r:(t.each(x,function(t,n){var i=n.match(e);return!i||(r={route:n,params:i},!1)}),r&&!n&&(C[e]=r),r)}function c(e,t){var n,r=x[e];return r&&(n=r.path(t)),n}function f(){return k}function h(e){return t.isDefined(e)?(b=e,this):b}function d(){return E}function p(e){return t.isDefined(e)?(w=e,this):w}function g(e,n){if(t.isDefined(n)){var r={};return r[e]=n,v(r),this}return x[e]}function v(e){if(!t.isDefined(e))return t.mixin({},x);for(var n in e)x[n]=new T.Route(n,e[n])}function m(){null==T.useHashbang&&null==T.useHistoryApi&&(window.location.host?T.useHistoryApi=!0:T.useHashbang=!0);var e;T.useHistoryApi?(e=window.location.pathname,void 0===b&&(b=e.replace(/\/$/,"")),e=e.replace(b,"")||w||"/"):e=T.useHashbang?window.location.hash.replace("#!","")||w||"/":"/",i.on(document.body,"click","a[href]",function(e){var n=e.currentTarget,o=r.attr(n,"href");"#"!=o&&o&&t.isSameOrigin(n.href)&&0===o.indexOf(b)&&(o=o.substr(b.length),i.stop(e),o=o.replace("#!",""),u(o))}),T.useHistoryApi?i.on(window,"popstate",function(e){e.state&&s(e.state),i.stop(e)}):T.useHashbang&&i.on(window,"hashchange",function(e){s({path:window.location.hash.replace(/^#!/,"")}),i.stop(e)}),u(e)}var y,k,b,w,x={},C={},E=new t.Evented,S=t.Evented.inherit({klassName:"Route",init:function(e,n){n=t.mixin({},n);var r=n.pathto||"",i=r,o=i.match(/\:([a-zA-Z0-9_]+)/g);null!==o?(o=o.map(function(e){return e.substring(1)}),i=i.replace(/\:([a-zA-Z0-9_]+)/g,"(.*?)")):o=[],i="*"===i?"(.*)":i.replace("/","\\/"),this._setting=n,this.name=e,this.pathto=r,this.paramNames=o,this.params=i,this.regex=new RegExp("^"+i+"$","");var a=this;["entering","entered","exiting","exited"].forEach(function(e){t.isFunction(n[e])&&a.on(e,n[e])})},enter:function(e,n){if(n){var r=this._entering(e);return o.Deferred.when(r).then(function(){var e=i.create("entering",{route:this,result:!0});return i.trigger(this,e),e.result})}return this._entered(e),i.trigger(this,"entered",t.safeMixin({route:this},e)),this},exit:function(e,n){if(n){var r=this._exiting(e);if(!r)return!1;var o=i.create("exiting",{route:this,result:!0});return i.trigger(this,o),o.result}return this._exited(e),i.trigger(this,"exited",t.safeMixin({route:this},e)),this},match:function(e){var t=this.paramNames,n=e.indexOf("?"),e=~n?e.slice(0,n):decodeURIComponent(e),r=this.regex.exec(e);if(!r)return!1;for(var i={},o=1,a=r.length;o 1) { + return callback ? callback(valueOrPromise) : valueOrPromise; + } else { + return new Deferred().resolve(valueOrPromise); + } + } else if (!nativePromise) { + var deferred = new Deferred(valueOrPromise.cancel); + valueOrPromise.then(deferred.resolve, deferred.reject, deferred.progress); + valueOrPromise = deferred.promise; + } + + if (callback || errback || progback) { + return valueOrPromise.then(callback, errback, progback); + } + return valueOrPromise; + }; + + Deferred.reject = function(err) { + var d = new Deferred(); + d.reject(err); + return d.promise; + }; + + Deferred.resolve = function(data) { + var d = new Deferred(); + d.resolve(data); + return d.promise; + }; + + Deferred.immediate = Deferred.resolve; + + var Evented = createClass({ + on: function(events,selector,data,callback,ctx,/*used internally*/one) { + var self = this, + _hub = this._hub || (this._hub = {}); + + if (isPlainObject(events)) { + ctx = callback; + each(events, function(type, fn) { + self.on(type,selector, data, fn, ctx, one); + }); + return this; + } + + if (!isString(selector) && !isFunction(callback)) { + ctx = callback; + callback = data; + data = selector; + selector = undefined; + } + + if (isFunction(data)) { + ctx = callback; + callback = data; + data = null; + } + + if (isString(events)) { + events = events.split(/\s/) + } + + events.forEach(function(name) { + (_hub[name] || (_hub[name] = [])).push({ + fn: callback, + selector: selector, + data: data, + ctx: ctx, + one: one + }); + }); + + return this; + }, + + one: function(events,selector,data,callback,ctx) { + return this.on(events,selector,data,callback,ctx,1); + }, + + trigger: function(e/*,argument list*/) { + if (!this._hub) { + return this; + } + + var self = this; + + if (isString(e)) { + e = new CustomEvent(e); + } + + var args = slice.call(arguments,1); + if (isDefined(args)) { + args = [e].concat(args); + } else { + args = [e]; + } + [e.type || e.name ,"all"].forEach(function(eventName){ + var listeners = self._hub[eventName]; + if (!listeners){ + return; + } + + var len = listeners.length, + reCompact = false; + + for (var i = 0; i < len; i++) { + var listener = listeners[i]; + if (e.data) { + if (listener.data) { + e.data = mixin({}, listener.data, e.data); + } + } else { + e.data = listener.data || null; + } + listener.fn.apply(listener.ctx, args); + if (listener.one){ + listeners[i] = null; + reCompact = true; + } + } + + if (reCompact){ + self._hub[eventName] = compact(listeners); + } + + }); + return this; + }, + + listened: function(event) { + var evtArr = ((this._hub || (this._events = {}))[event] || []); + return evtArr.length > 0; + }, + + listenTo: function(obj, event, callback,/*used internally*/one) { + if (!obj) { + return this; + } + + // Bind callbacks on obj, + if (isString(callback)) { + callback = this[callback]; + } + + if (one){ + obj.one(event,callback,this); + } else { + obj.on(event,callback,this); + } + + //keep track of them on listening. + var listeningTo = this._listeningTo || (this._listeningTo = []), + listening; + + for (var i=0;i 0 ? concat.apply([], array) : array; + } + + function funcArg(context, arg, idx, payload) { + return isFunction(arg) ? arg.call(context, idx, payload) : arg; + } + + var getAbsoluteUrl = (function() { + var a; + + return function(url) { + if (!a) a = document.createElement('a'); + a.href = url; + + return a.href; + }; + })(); + + function getQueryParams(url) { + var url = url || window.location.href, + segs = url.split("?"), + params = {}; + + if (segs.length > 1) { + segs[1].split("&").forEach(function(queryParam) { + var nv = queryParam.split('='); + params[nv[0]] = nv[1]; + }); + } + return params; + } + + function grep(array, callback) { + var out = []; + + each(array, function(i, item) { + if (callback(item, i)) { + out.push(item); + } + }); + + return out; + } + + function inArray(item, array) { + if (!array) { + return -1; + } + var i; + + if (array.indexOf) { + return array.indexOf(item); + } + + i = array.length; + while (i--) { + if (array[i] === item) { + return i; + } + } + + return -1; + } + + function inherit(ctor, base) { + var f = function() {}; + f.prototype = base.prototype; + + ctor.prototype = new f(); + } + + function isArray(object) { + return object instanceof Array; + } + + function isArrayLike(obj) { + return !isString(obj) && typeof obj.length == 'number'; + } + + function isBoolean(obj) { + return typeof(obj) === "boolean"; + } + + function isDocument(obj) { + return obj != null && obj.nodeType == obj.DOCUMENT_NODE; + } + + function isFunction(value) { + return type(value) == "function"; + } + + function isObject(obj) { + return type(obj) == "object"; + } + + function isPlainObject(obj) { + return isObject(obj) && !isWindow(obj) && Object.getPrototypeOf(obj) == Object.prototype; + } + + function isString(obj) { + return typeof obj === 'string'; + } + + function isWindow(obj) { + return obj && obj == obj.window; + } + + function isDefined(obj) { + return typeof obj !== 'undefined'; + } + + function isNumber(obj) { + return typeof obj == 'number'; + } + + function isSameOrigin(href) { + if (href) { + var origin = location.protocol + '//' + location.hostname; + if (location.port) { + origin += ':' + location.port; + } + return href.startsWith(origin); + } + } + + + function isEmptyObject(obj) { + var name; + for (name in obj) { + if (obj[name] !== null) { + return false; + } + } + return true; + } + + function makeArray(obj, offset, startWith) { + return (startWith || []).concat(Array.prototype.slice.call(obj, offset || 0)); + } + + function map(elements, callback) { + var value, values = [], + i, key + if (isArrayLike(elements)) + for (i = 0; i < elements.length; i++) { + value = callback.call(elements[i], elements[i], i); + if (value != null) values.push(value) + } + else + for (key in elements) { + value = callback.call(elements[key], elements[key], key); + if (value != null) values.push(value) + } + return flatten(values) + } + + function nextTick(fn) { + requestAnimationFrame(fn); + return this; + } + + function proxy(fn, context) { + var args = (2 in arguments) && slice.call(arguments, 2) + if (isFunction(fn)) { + var proxyFn = function() { + return fn.apply(context, args ? args.concat(slice.call(arguments)) : arguments); + } + return proxyFn; + } else if (isString(context)) { + if (args) { + args.unshift(fn[context], fn) + return proxy.apply(null, args) + } else { + return proxy(fn[context], fn); + } + } else { + throw new TypeError("expected function"); + } + } + + + function toPixel(value) { + // style values can be floats, client code may want + // to round for integer pixels. + return parseFloat(value) || 0; + } + + var type = (function() { + var class2type = {}; + + // Populate the class2type map + each("Boolean Number String Function Array Date RegExp Object Error".split(" "), function(i, name) { + class2type["[object " + name + "]"] = name.toLowerCase(); + }); + + return function type(obj) { + return obj == null ? String(obj) : + class2type[toString.call(obj)] || "object"; + }; + })(); + + function trim(str) { + return str == null ? "" : String.prototype.trim.call(str); + } + + function removeItem(items,item) { + if (isArray(items)) { + var idx = items.indexOf(item); + if (idx != -1) { + items.splice(idx, 1); + } + } else if (isPlainObject(items)) { + for (var key in items) { + if (items[key] == item) { + delete items[key]; + break; + } + } + } + + return this; + } + + function _mixin(target, source, deep, safe) { + for (var key in source) { + if (!source.hasOwnProperty(key)) { + continue; + } + if (safe && target[key] !== undefined) { + continue; + } + if (deep && (isPlainObject(source[key]) || isArray(source[key]))) { + if (isPlainObject(source[key]) && !isPlainObject(target[key])) { + target[key] = {}; + } + if (isArray(source[key]) && !isArray(target[key])) { + target[key] = []; + } + _mixin(target[key], source[key], deep, safe); + } else if (source[key] !== undefined) { + target[key] = source[key] + } + } + return target; + } + + function _parseMixinArgs(args) { + var params = slice.call(arguments, 0); + target = params.shift(), + deep = false; + if (isBoolean(params[params.length - 1])) { + deep = params.pop(); + } + + return { + target: target, + sources: params, + deep: deep + }; + } + + function mixin() { + var args = _parseMixinArgs.apply(this, arguments); + + args.sources.forEach(function(source) { + _mixin(args.target, source, args.deep, false); + }); + return args.target; + } + + function safeMixin() { + var args = _parseMixinArgs.apply(this, arguments); + + args.sources.forEach(function(source) { + _mixin(args.target, source, args.deep, true); + }); + return args.target; + } + + function substitute( /*String*/ template, + /*Object|Array*/ + map, + /*Function?*/ + transform, + /*Object?*/ + thisObject) { + // summary: + // Performs parameterized substitutions on a string. Throws an + // exception if any parameter is unmatched. + // template: + // a string with expressions in the form `${key}` to be replaced or + // `${key:format}` which specifies a format function. keys are case-sensitive. + // map: + // hash to search for substitutions + // transform: + // a function to process all parameters before substitution takes + + + thisObject = thisObject || window; + transform = transform ? + proxy(thisObject, transform) : function(v) { + return v; + }; + + function getObject(key, map) { + if (key.match(/\./)) { + var retVal, + getValue = function(keys, obj) { + var _k = keys.pop(); + if (_k) { + if (!obj[_k]) return null; + return getValue(keys, retVal = obj[_k]); + } else { + return retVal; + } + }; + return getValue(key.split(".").reverse(), map); + } else { + return map[key]; + } + } + + return template.replace(/\$\{([^\s\:\}]+)(?:\:([^\s\:\}]+))?\}/g, + function(match, key, format) { + var value = getObject(key, map); + if (format) { + value = getObject(format, thisObject).call(thisObject, value, key); + } + return transform(value, key).toString(); + }); // String + } + + var _uid = 1; + function uid(obj) { + return obj._uid || obj.id || (obj._uid = _uid++); + } + + function uniq(array) { + return filter.call(array, function(item, idx) { + return array.indexOf(item) == idx; + }) + } + + function langx() { + return langx; + } + + mixin(langx, { + camelCase: function(str) { + return str.replace(/-([\da-z])/g, function(a) { + return a.toUpperCase().replace('-', ''); + }); + }, + + compact: compact, + + dasherize: dasherize, + + debounce: debounce, + + Deferred: Deferred, + + Evented: Evented, + + deserializeValue: deserializeValue, + + each: each, + + flatten: flatten, + + funcArg: funcArg, + + getQueryParams: getQueryParams, + + inArray: inArray, + + isArray: isArray, + + isArrayLike: isArrayLike, + + isBoolean: isBoolean, + + isDefined: function(v) { + return v !== undefined; + }, + + isDocument: isDocument, + + isEmptyObject: isEmptyObject, + + isFunction: isFunction, + + isObject: isObject, + + isPlainObject: isPlainObject, + + isNumber: isNumber, + + isString: isString, + + isSameOrigin: isSameOrigin, + + isWindow: isWindow, + + klass: function(props, parent, options) { + return createClass(props, parent, options); + }, + + lowerFirst: function(str) { + return str.charAt(0).toLowerCase() + str.slice(1); + }, + + makeArray: makeArray, + + map: map, + + mixin: mixin, + + nextTick : nextTick, + + proxy: proxy, + + removeItem: removeItem, + + returnTrue: function() { + return true; + }, + + returnFalse: function() { + return false; + }, + + safeMixin: safeMixin, + + substitute: substitute, + + toPixel: toPixel, + + trim: trim, + + type: type, + + uid: uid, + + uniq: uniq, + + upperFirst: function(str) { + return str.charAt(0).toUpperCase() + str.slice(1); + } + + }); + + return skylark.langx = langx; +}); + +/** + * skylark-router - An Elegant HTML5 Routing Framework. + * @author Hudaokeji Co.,Ltd + * @version v0.9.2 + * @link www.skylarkjs.org + * @license MIT + */ +define('skylark-router/router',[ + "skylark-langx/skylark", + "skylark-langx/langx" +], function(skylark, langx) { + + var _curCtx, + _prevCtx, + _baseUrl, + _homePath, + _routes = {}, + _cache = {}, + _hub = new langx.Evented(); + + function createEvent(type,props) { + var e = new CustomEvent(type,props); + return langx.safeMixin(e, props); + } + + var Route = langx.Evented.inherit({ + klassName: "Route", + init: function(name, setting) { + setting = langx.mixin({}, setting); + var pathto = setting.pathto || "", + pattern = pathto, + paramNames = pattern.match(/\:([a-zA-Z0-9_]+)/g); + if (paramNames !== null) { + paramNames = paramNames.map(function(paramName) { + return paramName.substring(1); + }); + pattern = pattern.replace(/\:([a-zA-Z0-9_]+)/g, '(.*?)'); + } else { + paramNames = []; + } + if (pattern === "*") { + pattern = "(.*)"; + } else { + pattern = pattern.replace("/", "\\/"); + } + + this._setting = setting; + this.name = name; + this.pathto = pathto; + this.paramNames = paramNames; + this.params = pattern; + this.regex = new RegExp("^" + pattern + "$", ""); + + var self = this; + ["entering", "entered", "exiting", "exited"].forEach(function(eventName) { + if (langx.isFunction(setting[eventName])) { + self.on(eventName, setting[eventName]); + } + }); + }, + + enter: function(ctx,query) { + if (query) { + var r = this._entering(ctx), + self = this; + + return langx.Deferred.when(r).then(function(){ + var e = createEvent("entering", { + route: self, + result: true + }); + + self.trigger(e); + + return e.result; + }); + } else { + this._entered(ctx); + + this.trigger(createEvent("entered", langx.safeMixin({ + route: this + }, ctx))); + return this; + } + }, + + exit: function(ctx, query) { + if (query) { + var ok = this._exiting(ctx); + if (!ok) { + return false; + } + + var e = createEvent("exiting", { + route: this, + result: true + }); + + this.trigger(e); + + return e.result; + } else { + this._exited(ctx); + this.trigger(createEvent("exited", langx.safeMixin({ + route: this + }, ctx))); + + return this; + } + }, + + match: function(path) { + var names = this.paramNames, + x = path.indexOf('?'), + path = ~x ? path.slice(0, x) : decodeURIComponent(path), + m = this.regex.exec(path); + + if (!m) { + return false + }; + + var params = {}; + for (var i = 1, len = m.length; i < len; ++i) { + var name = names[i - 1], + val = decodeURIComponent(m[i]); + params[name] = val; + } + + return params; + }, + + path: function(params) { + var path = this.pathto; + if (params) { + path = path.replace(/:([a-zA-Z0-9_]+)/g, function(match, paramName) { + return params[paramName]; + }); + } + return path; + }, + + _entering: function(ctx) { + return true; + }, + _entered: function(ctx) { + return true; + }, + _exiting: function(ctx) { + return true; + }, + _exited: function(ctx) { + return true; + }, + }); + + function current() { + return _curCtx; + } + + // refresh the current route + function dispatch(ctx) { + + if (_prevCtx) { + var ret = _prevCtx.route.exit({ + path: _prevCtx.path, + params: _prevCtx.params + }, true); + if (!ret) { + return; + } + } + + _prevCtx = _curCtx; + _curCtx = ctx; + if (!_curCtx.route) { + var m = map(_curCtx.path); + _curCtx.route = m.route; + _curCtx.params = m.params; + } + + var r = _curCtx.route.enter({ + path: _curCtx.path, + params: _curCtx.params + },true); + + langx.Deferred.when(r).then(function() { + _hub.trigger(createEvent("routing", { + current: _curCtx, + previous: _prevCtx + })); + + _curCtx.route.enter({ + path: _curCtx.path, + params: _curCtx.params + },false); + + if (_prevCtx) { + _prevCtx.route.exit({ + path: _prevCtx.path, + params: _prevCtx.params + }, false); + } + + _hub.trigger(createEvent("routed", { + current: _curCtx, + previous: _prevCtx + })); + }); + } + + function go(path, force) { + if (!force && _curCtx && _curCtx.path == path) { + return false; + } + var ctx = map(path); + if (ctx) { + ctx.path = path; + + if (router.useHistoryApi) { + var state = { + path: path + } + + window.history.pushState(state, document.title, (_baseUrl + path).replace("//", "/")); + window.dispatchEvent(createEvent("popstate", { + state: state + })); + } else if (router.useHashbang) { + var newHash = "#!" + path; + if (window.location.hash !== newHash) { + window.location.hash = newHash; + } else { + dispatch(ctx); + }; + } else { + dispatch(ctx); + } + } + return true; + } + + function map(path, noCache) { + var finded = false; + if (!noCache) { + finded = _cache[path]; + if (finded) { + return finded; + } + } + langx.each(_routes, function(name, route) { + var ret = route.match(path); + if (ret) { + finded = { + route: route, + params: ret + } + return false; + } + return true; + }); + if (finded && !noCache) { + _cache[path] = finded; + } + return finded; + } + + function path(routeName, params) { + var route = _routes[routeName], + path; + if (route) { + path = route.path(params); + } + return path; + } + + function previous() { + return _prevCtx; + } + + function baseUrl(path) { + if (langx.isDefined(path)) { + _baseUrl = path; + return this; + } else { + return _baseUrl; + } + } + + function hub(){ + return _hub; + } + + function homePath(path) { + if (langx.isDefined(path)) { + _homePath = path; + return this; + } else { + return _homePath; + } + } + + function route(name, setting) { + if (langx.isDefined(setting)) { + var settings = {}; + settings[name] = setting; + routes(settings); + return this; + } else { + return _routes[name]; + } + } + + function routes(settings) { + if (!langx.isDefined(settings)) { + return langx.mixin({}, _routes); + } else { + for (var name in settings) { + _routes[name] = new router.Route(name, settings[name]); + } + } + } + + //starts routing urls + function start() { + if (router.useHashbang == null && router.useHistoryApi == null) { + if (window.location.host) { + //web access + router.useHistoryApi = true; + } else { + // local access + router.useHashbang = true; + } + } + + var initPath; + + if (router.useHistoryApi) { + initPath = window.location.pathname; + if (_baseUrl === undefined) { + _baseUrl = initPath.replace(/\/$/, ""); + } + initPath = initPath.replace(_baseUrl, "") || _homePath || "/"; + } else if (router.useHashbang) { + initPath = window.location.hash.replace("#!", "") || _homePath || "/"; + } else { + initPath = "/"; + } + + /* + eventer.on(document.body, "click", "a[href]", function(e) { + var elm = e.currentTarget, + url = elm.getAttribute("href"); + + if (url == "#") { + return; + } + if (url && langx.isSameOrigin(elm.href)) { + if (url.indexOf(_baseUrl) === 0) { + url = url.substr(_baseUrl.length); + eventer.stop(e); + url = url.replace('#!', ''); + go(url); + } + } + }); + */ + if (router.useHistoryApi) { + window.addEventListener("popstate", function(e) { + if(e.state) dispatch(e.state); + e.preventDefault(); + }); + } else if (router.useHashbang) { + window.addEventListener("hashchange", function(e) { + dispatch({ + path: window.location.hash.replace(/^#!/, "") + }); + e.preventDefault(); + }); + } + + go(initPath); + } + + var router = function() { + return router; + }; + + langx.mixin(router, { + "Route": Route, + + // Current path being processed + "current": current, + + // Changes the current path + "go": go, + + "map": map, + + "hub": hub, + + "off": function() { + _hub.off.apply(_hub, arguments); + }, + + "on": function() { + _hub.on.apply(_hub, arguments); + }, + + "one": function() { + _hub.one.apply(_hub, arguments); + }, + + // Returns the path of the named route + "path": path, + + "previous": previous, + + "baseUrl": baseUrl, + + "homePath": homePath, + + "route": route, + + "routes": routes, + + //starts routing urls + "start": start, + + "trigger": function(e) { + _hub.trigger(e); + return this; + }, + + "useHistoryApi": null, + "useHashbang": null + }); + + return skylark.router = router; +}); + +define('skylarkjs/router',[ + "skylark-router/router" +], function(router) { + return router; +}); + +define('skylark-spa/spa',[ + "skylark-langx/skylark", + "skylark-langx/langx", + "skylark-router/router" +], function(skylark, langx, router) { + var Deferred = langx.Deferred; + + function createEvent(type,props) { + var e = new CustomEvent(type,props); + return langx.safeMixin(e, props); + } + + var Route = router.Route = router.Route.inherit({ + klassName: "SpaRoute", + + init: function(name, setting) { + this.overrided(name, setting); + this.content = setting.content; + this.data = setting.data; + //this.lazy = !!setting.lazy; + var self = this; + ["preparing", "rendering", "rendered"].forEach(function(eventName) { + if (langx.isFunction(setting[eventName])) { + self.on(eventName, setting[eventName]); + } + }); + }, + + _entering: function(ctx) { + if (!this._prepared) { + return this.prepare(); + } + return this; + }, + + getConfigData: function(key) { + return key ? this.data[key] : this.data; + }, + + prepare: function() { + var d = new Deferred(), + setting = this._setting, + controllerSetting = setting.controller, + controller = this.controller, + + self = this, + content = setting.content, + contentPath = setting.contentPath; + + if (controllerSetting && !controller) { + require([controllerSetting.type], function(type) { + controller = self.controller = new type(controllerSetting); + d.resolve(); + }); + } else { + d.resolve(); + } + + return d.then(function() { + var e = createEvent("preparing", { + route: self, + result: true + }); + self.trigger(e); + + return Deferred.when(e.result).then(function() { + router.trigger(createEvent("prepared", { + route: self + })); + self._prepared = true; + }); + }); + }, + + render: function(ctx) { + var e = createEvent("rendering", { + route: this, + context: ctx, + content: this.content + }); + this.trigger(e); + return e.content; + }, + + trigger: function(e) { + var controller = this.controller; + if (controller) { + return controller.perform(e); + } else { + return this.overrided(e); + } + } + }); + + var RouteController = langx.Evented.inherit({ + klassName: "SpaRouteController", + + init: function(route, setting) { + setting = setting || {}; + this.content = setting.content; + this.data = setting.data; + }, + + getConfigData: function(key) { + return key ? this.data[key] : this.data; + }, + + perform: function(e) { + var eventName = e.type; + if (this[eventName]) { + return this[eventName].call(this, e); + } + + } + }); + + var Page = langx.Evented.inherit({ + klassName: "SpaPage", + + init: function(params) { + params = langx.mixin({ + "routeViewer": "body" + }, params); + + this._params = params; + this._rvc = document.querySelector(params.routeViewer); + this._router = router; + + router.on("routing", langx.proxy(this, "refresh")); + }, + + prepare: function() { + + }, + + //Refreshes the route + refresh: function() { + var curCtx = router.current(), + prevCtx = router.previous(); + var content = curCtx.route.render(curCtx); + if (langx.isString(content)) { + this._rvc.innerHTML = content; + } else { + this._rvc.innerHTML = ""; + this._rvc.appendChild(content); + } + //eventer.trigger(curCtx.route, "rendered", { + // route: curCtx.route, + // node: this._$rvc.domNode + //}); + } + }); + + var Plugin = langx.Evented.inherit({ + klassName: "SpaPlugin", + + init: function(name, setting) { + this.name = name; + this._setting = setting; + }, + + prepare: function() { + var d = new Deferred(), + setting = this._setting, + controllerSetting = setting.controller, + controller = this.controller, + self = this; + + if (controllerSetting && !controller) { + require([controllerSetting.type], function(type) { + controller = self.controller = new type(controllerSetting); + router.on(setting.hookers, { + plugin: self + }, langx.proxy(controller.perform, controller)); + d.resolve(); + }); + } else { + langx.each(setting.hookers, function(eventName, hooker) { + router.on(eventName, { + plugin: self + }, hooker); + }); + d.resolve(); + } + + return d.then(function() { + var e = createEvent("preparing", { + result: true + }); + self.trigger(e); + return Deferred.when(e.result).then(function() { + self._prepared = true; + }); + }); + } + }); + + var PluginController = langx.Evented.inherit({ + klassName: "SpaPluginController", + + init: function(plugin) { + this.plugin = plugin; + }, + + perform: function(e) { + var eventName = e.type; + if (this[eventName]) { + return this[eventName].call(this, e); + } + + } + }); + + var Application = langx.Evented.inherit({ + klassName: "SpaApplication", + + init: function(config) { + if (app) { + return app; + } + var plugins = this._plugins = {}; + + config = this._config = langx.mixin({ + plugins: {} + }, config, true); + + langx.each(config.plugins, function(pluginName, setting) { + plugins[pluginName] = new Plugin(pluginName, setting); + }); + + router.routes(config.routes); + + this._router = router; + + this._page = new spa.Page(config.page); + + document.title = config.title; + var baseUrl = config.baseUrl; + if (baseUrl === undefined) { + baseUrl = config.baseUrl = require.toUrl(""); + } + router.baseUrl(baseUrl); + + if (config.homePath) { + router.homePath(config.homePath); + } + + app = this; + }, + + getConfig: function(key) { + return key ? this._config[key] : this._config; + }, + + go: function(path) { + router.go(path); + return this; + }, + + page: function() { + return this._page; + }, + + prepare: function() { + var self = this; + var promises1 = langx.map(router.routes(), function(route, name) { + if (route.lazy === false) { + return route.prepare(); + } + }), + promises2 = langx.map(this._plugins, function(plugin, name) { + return plugin.prepare(); + }); + + + return Deferred.all(promises1.concat(promises2)).then(function() { + return router.trigger(createEvent("starting", { + spa: self + })); + }); + }, + + run: function() { + this._router.start(); + } + }); + + var app; + var spa = function(config) { + if (!app) { + window[config.name || "app"] = app = new spa.Application(config); + } + + return app; + } + + langx.mixin(spa, { + "Application": Application, + + "Page": Page, + + "Plugin": Plugin, + "PluginController": PluginController, + + "Route": Route, + "RouteController": RouteController + + }); + + return skylark.spa = spa; +}); + +define('skylarkjs/spa',[ + "skylark-spa/spa" +], function(spa) { + return spa; +}); + +define('skylarkjs/langx',[ + "skylark-langx/langx" +], function(langx) { + return langx; +}); + +define('skylarkjs/core',[ + "./skylark", + "./router", + "./spa", + "./langx" +], function(skylark) { + return skylark; +}) +; +define('skylark-utils/langx',[ + "skylark-langx/langx" +], function(langx) { + return langx; +}); + +define('skylark-utils/browser',[ + "./skylark", + "./langx" +], function(skylark,langx) { + var checkedCssProperties = { + "transitionproperty": "TransitionProperty", + }; + + var css3PropPrefix = "", + css3StylePrefix = "", + css3EventPrefix = "", + + cssStyles = {}, + cssProps = {}, + + vendorPrefix, + vendorPrefixRE, + vendorPrefixesRE = /^(Webkit|webkit|O|Moz|moz|ms)(.*)$/, + + document = window.document, + testEl = document.createElement("div"), + + matchesSelector = testEl.webkitMatchesSelector || + testEl.mozMatchesSelector || + testEl.oMatchesSelector || + testEl.matchesSelector, + + testStyle = testEl.style; + + for (var name in testStyle) { + var matched = name.match(vendorPrefixRE || vendorPrefixesRE); + if (matched) { + if (!vendorPrefixRE) { + vendorPrefix = matched[1]; + vendorPrefixRE = new RegExp("^(" + vendorPrefix + ")(.*)$"); + + css3StylePrefix = vendorPrefix; + css3PropPrefix = '-' + vendorPrefix.toLowerCase() + '-'; + css3EventPrefix = vendorPrefix.toLowerCase(); + } + + cssStyles[langx.lowerFirst(matched[2])] = name; + var cssPropName = langx.dasherize(matched[2]); + cssProps[cssPropName] = css3PropPrefix + cssPropName; + + } + } + + + function normalizeCssEvent(name) { + return css3EventPrefix ? css3EventPrefix + name : name.toLowerCase(); + } + + function normalizeCssProperty(name) { + return cssProps[name] || name; + } + + function normalizeStyleProperty(name) { + return cssStyles[name] || name; + } + + function browser() { + return browser; + } + + langx.mixin(browser, { + css3PropPrefix: css3PropPrefix, + + normalizeStyleProperty: normalizeStyleProperty, + + normalizeCssProperty: normalizeCssProperty, + + normalizeCssEvent: normalizeCssEvent, + + matchesSelector: matchesSelector, + + location: function() { + return window.location; + } + }); + + testEl = null; + + return skylark.browser = browser; +}); + +define('skylarkjs/browser',[ + "skylark-utils/browser" +], function(browser) { + return browser; +}); + +define('skylark-utils/styler',[ + "./skylark", + "./langx" +], function(skylark, langx) { + var every = Array.prototype.every, + forEach = Array.prototype.forEach, + camelCase = langx.camelCase, + dasherize = langx.dasherize; + + function maybeAddPx(name, value) { + return (typeof value == "number" && !cssNumber[dasherize(name)]) ? value + "px" : value + } + + var cssNumber = { + 'column-count': 1, + 'columns': 1, + 'font-weight': 1, + 'line-height': 1, + 'opacity': 1, + 'z-index': 1, + 'zoom': 1 + }, + classReCache = { + + }; + + function classRE(name) { + return name in classReCache ? + classReCache[name] : (classReCache[name] = new RegExp('(^|\\s)' + name + '(\\s|$)')); + } + + // access className property while respecting SVGAnimatedString + function className(node, value) { + var klass = node.className || '', + svg = klass && klass.baseVal !== undefined + + if (value === undefined) return svg ? klass.baseVal : klass + svg ? (klass.baseVal = value) : (node.className = value) + } + + + var elementDisplay = {}; + + function defaultDisplay(nodeName) { + var element, display + if (!elementDisplay[nodeName]) { + element = document.createElement(nodeName) + document.body.appendChild(element) + display = getComputedStyle(element, '').getPropertyValue("display") + element.parentNode.removeChild(element) + display == "none" && (display = "block") + elementDisplay[nodeName] = display + } + return elementDisplay[nodeName] + } + + function show(elm) { + styler.css(elm, "display", ""); + if (styler.css(elm, "display") == "none") { + styler.css(elm, "display", defaultDisplay(elm.nodeName)); + } + return this; + } + + function isInvisible(elm) { + return styler.css(elm, "display") == "none" || styler.css(elm, "opacity") == 0; + } + + function hide(elm) { + styler.css(elm, "display", "none"); + return this; + } + + function addClass(elm, name) { + if (!name) return this + var cls = className(elm), + names; + if (langx.isString(name)) { + names = name.split(/\s+/g); + } else { + names = name; + } + names.forEach(function(klass) { + var re = classRE(klass); + if (!cls.match(re)) { + cls += (cls ? " " : "") + klass; + } + }); + + className(elm, cls); + + return this; + } + + function css(elm, property, value) { + if (arguments.length < 3) { + var computedStyle, + computedStyle = getComputedStyle(elm, '') + if (langx.isString(property)) { + return elm.style[camelCase(property)] || computedStyle.getPropertyValue(property) + } else if (langx.isArrayLike(property)) { + var props = {} + forEach.call(property, function(prop) { + props[prop] = (elm.style[camelCase(prop)] || computedStyle.getPropertyValue(prop)) + }) + return props + } + } + + var css = ''; + if (typeof(property) == 'string') { + if (!value && value !== 0) { + elm.style.removeProperty(dasherize(property)); + } else { + css = dasherize(property) + ":" + maybeAddPx(property, value) + } + } else { + for (key in property) { + if (property[key] === undefined) { + continue; + } + if (!property[key] && property[key] !== 0) { + elm.style.removeProperty(dasherize(key)); + } else { + css += dasherize(key) + ':' + maybeAddPx(key, property[key]) + ';' + } + } + } + + elm.style.cssText += ';' + css; + return this; + } + + + function hasClass(elm, name) { + var re = classRE(name); + return elm.className && elm.className.match(re); + } + + function removeClass(elm, name) { + var cls = className(elm), + names; + if (langx.isString(name)) { + names = name.split(/\s+/g); + } else { + names = name; + } + + names.forEach(function(klass) { + var re = classRE(klass); + if (cls.match(re)) { + cls = cls.replace(re, " "); + } + }); + + className(elm, cls.trim()); + + return this; + } + + function toggleClass(elm, name, when) { + var self = this; + name.split(/\s+/g).forEach(function(klass) { + if (when === undefined) { + when = !self.hasClass(elm, klass); + } + if (when) { + self.addClass(elm, klass); + } else { + self.removeClass(elm, klass) + } + }); + + return self; + } + + var styler = function() { + return styler; + }; + + langx.mixin(styler, { + autocssfix: true, + + addClass: addClass, + className: className, + css: css, + hasClass: hasClass, + hide: hide, + isInvisible: isInvisible, + removeClass: removeClass, + show: show, + toggleClass: toggleClass + }); + + return skylark.styler = styler; +}); + +define('skylark-utils/noder',[ + "./skylark", + "./langx", + "./styler" +], function(skylark, langx, styler) { + var isIE = !!navigator.userAgent.match(/Trident/g) || !!navigator.userAgent.match(/MSIE/g), + fragmentRE = /^\s*<(\w+|!)[^>]*>/, + singleTagRE = /^<(\w+)\s*\/?>(?:<\/\1>|)$/, + div = document.createElement("div"), + table = document.createElement('table'), + tableBody = document.createElement('tbody'), + tableRow = document.createElement('tr'), + containers = { + 'tr': tableBody, + 'tbody': table, + 'thead': table, + 'tfoot': table, + 'td': tableRow, + 'th': tableRow, + '*': div + }, + rootNodeRE = /^(?:body|html)$/i, + map = Array.prototype.map, + slice = Array.prototype.slice; + + function ensureNodes(nodes, copyByClone) { + if (!langx.isArrayLike(nodes)) { + nodes = [nodes]; + } + if (copyByClone) { + nodes = map.call(nodes, function(node) { + return node.cloneNode(true); + }); + } + return nodes; + } + + function nodeName(elm, chkName) { + var name = elm.nodeName && elm.nodeName.toLowerCase(); + if (chkName !== undefined) { + return name === chkName.toLowerCase(); + } + return name; + }; + + function contents(elm) { + if (nodeName(elm, "iframe")) { + return elm.contentDocument; + } + return elm.childNodes; + } + + function html(node, html) { + if (html === undefined) { + return node.innerHTML; + } else { + this.empty(node); + html = html || ""; + if (langx.isString(html) || langx.isNumber(html)) { + node.innerHTML = html; + } else if (langx.isArrayLike(html)) { + for (var i = 0; i < html.length; i++) { + node.appendChild(html[i]); + } + } else { + node.appendChild(html); + } + } + } + + function clone(node, deep) { + var self = this, + clone; + + // TODO: Add feature detection here in the future + if (!isIE || node.nodeType !== 1 || deep) { + return node.cloneNode(deep); + } + + // Make a HTML5 safe shallow copy + if (!deep) { + clone = document.createElement(node.nodeName); + + // Copy attribs + each(self.getAttribs(node), function(attr) { + self.setAttrib(clone, attr.nodeName, self.getAttrib(node, attr.nodeName)); + }); + + return clone; + } + } + + function createElement(tag, props) { + var node = document.createElement(tag); + if (props) { + langx.mixin(node, props); + } + return node; + } + + function createFragment(html) { + // A special case optimization for a single tag + if (singleTagRE.test(html)) { + return [createElement(RegExp.$1)]; + } + + var name = fragmentRE.test(html) && RegExp.$1 + if (!(name in containers)) { + name = "*" + } + var container = containers[name]; + container.innerHTML = "" + html; + dom = slice.call(container.childNodes); + + dom.forEach(function(node){ + container.removeChild(node); + }) + + return dom; + } + + function contains(node, child) { + return isChildOf(child, node); + } + + function createTextNode(text) { + return document.createTextNode(text); + } + + function doc() { + return document; + } + + function empty(node) { + while (node.hasChildNodes()) { + var child = node.firstChild; + node.removeChild(child); + } + return this; + } + + function isChildOf(node, parent) { + if (document.documentElement.contains) { + return parent.contains(node); + } + while (node) { + if (parent === node) { + return true; + } + + node = node.parentNode; + } + + return false; + } + + function isDoc(node) { + return node != null && node.nodeType == node.DOCUMENT_NODE + } + + function ownerDoc(elm) { + if (!elm) { + return document; + } + + if (elm.nodeType == 9) { + return elm; + } + + return elm.ownerDocument; + } + + function after(node, placing, copyByClone) { + var refNode = node, + parent = refNode.parentNode; + if (parent) { + var nodes = ensureNodes(placing, copyByClone), + refNode = refNode.nextSibling; + + for (var i = 0; i < nodes.length; i++) { + if (refNode) { + parent.insertBefore(nodes[i], refNode); + } else { + parent.appendChild(nodes[i]); + } + } + } + return this; + } + + function before(node, placing, copyByClone) { + var refNode = node, + parent = refNode.parentNode; + if (parent) { + var nodes = ensureNodes(placing, copyByClone); + for (var i = 0; i < nodes.length; i++) { + parent.insertBefore(nodes[i], refNode); + } + } + return this; + } + + function prepend(node, placing, copyByClone) { + var parentNode = node, + refNode = parentNode.firstChild, + nodes = ensureNodes(placing, copyByClone); + for (var i = 0; i < nodes.length; i++) { + if (refNode) { + parentNode.insertBefore(nodes[i], refNode); + } else { + parentNode.appendChild(nodes[i]); + } + } + return this; + } + + function append(node, placing, copyByClone) { + var parentNode = node, + nodes = ensureNodes(placing, copyByClone); + for (var i = 0; i < nodes.length; i++) { + parentNode.appendChild(nodes[i]); + } + return this; + } + + function overlay(elm,params) { + var overlayDiv = createElement("div",params); + styler.css(overlayDiv, { + position: "absolute", + top: 0, + left: 0, + width: "100%", + height: "100%", + zIndex: 0x7FFFFFFF, + opacity: 0.7 + }); + elm.appendChild(overlayDiv); + return overlayDiv; + + } + + + + function remove(node) { + if (node && node.parentNode) { + node.parentNode.removeChild(node); + } + return this; + } + + function replace(node, oldNode) { + oldNode.parentNode.replaceChild(node, oldNode); + return this; + } + + function throb(elm, params) { + params = params || {}; + var self = this, + text = params.text, + style = params.style, + time = params.time, + callback = params.callback, + timer, + throbber = overlay(elm, { + className: params.className || "throbber", + style: style + }), + throb = this.createElement("div", { + className: "throb" + }), + textNode = this.createTextNode(text || ""), + remove = function() { + if (timer) { + clearTimeout(timer); + timer = null; + } + if (throbber) { + self.remove(throbber); + throbber = null; + } + }, + update = function(params) { + if (params && params.text && throbber) { + textNode.nodeValue = params.text; + } + }; + throb.appendChild(textNode); + throbber.appendChild(throb); + var end = function() { + remove(); + if (callback) callback(); + }; + if (time) { + timer = setTimeout(end, time); + } + + return { + remove: remove, + update: update + }; + } + + function traverse(node, fn) { + fn(node) + for (var i = 0, len = node.childNodes.length; i < len; i++) { + traverse(node.childNodes[i], fn); + } + return this; + } + + function reverse(node) { + var firstChild = node.firstChild; + for (var i = node.children.length - 1; i > 0; i--) { + if (i > 0) { + var child = node.children[i]; + node.insertBefore(child, firstChild); + } + } + } + + function wrapper(node, wrapperNode) { + if (langx.isString(wrapperNode)) { + wrapperNode = this.createFragment(wrapperNode).firstChild; + } + node.parentNode.insertBefore(wrapperNode, node); + wrapperNode.appendChild(node); + } + + function wrapperInner(node, wrapperNode) { + var childNodes = slice.call(node.childNodes); + node.appendChild(wrapperNode); + for (var i = 0; i < childNodes.length; i++) { + wrapperNode.appendChild(childNodes[i]); + } + return this; + } + + function unwrap(node) { + var child, parent = node.parentNode; + if (parent) { + if (this.isDoc(parent.parentNode)) return; + parent.parentNode.insertBefore(node, parent); + } + } + + function noder() { + return noder; + } + + langx.mixin(noder , { + clone: clone, + contents: contents, + + createElement: createElement, + + createFragment: createFragment, + + contains: contains, + + createTextNode: createTextNode, + + doc: doc, + + empty: empty, + + html: html, + + isChildOf: isChildOf, + + isDoc: isDoc, + + ownerDoc: ownerDoc, + + after: after, + + before: before, + + prepend: prepend, + + append: append, + + remove: remove, + + replace: replace, + + throb: throb, + + traverse: traverse, + + reverse: reverse, + + wrapper: wrapper, + + wrapperInner: wrapperInner, + + unwrap: unwrap + }); + + return skylark.noder = noder; +}); +define('skylark-utils/css',[ + "./skylark", + "./langx", + "./noder" +], function(skylark, langx, construct) { + + var head = document.getElementsByTagName("head")[0], + count = 0, + sheetsByUrl = {}, + sheetElementsById = {}, + defaultSheetId = _createStyleSheet(), + defaultSheet = sheetElementsById[defaultSheetId], + rulesPropName = ("cssRules" in defaultSheet) ? "cssRules" : "rules", + insertRuleFunc, + deleteRuleFunc = defaultSheet.deleteRule || defaultSheet.removeRule; + + if (defaultSheet.insertRule) { + var _insertRule = defaultSheet.insertRule; + insertRuleFunc = function(selector, css, index) { + _insertRule.call(this, selector + "{" + css + "}", index); + }; + } else { + insertRuleFunc = defaultSheet.addRule; + } + + function normalizeSelector(selectorText) { + var selector = [], + last, len; + last = defaultSheet[rulesPropName].length; + insertRuleFunc.call(defaultSheet, selectorText, ';'); + len = defaultSheet[rulesPropName].length; + for (var i = len - 1; i >= last; i--) { + selector.push(_sheet[_rules][i].selectorText); + deleteRuleFunc.call(defaultSheet, i); + } + return selector.reverse().join(', '); + } + + function _createStyleSheet() { + var link = document.createElement("link"), + id = (count++); + + link.rel = "stylesheet"; + link.type = "text/css"; + link.async = false; + link.defer = false; + + head.appendChild(link); + sheetElementsById[id] = link; + + return id; + } + + function css() { + return css; + } + + langx.mixin(css, { + createStyleSheet: function(cssText) { + return _createStyleSheet(); + }, + + loadStyleSheet: function(url, loadedCallback, errorCallback) { + var sheet = sheetsByUrl[url]; + if (!sheet) { + sheet = sheetsByUrl[url] = { + state: 0, //0:unload,1:loaded,-1:loaderror + loadedCallbacks: [], + errorCallbacks: [] + }; + } + + sheet.loadedCallbacks.push(loadedCallback); + sheet.errorCallbacks.push(errorCallback); + + if (sheet.state === 1) { + sheet.node.onload(); + } else if (sheet.state === -1) { + sheet.node.onerror(); + } else { + sheet.id = _createStyleSheet(); + var node = sheet.node = sheetElementsById[sheet.id]; + + startTime = new Date().getTime(); + + node.onload = function() { + sheet.state = 1; + sheet.state = -1; + var callbacks = sheet.loadedCallbacks, + i = callbacks.length; + + while (i--) { + callbacks[i](); + } + sheet.loadedCallbacks = []; + sheet.errorCallbacks = []; + }, + node.onerror = function() { + sheet.state = -1; + var callbacks = sheet.errorCallbacks, + i = callbacks.length; + + while (i--) { + callbacks[i](); + } + sheet.loadedCallbacks = []; + sheet.errorCallbacks = []; + }; + + node.href = sheet.url = url; + + sheetsByUrl[node.url] = sheet; + + } + return sheet.id; + }, + + deleteSheetRule: function(sheetId, rule) { + var sheet = sheetElementsById[sheetId]; + if (langx.isNumber(rule)) { + deleteRuleFunc.call(sheet, rule); + } else { + langx.each(sheet[rulesPropName], function(i, _rule) { + if (rule === _rule) { + deleteRuleFunc.call(sheet, i); + return false; + } + }); + } + }, + + deleteRule: function(rule) { + this.deleteSheetRule(defaultSheetId, rule); + return this; + }, + + removeStyleSheet: function(sheetId) { + if (sheetId === defaultSheetId) { + throw new Error("The default stylesheet can not be deleted"); + } + var sheet = sheetElementsById[sheetId]; + delete sheetElementsById[sheetId]; + + + construct.remove(sheet); + return this; + }, + + findRules: function(selector, sheetId) { + //return array of CSSStyleRule objects that match the selector text + var rules = [], + filters = parseSelector(selector); + $(document.styleSheets).each(function(i, styleSheet) { + if (filterStyleSheet(filters.styleSheet, styleSheet)) { + $.merge(rules, $(styleSheet[_rules]).filter(function() { + return matchSelector(this, filters.selectorText, filters.styleSheet === "*"); + }).map(function() { + return normalizeRule($.support.nativeCSSStyleRule ? this : new CSSStyleRule(this), styleSheet); + })); + } + }); + return rules.reverse(); + }, + + insertRule: function(selector, css, index) { + return this.insertSheetRule(defaultSheetId, selector, css, index); + }, + + insertSheetRule: function(sheetId, selector, css, index) { + if (!selector || !css) { + return -1; + } + + var sheet = sheetElementsById[sheetId]; + index = index || sheet[rulesPropName].length; + + return insertRuleFunc.call(sheet, selector, css, index); + + } + }); + + return skylark.css = css; +}); + +define('skylarkjs/css',[ + "skylark-utils/css" +], function(css) { + return css; +}); + +define('skylark-utils/finder',[ + "./skylark", + "./langx", + "./browser", + "./noder" +], function(skylark, langx, browser, noder, velm) { + var local = {}, + filter = Array.prototype.filter, + slice = Array.prototype.slice, + nativeMatchesSelector = browser.matchesSelector; + + /* + --- + name: Slick.Parser + description: Standalone CSS3 Selector parser + provides: Slick.Parser + ... + */ + ; + (function() { + + var parsed, + separatorIndex, + combinatorIndex, + reversed, + cache = {}, + reverseCache = {}, + reUnescape = /\\/g; + + var parse = function(expression, isReversed) { + if (expression == null) return null; + if (expression.Slick === true) return expression; + expression = ('' + expression).replace(/^\s+|\s+$/g, ''); + reversed = !!isReversed; + var currentCache = (reversed) ? reverseCache : cache; + if (currentCache[expression]) return currentCache[expression]; + parsed = { + Slick: true, + expressions: [], + raw: expression, + reverse: function() { + return parse(this.raw, true); + } + }; + separatorIndex = -1; + while (expression != (expression = expression.replace(regexp, parser))); + parsed.length = parsed.expressions.length; + return currentCache[parsed.raw] = (reversed) ? reverse(parsed) : parsed; + }; + + var reverseCombinator = function(combinator) { + if (combinator === '!') return ' '; + else if (combinator === ' ') return '!'; + else if ((/^!/).test(combinator)) return combinator.replace(/^!/, ''); + else return '!' + combinator; + }; + + var reverse = function(expression) { + var expressions = expression.expressions; + for (var i = 0; i < expressions.length; i++) { + var exp = expressions[i]; + var last = { + parts: [], + tag: '*', + combinator: reverseCombinator(exp[0].combinator) + }; + + for (var j = 0; j < exp.length; j++) { + var cexp = exp[j]; + if (!cexp.reverseCombinator) cexp.reverseCombinator = ' '; + cexp.combinator = cexp.reverseCombinator; + delete cexp.reverseCombinator; + } + + exp.reverse().push(last); + } + return expression; + }; + + var escapeRegExp = (function() { + // Credit: XRegExp 0.6.1 (c) 2007-2008 Steven Levithan MIT License + var from = /(?=[\-\[\]{}()*+?.\\\^$|,#\s])/g, + to = '\\'; + return function(string) { + return string.replace(from, to) + } + }()) + + var regexp = new RegExp( + "^(?:\\s*(,)\\s*|\\s*(+)\\s*|(\\s+)|(+|\\*)|\\#(+)|\\.(+)|\\[\\s*(+)(?:\\s*([*^$!~|]?=)(?:\\s*(?:([\"']?)(.*?)\\9)))?\\s*\\](?!\\])|(:+)(+)(?:\\((?:(?:([\"'])([^\\13]*)\\13)|((?:\\([^)]+\\)|[^()]*)+))\\))?)" + .replace(//, '[' + escapeRegExp(">+~`!@$%^&={}\\;/g, '(?:[\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])') + .replace(//g, '(?:[:\\w\\u00a1-\\uFFFF-]|\\\\[^\\s0-9a-f])') + ); + + function parser( + rawMatch, + + separator, + combinator, + combinatorChildren, + + tagName, + id, + className, + + attributeKey, + attributeOperator, + attributeQuote, + attributeValue, + + pseudoMarker, + pseudoClass, + pseudoQuote, + pseudoClassQuotedValue, + pseudoClassValue + ) { + if (separator || separatorIndex === -1) { + parsed.expressions[++separatorIndex] = []; + combinatorIndex = -1; + if (separator) return ''; + } + + if (combinator || combinatorChildren || combinatorIndex === -1) { + combinator = combinator || ' '; + var currentSeparator = parsed.expressions[separatorIndex]; + if (reversed && currentSeparator[combinatorIndex]) + currentSeparator[combinatorIndex].reverseCombinator = reverseCombinator(combinator); + currentSeparator[++combinatorIndex] = { + combinator: combinator, + tag: '*' + }; + } + + var currentParsed = parsed.expressions[separatorIndex][combinatorIndex]; + + if (tagName) { + currentParsed.tag = tagName.replace(reUnescape, ''); + + } else if (id) { + currentParsed.id = id.replace(reUnescape, ''); + + } else if (className) { + className = className.replace(reUnescape, ''); + + if (!currentParsed.classList) currentParsed.classList = []; + if (!currentParsed.classes) currentParsed.classes = []; + currentParsed.classList.push(className); + currentParsed.classes.push({ + value: className, + regexp: new RegExp('(^|\\s)' + escapeRegExp(className) + '(\\s|$)') + }); + + } else if (pseudoClass) { + pseudoClassValue = pseudoClassValue || pseudoClassQuotedValue; + pseudoClassValue = pseudoClassValue ? pseudoClassValue.replace(reUnescape, '') : null; + + if (!currentParsed.pseudos) currentParsed.pseudos = []; + currentParsed.pseudos.push({ + key: pseudoClass.replace(reUnescape, ''), + value: pseudoClassValue, + type: pseudoMarker.length == 1 ? 'class' : 'element' + }); + + } else if (attributeKey) { + attributeKey = attributeKey.replace(reUnescape, ''); + attributeValue = (attributeValue || '').replace(reUnescape, ''); + + var test, regexp; + + switch (attributeOperator) { + case '^=': + regexp = new RegExp('^' + escapeRegExp(attributeValue)); + break; + case '$=': + regexp = new RegExp(escapeRegExp(attributeValue) + '$'); + break; + case '~=': + regexp = new RegExp('(^|\\s)' + escapeRegExp(attributeValue) + '(\\s|$)'); + break; + case '|=': + regexp = new RegExp('^' + escapeRegExp(attributeValue) + '(-|$)'); + break; + case '=': + test = function(value) { + return attributeValue == value; + }; + break; + case '*=': + test = function(value) { + return value && value.indexOf(attributeValue) > -1; + }; + break; + case '!=': + test = function(value) { + return attributeValue != value; + }; + break; + default: + test = function(value) { + return !!value; + }; + } + + if (attributeValue == '' && (/^[*$^]=$/).test(attributeOperator)) test = function() { + return false; + }; + + if (!test) test = function(value) { + return value && regexp.test(value); + }; + + if (!currentParsed.attributes) currentParsed.attributes = []; + currentParsed.attributes.push({ + key: attributeKey, + operator: attributeOperator, + value: attributeValue, + test: test + }); + + } + + return ''; + }; + + // Slick NS + + var Slick = (this.Slick || {}); + + Slick.parse = function(expression) { + return parse(expression); + }; + + Slick.escapeRegExp = escapeRegExp; + + if (!this.Slick) this.Slick = Slick; + + }).apply(local); + + + var simpleClassSelectorRE = /^\.([\w-]*)$/, + simpleIdSelectorRE = /^#([\w-]*)$/, + slice = Array.prototype.slice; + + + local.parseSelector = local.Slick.parse; + + + local.pseudos = { + // custom pseudos + checked: function(elm) { + return !!elm.checked; + }, + + contains: function(elm, idx, nodes, text) { + if ($(this).text().indexOf(text) > -1) return this + }, + + 'disabled': function(elm) { + return !!elm.disabled; + }, + + 'enabled': function(elm) { + return !elm.disabled; + }, + + eq: function(elm, idx, nodes, value) { + return (idx === value); + }, + + 'focus': function(elm) { + return document.activeElement === elm && (elm.href || elm.type || elm.tabindex); + }, + + first: function(elm, idx) { + return (idx === 0); + }, + + has: function(elm, idx, nodes, sel) { + return local.querySelector(elm, sel).length > 0; + }, + + hidden: function(elm) { + return !local.pseudos["visible"](elm); + }, + + last: function(elm, idx, nodes) { + return (idx === nodes.length - 1); + }, + + parent: function(elm) { + return !!elm.parentNode; + }, + + selected: function(elm) { + return !!elm.selected; + }, + + visible: function(elm) { + return elm.offsetWidth && elm.offsetWidth + } + }; + + local.divide = function(cond) { + var nativeSelector = "", + customPseudos = [], + tag, + id, + classes, + attributes, + pseudos; + + + if (id = cond.id) { + nativeSelector += ("#" + id); + } + if (classes = cond.classes) { + for (var i = classes.length; i--;) { + nativeSelector += ("." + classes[i].value); + } + } + if (attributes = cond.attributes) { + for (var i = 0; i < attributes.length; i++) { + if (attributes[i].Operator) { + nativeSelector += ("[" + attributes[i].key + attributes[i].Operator + JSON.stringify(attributes[i].value) + +"]"); + } else { + nativeSelector += ("[" + attributes[i].key + "]"); + } + } + } + if (pseudos = cond.pseudos) { + for (i = pseudos.length; i--;) { + part = pseudos[i]; + if (this.pseudos[part.key]) { + customPseudos.push(part); + } else { + if (part.value !== undefine) { + nativeSelector += (":" + part.key + "(" + JSON.stringify(part)) + } + } + } + } + + if (tag = cond.tag) { + nativeSelector = tag.toUpperCase() + nativeSelector; + } + + if (!nativeSelector) { + nativeSelector = "*"; + } + + return { + nativeSelector: nativeSelector, + customPseudos: customPseudos + } + + }; + + local.check = function(node, cond, idx, nodes) { + var tag, + id, + classes, + attributes, + pseudos; + + if (tag = cond.tag) { + var nodeName = node.nodeName.toUpperCase(); + if (tag == '*') { + if (nodeName < '@') return false; // Fix for comment nodes and closed nodes + } else { + if (nodeName != tag) return false; + } + } + + if (id = cond.id) { + if (node.getAttribute('id') != id) { + return false; + } + } + + var i, part, cls, pseudo; + + if (classes = cond.classes) { + for (i = classes.length; i--;) { + cls = node.getAttribute('class'); + if (!(cls && classes[i].regexp.test(cls))) return false; + } + } + + if (attributes) + for (i = attributes.length; i--;) { + part = attributes[i]; + if (part.operator ? !part.test(node.getAttribute(part.key)) : !node.hasAttribute(part.key)) return false; + } + if (pseudos = cond.pseudos) { + for (i = pseudos.length; i--;) { + part = pseudos[i]; + if (pseudo = this.pseudos[part.key]) { + if (!pseudo(node, idx, nodes, part.value)) { + return false; + } + } else { + if (!nativeMatchesSelector.call(node, part.key)) { + return false; + } + } + } + } + return true; + } + + local.match = function(node, selector) { + + var parsed = local.Slick.parse(selector); + if (!parsed) { + return true; + } + + // simple (single) selectors + var expressions = parsed.expressions, + simpleExpCounter = 0, + i; + for (i = 0; + (currentExpression = expressions[i]); i++) { + if (currentExpression.length == 1) { + var exp = currentExpression[0]; + if (this.check(node, exp)) { + return true; + } + simpleExpCounter++; + } + } + + if (simpleExpCounter == parsed.length) { + return false; + } + + var nodes = this.query(document, parsed), + item; + for (i = 0; item = nodes[i++];) { + if (item === node) { + return true; + } + } + return false; + }; + + local.combine = function(elm, bit) { + var op = bit.combinator, + cond = bit, + node1, + nodes = []; + + switch (op) { + case '>': // direct children + nodes = children(elm, cond); + break; + case '+': // next sibling + node1 = nextSibling(elm, cond, true); + if (node1) { + nodes.push(node1); + } + break; + case '^': // first child + node1 = firstChild(elm, cond, true); + if (node1) { + nodes.push(node1); + } + break; + case '~': // next siblings + nodes = nextSiblings(elm, cond); + break; + case '++': // next sibling and previous sibling + var prev = previousSibling(elm, cond, true), + next = nextSibling(elm, cond, true); + if (prev) { + nodes.push(prev); + } + if (next) { + nodes.push(next); + } + break; + case '~~': // next siblings and previous siblings + nodes = siblings(elm, cond); + break; + case '!': // all parent nodes up to document + nodes = ancestors(elm, cond); + break; + case '!>': // direct parent (one level) + node1 = parent(elm, cond); + if (node1) { + nodes.push(node1); + } + break; + case '!+': // previous sibling + nodes = previousSibling(elm, cond, true); + break; + case '!^': // last child + node1 = lastChild(elm, cond, true); + if (node1) { + nodes.push(node1); + } + break; + case '!~': // previous siblings + nodes = previousSiblings(elm, cond); + break; + default: + var divided = this.divide(bit); + nodes = slice.call(elm.querySelectorAll(divided.nativeSelector)); + if (divided.customPseudos) { + for (var i = divided.customPseudos.length - 1; i >= 0; i--) { + nodes = filter.call(nodes, function(item, idx) { + return local.check(item, { + pseudos: [divided.customPseudos[i]] + }, idx, nodes) + }); + } + } + break; + + } + return nodes; + } + + local.query = function(node, selector, single) { + + + var parsed = this.Slick.parse(selector); + + var + founds = [], + currentExpression, currentBit, + expressions = parsed.expressions; + + for (var i = 0; + (currentExpression = expressions[i]); i++) { + var currentItems = [node], + found; + for (var j = 0; + (currentBit = currentExpression[j]); j++) { + found = langx.map(currentItems, function(item, i) { + return local.combine(item, currentBit) + }); + if (found) { + currentItems = found; + } + } + if (found) { + founds = founds.concat(found); + } + } + + return founds; + } + + + function ancestor(node, selector, root) { + while (node = node.parentNode) { + if (matches(node, selector)) { + return node; + } + if (node == root) { + break; + } + } + return null; + } + + function ancestors(node, selector) { + var ret = []; + while (node = node.parentNode) { + if (matches(node, selector)) { + ret.push(node); + } + if (node == ret) { + break; + } + } + return ret; + } + + function byId(id, doc) { + doc = doc || noder.doc(); + return doc.getElementById(id); + } + + function children(node, selector) { + var childNodes = node.childNodes, + ret = []; + for (var i = 0; i < childNodes.length; i++) { + var node = childNodes[i]; + if (node.nodeType == 1) { + if (!selector || matches(node, selector)) { + ret.push(node); + } + + } + } + return ret; + } + + function closest(node, selector) { + while (node && !(matches(node, selector))) { + node = node.parentNode; + } + + return node; + } + + function descendants(elm, selector) { + // Selector + try { + return slice.call(elm.querySelectorAll(selector)); + } catch (matchError) { + //console.log(matchError); + } + return local.query(elm, selector); + } + + function descendant(elm, selector) { + // Selector + try { + return elm.querySelector(selector); + } catch (matchError) { + //console.log(matchError); + } + var nodes = local.query(elm, selector); + if (nodes.length > 0) { + return nodes[0]; + } else { + return null; + } + } + + function find(selector) { + return descendant(document.body, selector); + } + + function findAll(selector) { + return descendants(document.body, selector); + } + + function firstChild(elm, selector, first) { + var childNodes = elm.childNodes, + node = childNodes[0]; + while (node) { + if (node.nodeType == 1) { + if (!selector || matches(node, selector)) { + return node; + } + if (first) { + break; + } + } + node = node.nextSibling; + } + + return null; + } + + function lastChild(elm, selector, last) { + var childNodes = elm.childNodes, + node = childNodes[childNodes.length - 1]; + while (node) { + if (node.nodeType == 1) { + if (!selector || matches(node, selector)) { + return node; + } + if (last) { + break; + } + } + node = node.previousSibling; + } + + return null; + } + + function matches(elm, selector) { + if (!selector || !elm || elm.nodeType !== 1) { + return false + } + + if (langx.isString(selector)) { + try { + return nativeMatchesSelector.call(elm, selector.replace(/\[([^=]+)=\s*([^'"\]]+?)\s*\]/g, '[$1="$2"]')); + } catch (matchError) { + //console.log(matchError); + } + return local.match(elm, selector) + } else { + return local.check(elm, selector); + } + + } + + function nextSibling(elm, selector, adjacent) { + var node = elm.nextSibling; + while (node) { + if (node.nodeType == 1) { + if (!selector || matches(node, selector)) { + return node; + } + if (adjacent) { + break; + } + } + node = node.nextSibling; + } + return null; + } + + function nextSiblings(elm, selector) { + var node = elm.nextSibling, + ret = []; + while (node) { + if (node.nodeType == 1) { + if (!selector || matches(node, selector)) { + ret.push(node); + } + } + node = node.nextSibling; + } + return ret; + } + + + function parent(elm, selector) { + var node = elm.parentNode; + if (node && (!selector || matches(node, selector))) { + return node; + } + + return null; + } + + function previousSibling(elm, selector, adjacent) { + var node = elm.previousSibling; + while (node) { + if (node.nodeType == 1) { + if (!selector || matches(node, selector)) { + return node; + } + if (adjacent) { + break; + } + } + node = node.previousSibling; + } + return null; + } + + function previousSiblings(elm, selector) { + var node = elm.previousSibling, + ret = []; + while (node) { + if (node.nodeType == 1) { + if (!selector || matches(node, selector)) { + ret.push(node); + } + } + node = node.previousSibling; + } + return ret; + } + + function siblings(elm, selector) { + var node = elm.parentNode.firstChild, + ret = []; + while (node) { + if (node.nodeType == 1 && node !== elm) { + if (!selector || matches(node, selector)) { + ret.push(node); + } + } + node = node.nextSibling; + } + return ret; + } + + var finder = function() { + return finder; + }; + + langx.mixin(finder, { + + ancestor: ancestor, + + ancestors: ancestors, + + byId: byId, + + children: children, + + closest: closest, + + descendant: descendant, + + descendants: descendants, + + find: find, + + findAll: findAll, + + firstChild: firstChild, + + lastChild: lastChild, + + matches: matches, + + nextSibling: nextSibling, + + nextSiblings: nextSiblings, + + parent: parent, + + previousSibling: previousSibling, + + previousSiblings: previousSiblings, + + pseudos: local.pseudos, + + siblings: siblings + }); + + return skylark.finder = finder; +}); +define('skylark-utils/datax',[ + "./skylark", + "./langx", + "./finder" +], function(skylark, langx, finder) { + var map = Array.prototype.map, + filter = Array.prototype.filter, + camelCase = langx.camelCase, + deserializeValue = langx.deserializeValue, + + capitalRE = /([A-Z])/g, + propMap = { + 'tabindex': 'tabIndex', + 'readonly': 'readOnly', + 'for': 'htmlFor', + 'class': 'className', + 'maxlength': 'maxLength', + 'cellspacing': 'cellSpacing', + 'cellpadding': 'cellPadding', + 'rowspan': 'rowSpan', + 'colspan': 'colSpan', + 'usemap': 'useMap', + 'frameborder': 'frameBorder', + 'contenteditable': 'contentEditable' + }; + + function setAttribute(elm, name, value) { + if (value == null) { + elm.removeAttribute(name); + } else { + elm.setAttribute(name, value); + } + } + + function attr(elm, name, value) { + if (value === undefined) { + if (typeof name === "object") { + for (var attrName in name) { + attr(elm, attrName, name[attrName]); + } + return this; + } else { + if (elm.hasAttribute(name)) { + return elm.getAttribute(name); + } + } + } else { + elm.setAttribute(name, value); + return this; + } + } + + // Read all "data-*" attributes from a node + function _attributeData(elm) { + var store = {} + langx.each(elm.attributes || [], function(i, attr) { + if (attr.name.indexOf('data-') == 0) { + store[camelCase(attr.name.replace('data-', ''))] = deserializeValue(attr.value); + } + }) + return store; + } + + function _store(elm, confirm) { + var store = elm["_$_store"]; + if (!store && confirm) { + store = elm["_$_store"] = _attributeData(elm); + } + return store; + } + + function _getData(elm, name) { + if (name === undefined) { + return _store(elm, true); + } else { + var store = _store(elm); + if (store) { + if (name in store) { + return store[name]; + } + var camelName = camelCase(name); + if (camelName in store) { + return store[camelName]; + } + } + var attrName = 'data-' + name.replace(capitalRE, "-$1").toLowerCase() + return attr(elm, attrName); + } + + } + + function _setData(elm, name, value) { + var store = _store(elm, true); + store[camelCase(name)] = value; + } + + + function data(elm, name, value) { + + if (value === undefined) { + if (typeof name === "object") { + for (var dataAttrName in name) { + _setData(elm, dataAttrName, name[dataAttrName]); + } + return this; + } else { + return _getData(elm, name); + } + } else { + _setData(elm, name, value); + return this; + } + } + + function removeData(elm, names) { + if (langx.isString(names)) { + names = names.split(/\s+/); + } + var store = _store(elm, true); + names.forEach(function(name) { + delete store[name]; + }); + return this; + } + + function pluck(nodes, property) { + return map.call(nodes, function(elm) { + return elm[property]; + }); + } + + function prop(elm, name, value) { + name = propMap[name] || name; + if (value === undefined) { + return elm[name]; + } else { + elm[name] = value; + return this; + } + } + + function removeAttr(elm, name) { + name.split(' ').forEach(function(attr) { + setAttribute(elm, attr); + }); + return this; + } + + function text(elm, txt) { + if (txt === undefined) { + return elm.textContent; + } else { + elm.textContent = txt == null ? '' : '' + txt; + return this; + } + } + + function val(elm, value) { + if (value === undefined) { + if (elm.multiple) { + // select multiple values + var selectedOptions = filter.call(finder.find(elm, "option"), (function(option) { + return option.selected; + })); + return pluck(selectedOptions, "value"); + } else { + return elm.value; + } + } else { + elm.value = value; + return this; + } + } + + function datax() { + return datax; + } + + langx.mixin(datax, { + attr: attr, + + data: data, + + pluck: pluck, + + prop: prop, + + removeAttr: removeAttr, + + removeData: removeData, + + text: text, + + val: val + }); + + return skylark.datax = datax; +}); + +define('skylarkjs/datax',[ + "skylark-utils/datax" +], function(datax) { + return datax; +}); + +define('skylark-utils/geom',[ + "./skylark", + "./langx", + "./styler" +], function(skylark, langx, styler) { + var rootNodeRE = /^(?:body|html)$/i, + px = langx.toPixel; + + function offsetParent(elm) { + var parent = elm.offsetParent || document.body; + while (parent && !rootNodeRE.test(parent.nodeName) && styler.css(parent, "position") == "static") { + parent = parent.offsetParent; + } + return parent; + } + + function borderExtents(elm) { + var s = getComputedStyle(elm); + return { + left: px(s.borderLeftWidth , elm), + top: px(s.borderTopWidth, elm), + right: px(s.borderRightWidth, elm), + bottom: px(s.borderBottomWidth, elm) + } + } + + //viewport coordinate + function boundingPosition(elm, coords) { + if (coords === undefined) { + return rootNodeRE.test(elm.nodeName) ? { top: 0, left: 0 } : elm.getBoundingClientRect(); + } else { + var // Get *real* offsetParent + parent = offsetParent(elm), + // Get correct offsets + parentOffset = boundingPosition(parent), + mex = marginExtents(elm), + pbex = borderExtents(parent); + + relativePosition(elm, { + top: coords.top - parentOffset.top - mex.top - pbex.top, + left: coords.left - parentOffset.left - mex.left - pbex.left + }); + return this; + } + } + + function boundingRect(elm, coords) { + if (coords === undefined) { + return elm.getBoundingClientRect() + } else { + boundingPosition(elm, coords); + size(elm, coords); + return this; + } + } + + function clientHeight(elm, value) { + if (value == undefined) { + return clientSize(elm).height; + } else { + return clientSize(elm, { + height: value + }); + } + } + + function clientSize(elm, dimension) { + if (dimension == undefined) { + return { + width: elm.clientWidth, + height: elm.clientHeight + } + } else { + var isBorderBox = (styler.css(elm, "box-sizing") === "border-box"), + props = { + width: dimension.width, + height: dimension.height + }; + if (!isBorderBox) { + var pex = paddingExtents(elm); + + if (props.width !== undefined) { + props.width = props.width - pex.left - pex.right; + } + + if (props.height !== undefined) { + props.height = props.height - pex.top - pex.bottom; + } + } else { + var bex = borderExtents(elm); + + if (props.width !== undefined) { + props.width = props.width + bex.left + bex.right; + } + + if (props.height !== undefined) { + props.height = props.height + bex.top + bex.bottom; + } + + } + styler.css(elm, props); + return this; + } + return { + width: elm.clientWidth, + height: elm.clientHeight + }; + } + + function clientWidth(elm, value) { + if (value == undefined) { + return clientSize(elm).width; + } else { + clientSize(elm, { + width: value + }); + return this; + } + } + + function contentRect(elm) { + var cs = clientSize(elm), + pex = paddingExtents(elm); + + + //// On Opera, offsetLeft includes the parent's border + //if(has("opera")){ + // pe.l += be.l; + // pe.t += be.t; + //} + return { + left: pex.left, + top: pex.top, + width: cs.width - pex.left - pex.right, + height: cs.height - pex.top - pex.bottom + }; + } + + function getDocumentSize(doc) { + var documentElement = doc.documentElement, + body = doc.body, + max = Math.max, + scrollWidth = max(documentElement.scrollWidth, body.scrollWidth), + clientWidth = max(documentElement.clientWidth, body.clientWidth), + offsetWidth = max(documentElement.offsetWidth, body.offsetWidth), + scrollHeight = max(documentElement.scrollHeight, body.scrollHeight), + clientHeight = max(documentElement.clientHeight, body.clientHeight), + offsetHeight = max(documentElement.offsetHeight, body.offsetHeight); + + return { + width: scrollWidth < offsetWidth ? clientWidth : scrollWidth, + height: scrollHeight < offsetHeight ? clientHeight : scrollHeight + }; + } + + function height(elm, value) { + if (value == undefined) { + return size(elm).height; + } else { + size(elm, { + height: value + }); + return this; + } + } + + function marginExtents(elm) { + var s = getComputedStyle(elm); + return { + left: px(s.marginLeft), + top: px(s.marginTop), + right: px(s.marginRight), + bottom: px(s.marginBottom), + } + } + + + function paddingExtents(elm) { + var s = getComputedStyle(elm); + return { + left: px(s.paddingLeft), + top: px(s.paddingTop), + right: px(s.paddingRight), + bottom: px(s.paddingBottom), + } + } + + //coordinate to the document + function pagePosition(elm, coords) { + if (coords === undefined) { + var obj = elm.getBoundingClientRect() + return { + left: obj.left + window.pageXOffset, + top: obj.top + window.pageYOffset + } + } else { + var // Get *real* offsetParent + parent = offsetParent(elm), + // Get correct offsets + parentOffset = pagePosition(parent), + mex = marginExtents(elm), + pbex = borderExtents(parent); + + relativePosition(elm, { + top: coords.top - parentOffset.top - mex.top - pbex.top, + left: coords.left - parentOffset.left - mex.left - pbex.left + }); + return this; + } + } + + function pageRect(elm, coords) { + if (coords === undefined) { + var obj = elm.getBoundingClientRect() + return { + left: obj.left + window.pageXOffset, + top: obj.top + window.pageYOffset, + width: Math.round(obj.width), + height: Math.round(obj.height) + } + } else { + pagePosition(elm, coords); + size(elm, coords); + return this; + } + } + + // coordinate relative to it's parent + function relativePosition(elm, coords) { + if (coords == undefined) { + var // Get *real* offsetParent + parent = offsetParent(elm), + // Get correct offsets + offset = boundingPosition(elm), + parentOffset = boundingPosition(parent), + mex = marginExtents(elm), + pbex = borderExtents(parent); + + // Subtract parent offsets and element margins + return { + top: offset.top - parentOffset.top - pbex.top - mex.top, + left: offset.left - parentOffset.left - pbex.left - mex.left + } + } else { + var props = { + top: coords.top, + left: coords.left + } + + if (styler.css(elm, "position") == "static") { + props['position'] = "relative"; + } + styler.css(elm, props); + return this; + } + } + + function relativeRect(elm, coords) { + if (coords === undefined) { + var // Get *real* offsetParent + parent = offsetParent(elm), + // Get correct offsets + offset = boundingRect(elm), + parentOffset = boundingPosition(parent), + mex = marginExtents(elm), + pbex = borderExtents(parent); + + // Subtract parent offsets and element margins + return { + top: offset.top - parentOffset.top - pbex.top - mex.top, + left: offset.left - parentOffset.left - pbex.left - mex.left, + width: offset.width, + height: offset.height + } + } else { + relativePosition(elm, coords); + size(elm, coords); + return this; + } + } + + function scrollIntoView(elm, align) { + function getOffset(elm, rootElm) { + var x, y, parent = elm; + + x = y = 0; + while (parent && parent != rootElm && parent.nodeType) { + x += parent.offsetLeft || 0; + y += parent.offsetTop || 0; + parent = parent.offsetParent; + } + + return { x: x, y: y }; + } + + var elm = this.getEl(), + parentElm = elm.parentNode; + var x, y, width, height, parentWidth, parentHeight; + var pos = getOffset(elm, parentElm); + + x = pos.x; + y = pos.y; + width = elm.offsetWidth; + height = elm.offsetHeight; + parentWidth = parentElm.clientWidth; + parentHeight = parentElm.clientHeight; + + if (align == "end") { + x -= parentWidth - width; + y -= parentHeight - height; + } else if (align == "center") { + x -= (parentWidth / 2) - (width / 2); + y -= (parentHeight / 2) - (height / 2); + } + + parentElm.scrollLeft = x; + parentElm.scrollTop = y; + + return this; + } + + function scrollLeft(elm, value) { + var hasScrollLeft = "scrollLeft" in elm; + if (value === undefined) { + return hasScrollLeft ? elm.scrollLeft : elm.pageXOffset + } else { + if (hasScrollLeft) { + elm.scrollLeft = value; + } else { + elm.scrollTo(value, elm.scrollY); + } + return this; + } + } + + function scrollTop(elm, value) { + var hasScrollTop = "scrollTop" in elm; + + if (value === undefined) { + return hasScrollTop ? elm.scrollTop : elm.pageYOffset + } else { + if (hasScrollTop) { + elm.scrollTop = value; + } else { + elm.scrollTo(elm.scrollX, value); + } + return this; + } + } + + function size(elm, dimension) { + if (dimension == undefined) { + if (langx.isWindow(elm)) { + return { + width: elm.innerWidth, + height: elm.innerHeight + } + + } else if (langx.isDocument(elm)) { + return getDocumentSize(document); + } else { + return { + width: elm.offsetWidth, + height: elm.offsetHeight + } + } + } else { + var isBorderBox = (styler.css(elm, "box-sizing") === "border-box"), + props = { + width: dimension.width, + height: dimension.height + }; + if (!isBorderBox) { + var pex = paddingExtents(elm), + bex = borderExtents(elm); + + if (props.width !== undefined) { + props.width = props.width - pex.left - pex.right - bex.left - bex.right; + } + + if (props.height !== undefined) { + props.height = props.height - pex.top - pex.bottom - bex.top - bex.bottom; + } + } + styler.css(elm, props); + return this; + } + } + + function width(elm, value) { + if (value == undefined) { + return size(elm).width; + } else { + size(elm, { + width: value + }); + return this; + } + } + + function geom() { + return geom; + } + + langx.mixin(geom, { + borderExtents: borderExtents, + //viewport coordinate + boundingPosition: boundingPosition, + + boundingRect: boundingRect, + + clientHeight: clientHeight, + + clientSize: clientSize, + + clientWidth: clientWidth, + + contentRect: contentRect, + + getDocumentSize: getDocumentSize, + + height: height, + + marginExtents: marginExtents, + + offsetParent: offsetParent, + + paddingExtents: paddingExtents, + + //coordinate to the document + pagePosition: pagePosition, + + pageRect: pageRect, + + // coordinate relative to it's parent + relativePosition: relativePosition, + + relativeRect: relativeRect, + + scrollIntoView: scrollIntoView, + + scrollLeft: scrollLeft, + + scrollTop: scrollTop, + + size: size, + + width: width + }); + + return skylark.geom = geom; +}); + +define('skylark-utils/eventer',[ + "./skylark", + "./langx", + "./browser", + "./finder", + "./noder", + "./datax" +], function(skylark, langx, browser, finder, noder, datax) { + var mixin = langx.mixin, + each = langx.each, + slice = Array.prototype.slice, + uid = langx.uid, + ignoreProperties = /^([A-Z]|returnValue$|layer[XY]$)/, + eventMethods = { + preventDefault: "isDefaultPrevented", + stopImmediatePropagation: "isImmediatePropagationStopped", + stopPropagation: "isPropagationStopped" + }, + readyRE = /complete|loaded|interactive/; + + function compatible(event, source) { + if (source || !event.isDefaultPrevented) { + if (!source) { + source = event; + } + + langx.each(eventMethods, function(name, predicate) { + var sourceMethod = source[name]; + event[name] = function() { + this[predicate] = langx.returnTrue; + return sourceMethod && sourceMethod.apply(source, arguments); + } + event[predicate] = langx.returnFalse; + }); + } + return event; + } + + function parse(event) { + var segs = ("" + event).split("."); + return { + type: segs[0], + ns: segs.slice(1).sort().join(" ") + }; + } + + //create a custom dom event + var createEvent = (function() { + var EventCtors = [ + window["CustomEvent"], // 0 default + window["CompositionEvent"], // 1 + window["DragEvent"], // 2 + window["Event"], // 3 + window["FocusEvent"], // 4 + window["KeyboardEvent"], // 5 + window["MessageEvent"], // 6 + window["MouseEvent"], // 7 + window["MouseScrollEvent"], // 8 + window["MouseWheelEvent"], // 9 + window["MutationEvent"], // 10 + window["ProgressEvent"], // 11 + window["TextEvent"], // 12 + window["TouchEvent"], // 13 + window["UIEvent"], // 14 + window["WheelEvent"] // 15 + ], + NativeEvents = { + "compositionstart": 1, // CompositionEvent + "compositionend": 1, // CompositionEvent + "compositionupdate": 1, // CompositionEvent + + "beforecopy": 2, // DragEvent + "beforecut": 2, // DragEvent + "beforepaste": 2, // DragEvent + "copy": 2, // DragEvent + "cut": 2, // DragEvent + "paste": 2, // DragEvent + + "drag": 2, // DragEvent + "dragend": 2, // DragEvent + "dragenter": 2, // DragEvent + "dragexit": 2, // DragEvent + "dragleave": 2, // DragEvent + "dragover": 2, // DragEvent + "dragstart": 2, // DragEvent + "drop": 2, // DragEvent + + "abort": 3, // Event + "change": 3, // Event + "error": 3, // Event + "selectionchange": 3, // Event + "submit": 3, // Event + "reset": 3, // Event + + "focus": 4, // FocusEvent + "blur": 4, // FocusEvent + "focusin": 4, // FocusEvent + "focusout": 4, // FocusEvent + + "keydown": 5, // KeyboardEvent + "keypress": 5, // KeyboardEvent + "keyup": 5, // KeyboardEvent + + "message": 6, // MessageEvent + + "click": 7, // MouseEvent + "contextmenu": 7, // MouseEvent + "dblclick": 7, // MouseEvent + "mousedown": 7, // MouseEvent + "mouseup": 7, // MouseEvent + "mousemove": 7, // MouseEvent + "mouseover": 7, // MouseEvent + "mouseout": 7, // MouseEvent + "mouseenter": 7, // MouseEvent + "mouseleave": 7, // MouseEvent + + + "textInput": 12, // TextEvent + + "touchstart": 13, // TouchEvent + "touchmove": 13, // TouchEvent + "touchend": 13, // TouchEvent + + "load": 14, // UIEvent + "resize": 14, // UIEvent + "select": 14, // UIEvent + "scroll": 14, // UIEvent + "unload": 14, // UIEvent, + + "wheel": 15 // WheelEvent + } + ; + + function getEventCtor(type) { + var idx = NativeEvents[type]; + if (!idx) { + idx = 0; + } + return EventCtors[idx]; + } + + return function(type, props) { + //create a custom dom event + + if (langx.isString(type)) { + props = props || {}; + } else { + props = type; + type = props.type; + } + var parsed = parse(type); + type = parsed.type; + + props = langx.mixin({ + bubbles: false, + cancelable: true + }, props); + + if (parsed.ns) { + props.namespace = parsed.ns; + } + + var ctor = getEventCtor(type), + e = new ctor(type, props); + + langx.safeMixin(e, props); + + return compatible(e); + }; + })(); + + function createProxy(event) { + var key, + proxy = { + originalEvent: event + }; + for (key in event) { + if (key !== "keyIdentifier" && !ignoreProperties.test(key) && event[key] !== undefined) { + proxy[key] = event[key]; + } + } + return compatible(proxy, event); + } + + var + specialEvents = {}, + focusinSupported = "onfocusin" in window, + focus = { focus: "focusin", blur: "focusout" }, + hover = { mouseenter: "mouseover", mouseleave: "mouseout" }, + realEvent = function(type) { + return hover[type] || (focusinSupported && focus[type]) || type; + }, + handlers = {}, + EventBindings = langx.klass({ + init: function(target, event) { + this._target = target; + this._event = event; + this._bindings = []; + }, + + add: function(fn, options) { + var bindings = this._bindings, + binding = { + fn: fn, + options: langx.mixin({}, options) + }; + + bindings.push(binding); + + var self = this; + if (!self._listener) { + self._listener = function(domEvt) { + var elm = this, + e = createProxy(domEvt), + args = domEvt._args, + binding = self._bindings, + ns = e.namespace; + + if (langx.isDefined(args)) { + args = [e].concat(args); + } else { + args = [e]; + } + + bindings.some(function(binding) { + var match = elm; + if (e.isImmediatePropagationStopped && e.isImmediatePropagationStopped()) { + return true; + } + var fn = binding.fn, + options = binding.options || {}, + selector = options.selector, + one = options.one, + data = options.data; + + if (ns && ns != options.ns) { + return false; + } + if (selector) { + match = finder.closest(e.target, selector); + if (match && match !== elm) { + langx.mixin(e, { + currentTarget: match, + liveFired: elm + }); + } else { + return false; + } + } + + if (langx.isDefined(data)) { + e.data = data; + } + + if (one) { + self.remove(fn, options); + } + + var result = fn.apply(match, args); + + if (result === false) { + e.preventDefault(); + e.stopPropagation(); + } + return false; + });; + }; + + var event = self._event; + if (event in hover) { + var l = self._listener; + self._listener = function(e) { + var related = e.relatedTarget; + if (!related || (related !== this && !noder.contains(this, related))) { + return l.apply(this, arguments); + } + } + } + + if (self._target.addEventListener) { + self._target.addEventListener(realEvent(event), self._listener, false); + } else { + console.warn("invalid eventer object", self._target); + } + } + + }, + remove: function(fn, options) { + options = langx.mixin({}, options); + + function matcherFor(ns) { + return new RegExp("(?:^| )" + ns.replace(" ", " .* ?") + "(?: |$)"); + } + var matcher; + if (options.ns) { + matcher = matcherFor(options.ns); + } + + this._bindings = this._bindings.filter(function(binding) { + var removing = (!fn || fn === binding.fn) && + (!matcher || matcher.test(binding.options.ns)) && + (!options.selector || options.selector == binding.options.selector); + + return !removing; + }); + if (this._bindings.length == 0) { + if (this._target.removeEventListener) { + this._target.removeEventListener(realEvent(this._event), this._listener, false); + } + this._listener = null; + } + } + }), + EventsHandler = langx.klass({ + init: function(elm) { + this._target = elm; + this._handler = {}; + }, + + // add a event listener + // selector Optional + register: function(event, callback, options) { + // Seperate the event from the namespace + var parsed = parse(event); + + event = parsed.type; + + var events = this._handler; + + // Check if there is already a handler for this event + if (events[event] === undefined) { + events[event] = new EventBindings(this._target, event); + } + + // Register the new callback function + events[event].add(callback, langx.mixin({ + ns: parsed.ns + }, options)); // options:{selector:xxx} + }, + + // remove a event listener + unregister: function(event, fn, options) { + // Check for parameter validtiy + var events = this._handler, + parsed = parse(event); + event = parsed.type; + + var listener = events[event]; + + if (listener) { + listener.remove(fn, langx.mixin({ + ns: parsed.ns + }, options)); + } + } + }), + + findHandler = function(elm) { + var id = uid(elm), + handler = handlers[id]; + if (!handler) { + handler = handlers[id] = new EventsHandler(elm); + } + return handler; + }; + + function off(elm, events, selector, callback) { + var $this = this + if (langx.isPlainObject(events)) { + langx.each(events, function(type, fn) { + off(elm, type, selector, fn); + }) + return $this; + } + + if (!langx.isString(selector) && !langx.isFunction(callback) && callback !== false) { + callback = selector; + selector = undefined; + } + + if (callback === false) { + callback = langx.returnFalse; + } + + if (typeof events == "string") { + if (events.indexOf(",") > -1) { + events = events.split(","); + } else { + events = events.split(/\s/); + } + } + + var handler = findHandler(elm); + + if (events) events.forEach(function(event) { + + handler.unregister(event, callback, { + selector: selector, + }); + }); + return this; + } + + function on(elm, events, selector, data, callback, one) { + + var autoRemove, delegator; + if (langx.isPlainObject(events)) { + langx.each(events, function(type, fn) { + on(elm, type, selector, data, fn, one); + }); + return this; + } + + if (!langx.isString(selector) && !langx.isFunction(callback)) { + callback = data; + data = selector; + selector = undefined; + } + + if (langx.isFunction(data)) { + callback = data; + data = undefined; + } + + if (callback === false) { + callback = langx.returnFalse; + } + + if (typeof events == "string") { + if (events.indexOf(",") > -1) { + events = events.split(","); + } else { + events = events.split(/\s/); + } + } + + var handler = findHandler(elm); + + events.forEach(function(event) { + if (event == "ready") { + return ready(callback); + } + handler.register(event, callback, { + data: data, + selector: selector, + one: !!one + }); + }); + return this; + } + + function one(elm, events, selector, data, callback) { + on(elm, events, selector, data, callback, 1); + + return this; + } + + function stop(event) { + if (window.document.all) { + event.keyCode = 0; + } + if (event.preventDefault) { + event.preventDefault(); + event.stopPropagation(); + } + return this; + } + + function trigger(evented, type, args) { + var e; + if (type instanceof Event) { + e = type; + } else { + e = createEvent(type, args); + } + e._args = args; + + (evented.dispatchEvent || evented.trigger).call(evented, e); + + return this; + } + + function ready(callback) { + // need to check if document.body exists for IE as that browser reports + // document ready when it hasn't yet created the body elm + if (readyRE.test(document.readyState) && document.body) { + callback() + } else { + document.addEventListener('DOMContentLoaded', callback, false); + } + + return this; + } + + var keyCodeLookup = { + "delete": 46 + }; + //example: + //shortcuts(elm).add("CTRL+ALT+SHIFT+X",function(){console.log("test!")}); + function shortcuts(elm) { + + var registry = datax.data(elm, "shortcuts"); + if (!registry) { + registry = {}; + datax.data(elm, "shortcuts", registry); + var run = function(shortcut, event) { + var n = event.metaKey || event.ctrlKey; + if (shortcut.ctrl == n && shortcut.alt == event.altKey && shortcut.shift == event.shiftKey) { + if (event.keyCode == shortcut.keyCode || event.charCode && event.charCode == shortcut.charCode) { + event.preventDefault(); + if ("keydown" == event.type) { + shortcut.fn(event); + } + return true; + } + } + }; + on(elm, "keyup keypress keydown", function(event) { + if (!(/INPUT|TEXTAREA/.test(event.target.nodeName))) { + for (var key in registry) { + run(registry[key], event); + } + } + }); + + } + + return { + add: function(pattern, fn) { + var shortcutKeys; + if (pattern.indexOf(",") > -1) { + shortcutKeys = pattern.toLowerCase().split(","); + } else { + shortcutKeys = pattern.toLowerCase().split(" "); + } + shortcutKeys.forEach(function(shortcutKey) { + var setting = { + fn: fn, + alt: false, + ctrl: false, + shift: false + }; + shortcutKey.split("+").forEach(function(key) { + switch (key) { + case "alt": + case "ctrl": + case "shift": + setting[key] = true; + break; + default: + setting.charCode = key.charCodeAt(0); + setting.keyCode = keyCodeLookup[key] || key.toUpperCase().charCodeAt(0); + } + }); + var regKey = (setting.ctrl ? "ctrl" : "") + "," + (setting.alt ? "alt" : "") + "," + (setting.shift ? "shift" : "") + "," + setting.keyCode; + registry[regKey] = setting; + }) + } + + }; + + } + + function eventer() { + return eventer; + } + + langx.mixin(eventer, { + create: createEvent, + + off: off, + + on: on, + + one: one, + + proxy: createProxy, + + ready: ready, + + shortcuts: shortcuts, + + stop: stop, + + trigger: trigger, + + }); + + return skylark.eventer = eventer; +}); + +define('skylark-utils/dnd',[ + "./skylark", + "./langx", + "./noder", + "./datax", + "./geom", + "./eventer", + "./styler" +],function(skylark, langx,noder,datax,geom,eventer,styler){ + var on = eventer.on, + off = eventer.off, + attr = datax.attr, + removeAttr = datax.removeAttr, + offset = geom.pagePosition, + addClass = styler.addClass, + height = geom.height; + + + var DndManager = langx.Evented.inherit({ + klassName : "DndManager", + + init : function() { + + }, + + start : function(draggable,event) { + + var p = geom.pagePosition(draggable.elm); + this.draggingOffsetX = parseInt(event.pageX - p.left); + this.draggingOffsetY = parseInt(event.pageY - p.top) + + var e = eventer.create("started",{ + ghost : null, + transfer : { + } + }); + + draggable.trigger(e); + + this.dragging = draggable; + this.draggingGhost = e.ghost; + if (!this.draggingGhost) { + this.draggingGhost = draggable.elm; + } + + this.draggingTransfer = e.transfer; + if (this.draggingTransfer) { + + langx.each(this.draggingTransfer,function(key,value){ + event.dataTransfer.setData(key, value); + }); + } + + event.dataTransfer.setDragImage(this.draggingGhost, this.draggingOffsetX, this.draggingOffsetY); + + event.dataTransfer.effectAllowed = "copyMove"; + + this.trigger(e); + }, + + end : function() { + var e = eventer.create("ended",{ + }); + this.trigger(e); + + this.dragging = null; + this.draggingTransfer = null; + this.draggingGhost = null; + this.draggingOffsetX = null; + this.draggingOffsetY = null; + } + }); + + var manager = new DndManager(), + draggingHeight, + placeholders = []; + + + + var Draggable = langx.Evented.inherit({ + klassName : "Draggable", + + init : function (elm,params) { + var self = this, + draggingClass = params.draggingClass || "dragging", + allowed = false; + + self.elm = elm; + self._params = params; + + ["started", "ended", "moving"].forEach(function(eventName) { + if (langx.isFunction(params[eventName])) { + self.on(eventName, params[eventName]); + } + }); + + + eventer.on(elm,{ + "mousedown" : function(e) { + if (allowed === true) { + datax.prop(self.elm, "draggable", true); + } + }, + + "mouseup" : function(e) { + datax.prop(self.elm, "draggable", false); + }, + + "dragstart": function(e) { + manager.start(self, e); + styler.addClass(self.elm,draggingClass); + }, + + "dragend": function(e){ + eventer.stop(e); + + if (!manager.dragging) { + return; + } + + styler.removeClass(self.elm,draggingClass); + + manager.end(); + } + }); + + if (params.handle) { + eventer.on(elm,{ + "mouseenter" : function(e) { + allowed = true; + }, + "mouseleave" : function(e) { + allowed = false; + } + },params.handle); + } else { + allowed = true; + } + + } + + }); + + + var Droppable = langx.Evented.inherit({ + klassName : "Droppable", + + init : function(elm,params) { + var self = this, + draggingClass = params.draggingClass || "dragging", + hoverClass, + activeClass, + acceptable = true; + + self.elm = elm; + self._params = params; + + ["started","ended","entered", "leaved", "dropped","overing"].forEach(function(eventName) { + if (langx.isFunction(params[eventName])) { + self.on(eventName, params[eventName]); + } + }); + + eventer.on(elm,{ + "dragover" : function(e) { + e.stopPropagation() + + if (!acceptable) { + return + } + + var e2 = eventer.create("overing",{ + transfer : manager.draggingTransfer + }); + self.trigger(e2); + + e.preventDefault() // allow drop + + e.dataTransfer.dropEffect = "copyMove"; + + }, + + "dragenter" : function(e) { + var params = self._params, + elm = self.elm; + + var e2 = eventer.create("entered",{ + transfer : manager.draggingTransfer + }); + + self.trigger(e2); + + e.stopPropagation() + + if (hoverClass && acceptable) { + styler.addClass(elm,hoverClass) + } + }, + + "dragleave": function(e) { + var params = self._params, + elm = self.elm; + if (!acceptable) return false + + var e2 = eventer.create("leaved",{ + transfer : manager.draggingTransfer + }); + + self.trigger(e2); + + e.stopPropagation() + + if (hoverClass && acceptable) { + styler.removeClass(elm,hoverClass); + } + }, + + "drop": function(e){ + var params = self._params, + elm = self.elm; + + eventer.stop(e); // stops the browser from redirecting. + + if (!manager.dragging) return + + // manager.dragging.elm.removeClass('dragging'); + + if (hoverClass && acceptable) { + styler.addClass(elm,hoverClass) + } + + var e2 = eventer.create("dropped",{ + transfer : manager.draggingTransfer + }); + + self.trigger(e2); + + manager.end() + } + }); + + manager.on("started",function(e){ + var e2 = eventer.create("started",{ + transfer : manager.draggingTransfer, + acceptable : false + }); + + self.trigger(e2); + + acceptable = e2.acceptable; + hoverClass = e2.hoverClass; + activeClass = e2.activeClass; + + if (activeClass && acceptable) { + styler.addClass(elm,activeClass); + } + + }).on("ended" , function(e){ + var e2 = eventer.create("ended",{ + transfer : manager.draggingTransfer, + acceptable : false + }); + + self.trigger(e2); + + if (hoverClass && acceptable) { + styler.removeClass(elm,hoverClass); + } + if (activeClass && acceptable) { + styler.removeClass(elm,activeClass); + } + + acceptable = false; + activeClass = null; + hoverClass = null; + }); + + } + }); + + + function draggable(elm, params) { + return new Draggable(elm,params); + } + + function droppable(elm, params) { + return new Droppable(elm,params); + } + + function dnd(){ + return dnd; + } + + langx.mixin(dnd, { + //params : { + // target : Element or string or function + // handle : Element + // copy : boolean + // placeHolder : "div" + // hoverClass : "hover" + // start : function + // enter : function + // over : function + // leave : function + // drop : function + // end : function + // + // + //} + draggable : draggable, + + //params : { + // accept : string or function + // placeHolder + // + // + // + //} + droppable : droppable, + + manager : manager + + + }); + + return skylark.dnd = dnd; +}); + +define('skylarkjs/dnd',[ + "skylark-utils/dnd" +], function(dnd) { + return dnd; +}); + +define('skylarkjs/eventer',[ + "skylark-utils/eventer" +], function(eventer) { + return eventer; +}); + +define('skylark-utils/filer',[ + "./skylark", + "./langx", + "./eventer", + "./styler" +], function(skylark, langx, eventer,styler) { + var on = eventer.on, + attr = eventer.attr, + Deferred = langx.Deferred, + + fileInput, + fileInputForm, + fileSelected, + maxFileSize = 1 / 0; + + function selectFile(callback) { + fileSelected = callback; + if (!fileInput) { + var input = fileInput = document.createElement("input"); + + function selectFiles(pickedFiles) { + for (var i = pickedFiles.length; i--;) { + if (pickedFiles[i].size > maxFileSize) { + pickedFiles.splice(i, 1); + } + } + fileSelected(pickedFiles); + } + + input.type = "file"; + input.style.position = "fixed", + input.style.left = 0, + input.style.top = 0, + input.style.opacity = .001, + document.body.appendChild(input); + + input.onchange = function(e) { + selectFiles(Array.prototype.slice.call(e.target.files)); + // reset to "", so selecting the same file next time still trigger the change handler + input.value = ""; + }; + } + fileInput.click(); + } + + function upload(files, url, params) { + params = params || {}; + var chunkSize = params.chunkSize || 0, + maxSize = params.maxSize || 0, + progressCallback = params.progress, + errorCallback = params.error, + completedCallback = params.completed, + uploadedCallback = params.uploaded; + + + function uploadOneFile(fileItem,oneFileloadedSize, fileItems) { + function handleProcess(nowLoadedSize) { + var t; + speed = Math.ceil(oneFileloadedSize + nowLoadedSize / ((now() - uploadStartedTime) / 1e3)), + percent = Math.round((oneFileloadedSize + nowLoadedSize) / file.size * 100); + if (progressCallback) { + progressCallback({ + name: file.name, + loaded: oneFileloadedSize + nowLoadedSize, + total: file.size, + percent: percent, + bytesPerSecond: speed, + global: { + loaded: allLoadedSize + oneFileloadedSize + nowLoadedSize, + total: totalSize + } + }); + } + } + var file = fileItem.file, + uploadChunkSize = chunkSize || file.size, + chunk = file.slice(oneFileloadedSize, oneFileloadedSize + uploadChunkSize); + + xhr = createXmlHttpRequest(); + //xhr.open("POST", url + + // "?action=upload&path=" + + // encodeURIComponent(path) + + // "&name=" + encodeURIComponent(file.name) + + // "&loaded=" + oneFileloadedSize + + // "&total=" + file.size + + // "&id=" + id + + // "&csrf=" + encodeURIComponent(token) + + // "&resolution=" + + // encodeURIComponent(fileItem.type)); + xhr.upload.onprogress = function(event) { + handleProcess(event.loaded - (event.total - h.size)) + }; + xhr.onload = function() { + var response, i; + xhr.upload.onprogress({ + loaded: h.size, + total: h.size + }); + try { + response = JSON.parse(xhr.responseText); + } catch (e) { + i = { + code: -1, + message: "Error response is not proper JSON\n\nResponse:\n" + xhr.responseText, + data: { + fileName: file.name, + fileSize: file.size, + maxSize: uploadMaxSize, + extensions: extensions.join(", ") + }, + extra: extra + }; + errorFileInfos.push(i); + if (errorCallback) { + errorCallback(i); + } + return uploadFiles(fileItems) + } + if (response.error) { + + i = { + code: response.error.code, + message: response.error.message, + data: { + fileName: file.name, + fileSize: file.size, + maxSize: uploadMaxSize, + extensions: extensions.join(", ") + }, + extra: extra + }; + errorFileInfos.push(i); + if (errorCallback) { + errorCallback(i); + } + uploadFiles(fileItems); + } else { + if (!response.error && oneFileloadedSize + uploadChunkSize < file.size) { + uploadOneFile(fileItem, oneFileloadedSize + uploadChunkSize, fileItems); + } else { + if (response.result) { + utils.each(response.result, function(e) { + e = File.fromJSON(e); + uploadFileItems.push(e); + + if (uploadedCallback) { + uploadedCallback({ + file: e + }); + } + }); + + } + allLoadedSize += file.size; + response.result && k.push(response.result); + uploadFiles(fileItems); + } + } + + }; + handleProcess(0); + xhr.send(createFormData(h)); + } + + function uploadFiles(fileItems) { + var fileItem = fileItems.shift(); + processedFilesCount++; + if (fileItem && fileItem.file.error) { + uploadFiles(fileItem); + } else { + if (uploadingFile) { + uploadOneFile(fileItem, null, 0, fileItems); + } else { + + if (completedCallback) { + completedCallback({ + files: new FileCollection(uploadFileItems), + bytesPerSecond: I, + errors: E(D), + extra: extra + }); + } + } + } + } + + var self = this, + fileItems = [], + processedFilesCount = -1, + xhr, + totalSize = 0, + allLoadedSize = 0, + k = [], + errorFileInfos = [], + startedTime = now(), + I = 0, + uploadFileItems = []; + + for ( var i = 0; i < files.length; i++) { + totalSize += files[i].size; + fileItems.push({ + file : files[i] + }); + } + + uploadFiles(fileItems); + } + + + var filer = function() { + return filer; + }; + + langx.mixin(filer , { + dropzone: function(elm, params) { + params = params || {}; + var hoverClass = params.hoverClass || "dropzone", + droppedCallback = params.dropped; + + var enterdCount = 0; + on(elm, "dragenter", function(e) { + if (e.dataTransfer && e.dataTransfer.types.indexOf("Files")>-1) { + eventer.stop(e); + enterdCount ++; + styler.addClass(elm,hoverClass) + } + }); + + on(elm, "dragover", function(e) { + if (e.dataTransfer && e.dataTransfer.types.indexOf("Files")>-1) { + eventer.stop(e); + } + }); + + + on(elm, "dragleave", function(e) { + if (e.dataTransfer && e.dataTransfer.types.indexOf("Files")>-1) { + enterdCount-- + if (enterdCount==0) { + styler.removeClass(elm,hoverClass); + } + } + }); + + on(elm, "drop", function(e) { + if (e.dataTransfer && e.dataTransfer.types.indexOf("Files")>-1) { + styler.removeClass(elm,hoverClass) + eventer.stop(e); + if (droppedCallback) { + droppedCallback(e.dataTransfer.files); + } + } + }); + + + return this; + }, + + picker: function(elm, params) { + params = params || {}; + + var pickedCallback = params.picked; + + on(elm, "click", function(e) { + e.preventDefault(); + selectFile(pickedCallback); + }); + return this; + }, + + readFile : function(file,params) { + params = params || {}; + var d = new Deferred, + reader = new FileReader(); + + reader.onload = function(evt) { + d.resolve(evt.target.result); + }; + reader.onerror = function(e) { + var code = e.target.error.code; + if (code === 2) { + alert('please don\'t open this page using protocol fill:///'); + } else { + alert('error code: ' + code); + } + }; + + if (params.asArrayBuffer){ + reader.readAsArrayBuffer(file); + } else if (params.asDataUrl) { + reader.readAsDataURL(file); + } else if (params.asText) { + reader.readAsText(file); + } else { + reader.readAsArrayBuffer(file); + } + + return d.promise; + }, + + writeFile : function(dataUri,name) { + if (window.navigator.msSaveBlob) { +   var blob = dataURItoBlob(dataUri); + window.navigator.msSaveBlob(blob, name); + } else { + var a = document.createElement('a'); + a.href = dataUri; + a.setAttribute('download', name || 'noname'); + a.dispatchEvent(new CustomEvent('click')); + } + } + + + }); + + return skylark.filer = filer; +}); + +define('skylarkjs/filer',[ + "skylark-utils/filer" +], function(filer) { + return filer; +}); + +define('skylarkjs/finder',[ + "skylark-utils/finder" +], function(finder) { + return finder; +}); + +define('skylark-utils/fx',[ + "./skylark", + "./langx", + "./browser", + "./styler", + "./eventer" +], function(skylark, langx, browser, styler, eventer) { + var animationName, + animationDuration, + animationTiming, + animationDelay, + transitionProperty, + transitionDuration, + transitionTiming, + transitionDelay, + + animationEnd = browser.normalizeCssEvent('AnimationEnd'), + transitionEnd = browser.normalizeCssEvent('TransitionEnd'), + + supportedTransforms = /^((translate|rotate|scale)(X|Y|Z|3d)?|matrix(3d)?|perspective|skew(X|Y)?)$/i, + transform = browser.css3PropPrefix + "transform", + cssReset = {}; + + + cssReset[animationName = browser.normalizeCssProperty("animation-name")] = + cssReset[animationDuration = browser.normalizeCssProperty("animation-duration")] = + cssReset[animationDelay = browser.normalizeCssProperty("animation-delay")] = + cssReset[animationTiming = browser.normalizeCssProperty("animation-timing-function")] = ""; + + cssReset[transitionProperty = browser.normalizeCssProperty("transition-property")] = + cssReset[transitionDuration = browser.normalizeCssProperty("transition-duration")] = + cssReset[transitionDelay = browser.normalizeCssProperty("transition-delay")] = + cssReset[transitionTiming = browser.normalizeCssProperty("transition-timing-function")] = ""; + + + + function animate(elm, properties, duration, ease, callback, delay) { + var key, + cssValues = {}, + cssProperties = [], + transforms = "", + that = this, + endEvent, + wrappedCallback, + fired = false, + hasScrollTop = false; + + if (langx.isPlainObject(duration)) { + ease = duration.easing; + callback = duration.complete; + delay = duration.delay; + duration = duration.duration; + } + + if (langx.isString(duration)) { + duration = fx.speeds[duration]; + } + if (duration === undefined) { + duration = fx.speeds.normal; + } + duration = duration / 1000; + if (fx.off) { + duration = 0; + } + + if (langx.isFunction(ease)) { + callback = ease; + eace = "swing"; + } else { + ease = ease || "swing"; + } + + if (delay) { + delay = delay / 1000; + } else { + delay = 0; + } + + if (langx.isString(properties)) { + // keyframe animation + cssValues[animationName] = properties; + cssValues[animationDuration] = duration + "s"; + cssValues[animationTiming] = ease; + endEvent = animationEnd; + } else { + // CSS transitions + for (key in properties) { + if (supportedTransforms.test(key)) { + transforms += key + "(" + properties[key] + ") "; + } else { + if (key === "scrollTop") { + hasScrollTop = true; + } + cssValues[key] = properties[key]; + cssProperties.push(langx.dasherize(key)); + } + } + endEvent = transitionEnd; + } + + if (transforms) { + cssValues[transform] = transforms; + cssProperties.push(transform); + } + + if (duration > 0 && langx.isPlainObject(properties)) { + cssValues[transitionProperty] = cssProperties.join(", "); + cssValues[transitionDuration] = duration + "s"; + cssValues[transitionDelay] = delay + "s"; + cssValues[transitionTiming] = ease; + } + + wrappedCallback = function(event) { + fired = true; + if (event) { + if (event.target !== event.currentTarget) { + return // makes sure the event didn't bubble from "below" + } + eventer.off(event.target, endEvent, wrappedCallback) + } else { + eventer.off(elm, animationEnd, wrappedCallback) // triggered by setTimeout + } + styler.css(elm, cssReset); + callback && callback.call(this); + }; + + if (duration > 0) { + eventer.on(elm, endEvent, wrappedCallback); + // transitionEnd is not always firing on older Android phones + // so make sure it gets fired + langx.debounce(function() { + if (fired) { + return; + } + wrappedCallback.call(that); + }, ((duration + delay) * 1000) + 25)(); + } + + // trigger page reflow so new elements can animate + elm.clientLeft; + + styler.css(elm, cssValues); + + if (duration <= 0) { + langx.debounce(function() { + if (fired) { + return; + } + wrappedCallback.call(that); + }, 0)(); + } + + if (hasScrollTop) { + scrollToTop(elm, properties["scrollTop"], duration, callback); + } + + return this; + } + + function show(elm, speed, callback) { + styler.show(elm); + if (speed) { + if (!callback && langx.isFunction(speed)) { + callback = speed; + speed = "normal"; + } + styler.css(elm, "opacity", 0) + animate(elm, { opacity: 1, scale: "1,1" }, speed, callback); + } + return this; + } + + + function hide(elm, speed, callback) { + if (speed) { + if (!callback && langx.isFunction(speed)) { + callback = speed; + speed = "normal"; + } + animate(elm, { opacity: 0, scale: "0,0" }, speed, function() { + styler.hide(elm); + if (callback) { + callback.call(elm); + } + }); + } else { + styler.hide(elm); + } + return this; + } + + function scrollToTop(elm, pos, speed, callback) { + var scrollFrom = parseInt(elm.scrollTop), + i = 0, + runEvery = 5, // run every 5ms + freq = speed * 1000 / runEvery, + scrollTo = parseInt(pos); + + var interval = setInterval(function() { + i++; + + if(i<=freq) elm.scrollTop = (scrollTo - scrollFrom) / freq * i + scrollFrom; + + if (i >= freq + 1) { + clearInterval(interval); + if (callback) langx.debounce(callback, 1000)(); + } + }, runEvery); + } + + function toggle(elm, speed, callback) { + if (styler.isInvisible(elm)) { + show(elm, speed, callback); + } else { + hide(elm, speed, callback); + } + return this; + } + + function fadeTo(elm, speed, opacity, callback) { + animate(elm, { opacity: opacity }, speed, callback); + return this; + } + + function fadeIn(elm, speed, callback) { + var target = styler.css(elm, "opacity"); + if (target > 0) { + styler.css(elm, "opacity", 0); + } else { + target = 1; + } + styler.show(elm); + + fadeTo(elm, speed, target, callback); + + return this; + } + + function fadeOut(elm, speed, callback) { + + fadeTo(elm, speed, 0, function() { + styler.hide(elm); + if (callback) { + callback.call(elm); + } + + }); + + return this; + } + + function fadeToggle(elm, speed, callback) { + if (styler.isInvisible(elm)) { + fadeIn(elm, speed, callback); + } else { + fadeOut(elm, speed, callback); + } + return this; + } + + function fx() { + return fx; + } + + langx.mixin(fx, { + off: false, + + speeds: { + normal: 400, + fast: 200, + slow: 600 + }, + + animate: animate, + fadeIn: fadeIn, + fadeOut: fadeOut, + fadeTo: fadeTo, + fadeToggle: fadeToggle, + hide: hide, + scrollToTop: scrollToTop, + show: show, + toggle: toggle + }); + + return skylark.fx = fx; +}); + +define('skylarkjs/fx',[ + "skylark-utils/fx" +], function(fx) { + return fx; +}); + +define('skylarkjs/geom',[ + "skylark-utils/geom" +], function(geom) { + return geom; +}); + +define('skylark-utils/mover',[ + "./skylark", + "./langx", + "./noder", + "./datax", + "./geom", + "./eventer", + "./styler" +],function(skylark, langx,noder,datax,geom,eventer,styler){ + var on = eventer.on, + off = eventer.off, + attr = datax.attr, + removeAttr = datax.removeAttr, + offset = geom.pagePosition, + addClass = styler.addClass, + height = geom.height; + + + function movable(elm, params) { + function updateWithTouchData(e) { + var keys, i; + + if (e.changedTouches) { + keys = "screenX screenY pageX pageY clientX clientY".split(' '); + for (i = 0; i < keys.length; i++) { + e[keys[i]] = e.changedTouches[0][keys[i]]; + } + } + } + + params = params || {}; + var handleEl = params.handle || elm, + constraints = params.constraints, + overlayDiv, + doc = params.document || document, + downButton, + start, + stop, + drag, + startX, + startY, + originalPos, + size, + startedCallback = params.started, + movingCallback = params.moving, + stoppedCallback = params.stopped, + + start = function(e) { + var docSize = geom.getDocumentSize(doc), + cursor; + + updateWithTouchData(e); + + e.preventDefault(); + downButton = e.button; + //handleEl = getHandleEl(); + startX = e.screenX; + startY = e.screenY; + + originalPos = geom.relativePosition(elm); + size = geom.size(elm); + + // Grab cursor from handle so we can place it on overlay + cursor = styler.css(handleEl, "curosr"); + + overlayDiv = noder.createElement("div"); + styler.css(overlayDiv, { + position: "absolute", + top: 0, + left: 0, + width: docSize.width, + height: docSize.height, + zIndex: 0x7FFFFFFF, + opacity: 0.0001, + cursor: cursor + }); + noder.append(doc.body, overlayDiv); + + eventer.on(doc, "mousemove touchmove", move).on(doc, "mouseup touchend", stop); + + if (startedCallback) { + startedCallback(e); + } + }, + + move = function(e) { + updateWithTouchData(e); + + if (e.button !== 0) { + return stop(e); + } + + e.deltaX = e.screenX - startX; + e.deltaY = e.screenY - startY; + + var l = originalPos.left + e.deltaX, + t = originalPos.top + e.deltaY; + if (constraints) { + + if (l < constraints.minX) { + l = constraints.minX; + } + + if (l > constraints.maxX) { + l = constraints.maxX; + } + + if (t < constraints.minY) { + t = constraints.minY; + } + + if (t > constraints.maxY) { + t = constraints.maxY; + } + } + geom.relativePosition(elm, { + left: l, + top: t + }) + + e.preventDefault(); + if (movingCallback) { + movingCallback(e); + } + }, + + stop = function(e) { + updateWithTouchData(e); + + eventer.off(doc, "mousemove touchmove", move).off(doc, "mouseup touchend", stop); + + noder.remove(overlayDiv); + + if (stoppedCallback) { + stoppedCallback(e); + } + }; + + eventer.on(handleEl, "mousedown touchstart", start); + + return { + // destroys the dragger. + remove: function() { + eventer.off(handleEl); + } + } + } + + function mover(){ + return mover; + } + + langx.mixin(mover, { + + movable: movable + + }); + + return skylark.mover = mover; +}); + +define('skylarkjs/mover',[ + "skylark-utils/mover" +], function(mover) { + return mover; +}); + +define('skylarkjs/noder',[ + "skylark-utils/noder" +], function(noder) { + return noder; +}); + +define('skylark-utils/query',[ + "./skylark", + "./langx", + "./noder", + "./datax", + "./eventer", + "./finder", + "./geom", + "./styler", + "./fx" +], function(skylark, langx, noder, datax, eventer, finder, geom, styler, fx) { + var some = Array.prototype.some, + push = Array.prototype.push, + every = Array.prototype.every, + concat = Array.prototype.concat, + slice = Array.prototype.slice, + map = Array.prototype.map, + filter = Array.prototype.filter, + forEach = Array.prototype.forEach, + isQ; + + var rquickExpr = /^(?:[^#<]*(<[\w\W]+>)[^>]*$|#([\w\-]*)$)/; + + var funcArg = langx.funcArg, + isArrayLike = langx.isArrayLike, + isString = langx.isString, + uniq = langx.uniq, + isFunction = langx.isFunction; + + var type = langx.type, + isArray = langx.isArray, + + isWindow = langx.isWindow, + + isDocument = langx.isDocument, + + isObject = langx.isObject, + + isPlainObject = langx.isPlainObject, + + compact = langx.compact, + + flatten = langx.flatten, + + camelCase = langx.camelCase, + + dasherize = langx.dasherize, + children = finder.children; + + function wrapper_map(func, context) { + return function() { + var self = this, + params = slice.call(arguments); + var result = $.map(self, function(elem, idx) { + return func.apply(context, [elem].concat(params)); + }); + return $(uniq(result)); + } + } + + function wrapper_selector(func, context, last) { + return function(selector) { + var self = this, + params = slice.call(arguments); + var result = this.map(function(idx, elem) { + return func.apply(context, last ? [elem] : [elem, selector]); + }); + if (last && selector) { + return result.filter(selector); + } else { + return result; + } + } + } + + function wrapper_every_act(func, context) { + return function() { + var self = this, + params = slice.call(arguments); + this.each(function(idx) { + func.apply(context, [this].concat(params)); + }); + return self; + } + } + + function wrapper_every_act_firstArgFunc(func, context, oldValueFunc) { + return function(arg1) { + var self = this, + params = slice.call(arguments); + forEach.call(self, function(elem, idx) { + var newArg1 = funcArg(elem, arg1, idx, oldValueFunc(elem)); + func.apply(context, [elem, arg1].concat(params.slice(1))); + }); + return self; + } + } + + function wrapper_some_chk(func, context) { + return function() { + var self = this, + params = slice.call(arguments); + return some.call(self, function(elem) { + return func.apply(context, [elem].concat(params)); + }); + } + } + + function wrapper_name_value(func, context, oldValueFunc) { + return function(name, value) { + var self = this, + params = slice.call(arguments); + + if (langx.isPlainObject(name) || langx.isDefined(value)) { + forEach.call(self, function(elem, idx) { + var newValue; + if (oldValueFunc) { + newValue = funcArg(elem, value, idx, oldValueFunc(elem)); + } else { + newValue = value + } + func.apply(context, [elem].concat(params)); + }); + return self; + } else { + if (self[0]) { + return func.apply(context, [self[0], name]); + } + } + + } + } + + function wrapper_value(func, context, oldValueFunc) { + return function(value) { + var self = this; + + if (langx.isDefined(value)) { + forEach.call(self, function(elem, idx) { + var newValue; + if (oldValueFunc) { + newValue = funcArg(elem, value, idx, oldValueFunc(elem)); + } else { + newValue = value + } + func.apply(context, [elem, newValue]); + }); + return self; + } else { + if (self[0]) { + return func.apply(context, [self[0]]); + } + } + + } + } + + var NodeList = langx.klass({ + klassName: "SkNodeList", + init: function(selector, context) { + var self = this, + match, nodes, node, props; + + if (selector) { + self.context = context = context || noder.doc(); + + if (isString(selector)) { + // a html string or a css selector is expected + self.selector = selector; + + if (selector.charAt(0) === "<" && selector.charAt(selector.length - 1) === ">" && selector.length >= 3) { + match = [null, selector, null]; + } else { + match = rquickExpr.exec(selector); + } + + if (match) { + if (match[1]) { + // if selector is html + nodes = noder.createFragment(selector); + + if (langx.isPlainObject(context)) { + props = context; + } + + } else { + node = finder.byId(match[2], noder.ownerDoc(context)); + + if (node) { + // if selector is id + nodes = [node]; + } + + } + } else { + // if selector is css selector + nodes = finder.descendants(context, selector); + } + } else { + if (isArray(selector)) { + // a dom node array is expected + nodes = selector; + } else { + // a dom node is expected + nodes = [selector]; + } + //self.add(selector, false); + } + } + + + if (nodes) { + push.apply(self, nodes); + + if (props) { + self.attr(props); + } + } + + return self; + } + }, Array); + + var query = (function() { + isQ = function(object) { + return object instanceof NodeList; + } + init = function(selector, context) { + return new NodeList(selector, context); + } + + var $ = function(selector, context) { + if (isFunction(selector)) { + eventer.ready(function() { + selector($); + }); + } else if (isQ(selector)) { + return selector; + } else { + if (context && isQ(context) && isString(selector)) { + return context.find(selector); + } + return init(selector, context); + } + }; + + $.fn = NodeList.prototype; + langx.mixin($.fn, { + // `map` and `slice` in the jQuery API work differently + // from their array counterparts + + map: function(fn) { + return $(langx.map(this, function(el, i) { + return fn.call(el, i, el) + })) + }, + + slice: function() { + return $(slice.apply(this, arguments)) + }, + + get: function(idx) { + return idx === undefined ? slice.call(this) : this[idx >= 0 ? idx : idx + this.length] + }, + + toArray: function() { + return slice.call(this); + }, + + size: function() { + return this.length + }, + + remove: wrapper_every_act(noder.remove, noder), + + each: function(callback) { + langx.each(this, callback); + return this; + }, + + filter: function(selector) { + if (isFunction(selector)) return this.not(this.not(selector)) + return $(filter.call(this, function(element) { + return finder.matches(element, selector) + })) + }, + + add: function(selector, context) { + return $(uniq(this.concat($(selector, context)))) + }, + + is: function(selector) { + return this.length > 0 && finder.matches(this[0], selector) + }, + + not: function(selector) { + var nodes = [] + if (isFunction(selector) && selector.call !== undefined) + this.each(function(idx) { + if (!selector.call(this, idx)) nodes.push(this) + }) + else { + var excludes = typeof selector == 'string' ? this.filter(selector) : + (isArrayLike(selector) && isFunction(selector.item)) ? slice.call(selector) : $(selector) + this.forEach(function(el) { + if (excludes.indexOf(el) < 0) nodes.push(el) + }) + } + return $(nodes) + }, + + has: function(selector) { + return this.filter(function() { + return isObject(selector) ? + noder.contains(this, selector) : + $(this).find(selector).size() + }) + }, + + eq: function(idx) { + return idx === -1 ? this.slice(idx) : this.slice(idx, +idx + 1); + }, + + first: function() { + return this.eq(0); + }, + + last: function() { + return this.eq(-1); + }, + + find: wrapper_selector(finder.descendants, finder), + + closest: function(selector, context) { + var node = this[0], + collection = false + if (typeof selector == 'object') collection = $(selector) + while (node && !(collection ? collection.indexOf(node) >= 0 : finder.matches(node, selector))) + node = node !== context && !isDocument(node) && node.parentNode + return $(node) + }, + + + parents: wrapper_selector(finder.ancestors, finder), + + parent: wrapper_selector(finder.parent, finder), + + children: wrapper_selector(finder.children, finder), + + contents: wrapper_map(noder.contents, noder), + + siblings: wrapper_selector(finder.siblings, finder), + + empty: wrapper_every_act(noder.empty, noder), + + // `pluck` is borrowed from Prototype.js + pluck: function(property) { + return langx.map(this, function(el) { + return el[property] + }) + }, + + show: wrapper_every_act(fx.show, fx), + + replaceWith: function(newContent) { + return this.before(newContent).remove(); + }, + + wrap: function(structure) { + var func = isFunction(structure) + if (this[0] && !func) + var dom = $(structure).get(0), + clone = dom.parentNode || this.length > 1 + + return this.each(function(index) { + $(this).wrapAll( + func ? structure.call(this, index) : + clone ? dom.cloneNode(true) : dom + ) + }) + }, + + wrapAll: function(wrappingElement) { + if (this[0]) { + $(this[0]).before(wrappingElement = $(wrappingElement)); + var children; + // drill down to the inmost element + while ((children = wrappingElement.children()).length) { + wrappingElement = children.first(); + } + $(wrappingElement).append(this); + } + return this + }, + + wrapInner: function(wrappingElement) { + var func = isFunction(wrappingElement) + return this.each(function(index) { + var self = $(this), + contents = self.contents(), + dom = func ? wrappingElement.call(this, index) : wrappingElement + contents.length ? contents.wrapAll(dom) : self.append(dom) + }) + }, + + unwrap: function(selector) { + if (this.parent().children().length === 0) { + // remove dom without text + this.parent(selector).not("body").each(function() { + $(this).replaceWith(document.createTextNode(this.childNodes[0].textContent)); + }); + } else { + this.parent().each(function() { + $(this).replaceWith($(this).children()) + }); + } + return this + }, + + clone: function() { + return this.map(function() { + return this.cloneNode(true) + }) + }, + + hide: wrapper_every_act(fx.hide, fx), + + toggle: function(setting) { + return this.each(function() { + var el = $(this); + (setting === undefined ? el.css("display") == "none" : setting) ? el.show() : el.hide() + }) + }, + + prev: function(selector) { + return $(this.pluck('previousElementSibling')).filter(selector || '*') + }, + + next: function(selector) { + return $(this.pluck('nextElementSibling')).filter(selector || '*') + }, + + html: wrapper_value(noder.html, noder, noder.html), + + text: wrapper_value(datax.text, datax, datax.text), + + attr: wrapper_name_value(datax.attr, datax, datax.attr), + + removeAttr: wrapper_every_act(datax.removeAttr, datax), + + prop: wrapper_name_value(datax.prop, datax, datax.prop), + + data: wrapper_name_value(datax.data, datax, datax.data), + + removeData: wrapper_every_act(datax.removeData, datax), + + val: wrapper_value(datax.val, datax, datax.val), + + offset: wrapper_value(geom.pageRect, geom, geom.pageRect), + + style: wrapper_name_value(styler.css, styler), + + css: wrapper_name_value(styler.css, styler), + + index: function(elem) { + if (elem) { + return this.indexOf($(elem)[0]); + } else { + return this.parent().children().indexOf(this[0]); + } + }, + + //hasClass(name) + hasClass: wrapper_some_chk(styler.hasClass, styler), + + //addClass(name) + addClass: wrapper_every_act_firstArgFunc(styler.addClass, styler, styler.className), + + //removeClass(name) + removeClass: wrapper_every_act_firstArgFunc(styler.removeClass, styler, styler.className), + + //toogleClass(name,when) + toggleClass: wrapper_every_act_firstArgFunc(styler.toggleClass, styler, styler.className), + + scrollTop: wrapper_value(geom.scrollTop, geom), + + scrollLeft: wrapper_value(geom.scrollLeft, geom), + + position: function() { + if (!this.length) return + + var elem = this[0]; + + return geom.relativePosition(elem); + }, + + offsetParent: wrapper_map(geom.offsetParent, geom), + }); + + // for now + $.fn.detach = $.fn.remove; + + + $.fn.size = wrapper_value(geom.size, geom); + + $.fn.width = wrapper_value(geom.width, geom, geom.width); + + $.fn.height = wrapper_value(geom.height, geom, geom.height); + + ['width', 'height'].forEach(function(dimension) { + var offset, Dimension = dimension.replace(/./, function(m) { + return m[0].toUpperCase() + }); + + $.fn['outer' + Dimension] = function(margin, value) { + if (arguments.length) { + if (typeof margin !== 'boolean') { + value = margin; + margin = false; + } + } else { + margin = false; + value = undefined; + } + + if (value === undefined) { + var el = this[0]; + var cb = geom.size(el); + if (margin) { + var me = geom.marginExtents(el); + cb.width = cb.width + me.left + me.right; + cb.height = cb.height + me.top + me.bottom; + } + return dimension === "width" ? cb.width : cb.height; + } else { + return this.each(function(idx, el) { + var mb = {}; + var me = geom.marginExtents(el); + if (dimension === "width") { + mb.width = value; + if (margin) { + mb.width = mb.width - me.left - me.right + } + } else { + mb.height = value; + if (margin) { + mb.height = mb.height - me.top - me.bottom; + } + } + geom.size(el, mb); + }) + + } + }; + }) + + $.fn.innerWidth = wrapper_value(geom.width, geom, geom.width); + + $.fn.innerHeight = wrapper_value(geom.height, geom, geom.height); + + + var traverseNode = noder.traverse; + + function wrapper_node_operation(func, context, oldValueFunc) { + return function(html) { + var argType, nodes = langx.map(arguments, function(arg) { + argType = type(arg) + return argType == "object" || argType == "array" || arg == null ? + arg : noder.createFragment(arg) + }); + if (nodes.length < 1) { + return this + } + this.each(function(idx) { + func.apply(context, [this, nodes, idx > 0]); + }); + return this; + } + } + + + $.fn.after = wrapper_node_operation(noder.after, noder); + + $.fn.prepend = wrapper_node_operation(noder.prepend, noder); + + $.fn.before = wrapper_node_operation(noder.before, noder); + + $.fn.append = wrapper_node_operation(noder.append, noder); + + $.fn.insertAfter = function(html) { + $(html).after(this); + return this; + }; + + $.fn.insertBefore = function(html) { + $(html).before(this); + return this; + }; + + $.fn.appendTo = function(html) { + $(html).append(this); + return this; + }; + + $.fn.prependTo = function(html) { + $(html).prepend(this); + return this; + }; + + return $ + })(); + + (function($) { + $.fn.on = wrapper_every_act(eventer.on, eventer); + + $.fn.off = wrapper_every_act(eventer.off, eventer); + + $.fn.trigger = wrapper_every_act(eventer.trigger, eventer); + + + ('focusin focusout focus blur load resize scroll unload click dblclick ' + + 'mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave ' + + 'change select keydown keypress keyup error').split(' ').forEach(function(event) { + $.fn[event] = function(data, callback) { + return (0 in arguments) ? + this.on(event, data, callback) : + this.trigger(event) + } + }); + + + $.fn.one = function(event, selector, data, callback) { + if (!langx.isString(selector) && !langx.isFunction(callback)) { + callback = data; + data = selector; + selector = null; + } + + if (langx.isFunction(data)) { + callback = data; + data = null; + } + + return this.on(event, selector, data, callback, 1) + }; + + $.fn.animate = wrapper_every_act(fx.animate, fx); + + $.fn.show = wrapper_every_act(fx.show, fx); + $.fn.hide = wrapper_every_act(fx.hide, fx); + $.fn.toogle = wrapper_every_act(fx.toogle, fx); + $.fn.fadeTo = wrapper_every_act(fx.fadeTo, fx); + $.fn.fadeIn = wrapper_every_act(fx.fadeIn, fx); + $.fn.fadeOut = wrapper_every_act(fx.fadeOut, fx); + $.fn.fadeToggle = wrapper_every_act(fx.fadeToggle, fx); + })(query); + + + (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 + } + }) + })(query); + + + (function($) { + $.fn.query = $.fn.find; + + $.fn.place = function(refNode, position) { + // summary: + // places elements of this node list relative to the first element matched + // by queryOrNode. Returns the original NodeList. See: `dojo/dom-construct.place` + // queryOrNode: + // may be a string representing any valid CSS3 selector or a DOM node. + // In the selector case, only the first matching element will be used + // for relative positioning. + // position: + // can be one of: + // + // - "last" (default) + // - "first" + // - "before" + // - "after" + // - "only" + // - "replace" + // + // or an offset in the childNodes + if (langx.isString(refNode)) { + refNode = finder.descendant(refNode); + } else if (isQ(refNode)) { + refNode = refNode[0]; + } + return this.each(function(i, node) { + switch (position) { + case "before": + noder.before(refNode, node); + break; + case "after": + noder.after(refNode, node); + break; + case "replace": + noder.replace(refNode, node); + break; + case "only": + noder.empty(refNode); + noder.append(refNode, node); + break; + case "first": + noder.prepend(refNode, node); + break; + // else fallthrough... + default: // aka: last + noder.append(refNode, node); + } + }); + }; + + $.fn.addContent = function(content, position) { + if (content.template) { + content = langx.substitute(content.template, content); + } + return this.append(content); + }; + + $.fn.replaceClass = function(newClass, oldClass) { + this.removeClass(oldClass); + this.addClass(newClass); + return this; + }; + + })(query); + + + return skylark.query = query; +}); +define('skylarkjs/query',[ + "skylark-utils/query" +], function(query) { + return query; +}); + +define('skylark-utils/scripter',[ + "./skylark", + "./langx", + "./noder", + "./finder" +], function(skylark, langx, noder, finder) { + + var head = document.getElementsByTagName('head')[0], + scriptsByUrl = {}, + scriptElementsById = {}, + count = 0; + + function scripter() { + return scripter; + } + + langx.mixin(scripter, { + + loadJavaScript: function(url, loadedCallback, errorCallback) { + var script = scriptsByUrl[url]; + if (!script) { + script = scriptsByUrl[url] = { + state: 0, //0:unload,1:loaded,-1:loaderror + loadedCallbacks: [], + errorCallbacks: [] + } + } + + script.loadedCallbacks.push(loadedCallback); + script.errorCallbacks.push(errorCallback); + + if (script.state === 1) { + script.node.onload(); + } else if (script.state === -1) { + script.node.onerror(); + } else { + var node = script.node = document.createElement("script"), + id = script.id = (count++); + + node.type = "text/javascript"; + node.async = false; + node.defer = false; + startTime = new Date().getTime(); + head.appendChild(node); + + node.onload = function() { + script.state = 1; + + var callbacks = script.loadedCallbacks, + i = callbacks.length; + + while (i--) { + callbacks[i](); + } + script.loadedCallbacks = []; + script.errorCallbacks = []; + }, + node.onerror = function() { + script.state = -1; + var callbacks = script.errorCallbacks, + i = callbacks.length; + + while (i--) { + callbacks[i](); + } + script.loadedCallbacks = []; + script.errorCallbacks = []; + }; + node.src = url; + + scriptElementsById[id] = node; + } + return script.id; + }, + + deleteJavaScript: function(id) { + var node = scriptElementsById[id]; + if (node) { + var url = node.src; + noder.remove(node); + delete scriptElementsById[id]; + delete scriptsByUrl[url]; + } + } + }); + + return skylark.scripter = scripter; +}); + +define('skylarkjs/scripter',[ + "skylark-utils/scripter" +], function(scripter) { + return scripter; +}); + +define('skylarkjs/styler',[ + "skylark-utils/styler" +], function(styler) { + return styler; +}); + +define('skylark-utils/velm',[ + "./skylark", + "./langx", + "./datax", + "./dnd", + "./eventer", + "./filer", + "./finder", + "./fx", + "./geom", + "./mover", + "./noder", + "./styler" +], function(skylark, langx, datax, dnd, eventer, filer, finder, fx, geom, mover, noder, styler) { + var map = Array.prototype.map, + slice = Array.prototype.slice; + + var VisualElement = langx.klass({ + klassName: "VisualElement", + + "init": function(node) { + if (langx.isString(node)) { + node = document.getElementById(node); + } + this.domNode = node; + } + }); + + var root = new VisualElement(document.body), + velm = function(node) { + if (node) { + return new VisualElement(node); + } else { + return root; + } + }; + + function _delegator(fn, context) { + return function() { + var self = this, + elem = self.domNode, + ret = fn.apply(context, [elem].concat(slice.call(arguments))); + + if (ret) { + if (ret === context) { + return self; + } else { + if (ret instanceof HTMLElement) { + ret = new VisualElement(ret); + } else if (langx.isArrayLike(ret)) { + ret = map.call(ret, function(el) { + if (el instanceof HTMLElement) { + return new VisualElement(ret); + } else { + return el; + } + }) + } + } + } + return ret; + }; + } + + langx.mixin(velm, { + batch: function(nodes, action, args) { + nodes.forEach(function(node) { + var elm = (node instanceof VisualElement) ? node : velm(node); + elm[action].apply(elm, args); + }); + + return this; + }, + + root: new VisualElement(document.body), + + VisualElement: VisualElement, + + delegate: function(names, context) { + var props = {}; + + names.forEach(function(name) { + props[name] = _delegator(context[name], context); + }); + + VisualElement.partial(props); + } + }); + + // from ./datax + velm.delegate([ + "attr", + "data", + "prop", + "removeAttr", + "removeData", + "text", + "val" + ], datax); + + // from ./dnd + velm.delegate([ + "draggable", + "droppable" + ], dnd); + + + // from ./eventer + velm.delegate([ + "off", + "on", + "one", + "shortcuts", + "trigger" + ], eventer); + + // from ./filer + velm.delegate([ + "picker", + "dropzone" + ], filer); + + // from ./finder + velm.delegate([ + "ancestor", + "ancestors", + "children", + "descendant", + "find", + "findAll", + "firstChild", + "lastChild", + "matches", + "nextSibling", + "nextSiblings", + "parent", + "previousSibling", + "previousSiblings", + "siblings" + ], finder); + + velm.find = function(selector) { + if (selector === "body") { + return this.root; + } else { + return this.root.descendant(selector); + } + }; + + // from ./fx + velm.delegate([ + "animate", + "fadeIn", + "fadeOut", + "fadeTo", + "fadeToggle", + "hide", + "scrollToTop", + "show", + "toggle" + ], fx); + + + // from ./geom + velm.delegate([ + "borderExtents", + "boundingPosition", + "boundingRect", + "clientHeight", + "clientSize", + "clientWidth", + "contentRect", + "height", + "marginExtents", + "offsetParent", + "paddingExtents", + "pagePosition", + "pageRect", + "relativePosition", + "relativeRect", + "scrollIntoView", + "scrollLeft", + "scrollTop", + "size", + "width" + ], geom); + + // from ./mover + velm.delegate([ + "movable" + ], dnd); + + + // from ./noder + velm.delegate([ + "after", + "append", + "before", + "clone", + "contains", + "contents", + "empty", + "html", + "isChildOf", + "ownerDoc", + "prepend", + "remove", + "replace", + "reverse", + "throb", + "traverse", + "wrapper", + "wrapperInner", + "unwrap" + ], noder); + + // from ./styler + velm.delegate([ + "addClass", + "className", + "css", + "hasClass", + "hide", + "isInvisible", + "removeClass", + "show", + "toggleClass" + ], styler); + return skylark.velm = velm; +}); + +define('skylarkjs/velm',[ + "skylark-utils/velm" +], function(velm) { + return velm; +}); + +define('skylarkjs/main',[ + "./core", + "./browser", + "./css", + "./datax", + "./dnd", + "./eventer", + "./filer", + "./finder", + "./fx", + "./geom", + "./mover", + "./noder", + "./query", + "./scripter", + "./styler", + "./velm" +], function(skylark) { + return skylark; +}) +; +define('skylarkjs', ['skylarkjs/main'], function (main) { return main; }); + + +},this); \ No newline at end of file diff --git a/src/scripts/helpers/AceEditor.js b/src/scripts/helpers/AceEditor.js index 38c54ea..13807ed 100644 --- a/src/scripts/helpers/AceEditor.js +++ b/src/scripts/helpers/AceEditor.js @@ -1,6 +1,6 @@ define([ "./isMobile", - "skylark/langx", + "skylarkjs/langx", "ace", // "ace/ext-beautify" ], function(isMobile, langx, ace) { diff --git a/src/scripts/helpers/FolderTreeDomEvent.js b/src/scripts/helpers/FolderTreeDomEvent.js index 832db87..d648487 100644 --- a/src/scripts/helpers/FolderTreeDomEvent.js +++ b/src/scripts/helpers/FolderTreeDomEvent.js @@ -1,7 +1,7 @@ define([ "./isMobile", "./mobileSidebar", - "skylark/langx", + "skylarkjs/langx", "jquery" ], function(isMobile, mobileSidebar, langx, $) { var _sectionPrefix = "_section-"; diff --git a/src/scripts/helpers/FolderTreeStore.js b/src/scripts/helpers/FolderTreeStore.js index 78e5127..a6af7b9 100644 --- a/src/scripts/helpers/FolderTreeStore.js +++ b/src/scripts/helpers/FolderTreeStore.js @@ -1,5 +1,5 @@ define([ - "skylark/langx" + "skylarkjs/langx" ], function(langx) { return langx.klass({ klassName: "FolderTree", diff --git a/src/scripts/helpers/Partial.js b/src/scripts/helpers/Partial.js index 415855f..2f8f2c5 100644 --- a/src/scripts/helpers/Partial.js +++ b/src/scripts/helpers/Partial.js @@ -1,6 +1,6 @@ define([ "jquery", - "skylark/langx", + "skylarkjs/langx", "text!./_partials.hbs", "handlebars" ], function($, langx, partialsTpl, handlebars) { diff --git a/src/scripts/main.js b/src/scripts/main.js index 976402b..82d9e22 100644 --- a/src/scripts/main.js +++ b/src/scripts/main.js @@ -11,15 +11,13 @@ require.config({ }], paths: { - "skylark-all": "lib/skylarkjs-all.min", - "skylark-utils": "http://registry.skylarkjs.org/packages/skylark-utils/v0.9.0/skylark-utils", - "skylark-router": "http://registry.skylarkjs.org/packages/skylark-router/v0.9.0/skylark-router", + "skylarkjs": "lib/skylarkjs", "caret": "https://cdn.bootcss.com/Caret.js/0.3.1/jquery.caret", "atwho": "https://cdn.bootcss.com/at.js/1.5.4/js/jquery.atwho", "bootstrap": "https://cdn.bootcss.com/bootstrap/3.3.6/js/bootstrap.min", "handlebars": "https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/4.0.10/handlebars.amd.min", "jotted": "https://cdn.jsdelivr.net/jotted/1.5.1/jotted.min", - "jquery": "lib/skylark-jquery-all.min", + "jquery": "lib/skylark-jquery", "particles": "lib/particles", "tether": "https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min", "text": "https://cdnjs.cloudflare.com/ajax/libs/require-text/2.0.12/text" @@ -32,11 +30,11 @@ require.config({ } }); -require(["skylark-all"], function() { +require(["skylarkjs"], function() { require([ - "skylark-utils/noder", - "skylark-router", - "skylark/spa", + "skylarkjs/noder", + "skylarkjs/router", + "skylarkjs/spa", "text!./skylark-config.json", "jquery" ], function(noder, router, spa, txtConfig, $) { @@ -56,9 +54,9 @@ require(["skylark-all"], function() { }; window.addThrob = function(node, callback) { $(node).css("opacity", 0.5); - return noder.throb(node, { - callback: callback - }); + var throb = noder.throb(node, {}); + callback(); + return throb; }; var goTop = function(selector) { var goTopShown = false; @@ -83,7 +81,7 @@ require(["skylark-all"], function() { } }); }; - var main = $("#main-wrap")[0], + var main = $("#main-wrap")[0]; throb = window.addThrob(main, function() { require(["bootstrap"], function() { var app = spa(config); diff --git a/src/scripts/plugins/navbar/NavbarController.js b/src/scripts/plugins/navbar/NavbarController.js index 9f74731..de21214 100644 --- a/src/scripts/plugins/navbar/NavbarController.js +++ b/src/scripts/plugins/navbar/NavbarController.js @@ -1,7 +1,7 @@ define([ - "skylark/spa", + "skylarkjs/spa", "jquery", - "skylark/router" + "skylarkjs/router" ], function(spa, $, router) { var currentNav, setActive = function(selector) { @@ -42,7 +42,7 @@ define([ }); var selector = $("#main-wrap"); router.one("prepared", function(e) { - var curR = e._args.route; + var curR = e.route; setActive(curR.name); }); $(".logo-nav").on("click", function() { diff --git a/src/scripts/plugins/search/SearchController.js b/src/scripts/plugins/search/SearchController.js index f16a827..0fda71d 100644 --- a/src/scripts/plugins/search/SearchController.js +++ b/src/scripts/plugins/search/SearchController.js @@ -1,8 +1,8 @@ define([ - "skylark/spa", + "skylarkjs/spa", "jquery", - "skylark/router", - "skylark/eventer", + "skylarkjs/router", + "skylarkjs/eventer", "caret", "atwho" ], function(spa, $, router, eventer, caret, atwho) { @@ -30,7 +30,7 @@ define([ basePath = spa.getConfig("baseUrl"), routes = spa.getConfig("routes"); router.on("routed", function(e) { - var r = e._args.current.route, + var r = e.current.route, searchConfig = r.getConfigData("search"); if (searchConfig) { if (!searchConfig.searchBar) { diff --git a/src/scripts/routes/api/ApiController.js b/src/scripts/routes/api/ApiController.js index 53564e6..14b50ec 100644 --- a/src/scripts/routes/api/ApiController.js +++ b/src/scripts/routes/api/ApiController.js @@ -1,20 +1,19 @@ define([ - "skylark/spa", - "skylark/async", + "skylarkjs/spa", "jquery", - "skylark/langx", + "skylarkjs/langx", "handlebars", "scripts/helpers/AceEditor", "scripts/helpers/Partial", "scripts/helpers/FolderTreeDomEvent", "text!contents/api/api.json", "text!scripts/routes/api/api.hbs" -], function(spa, async, $, langx, handlebars, AceEditor, Partial, FolderTreeDomEvent, apiJson, apiTpl) { +], function(spa, $, langx, handlebars, AceEditor, Partial, FolderTreeDomEvent, apiJson, apiTpl) { return spa.RouteController.inherit({ klassName: "GuideController", preparing: function(e) { var selector = $(langx.trim(apiTpl)), - deferred = new async.Deferred(); + deferred = new langx.Deferred(); Partial.get("file-section-partial"); Partial.get("folder-tree-partial"); Partial.get("folder-tree-loop-partial"); diff --git a/src/scripts/routes/examples/ExamplesController.js b/src/scripts/routes/examples/ExamplesController.js index 315eab2..46d3081 100644 --- a/src/scripts/routes/examples/ExamplesController.js +++ b/src/scripts/routes/examples/ExamplesController.js @@ -1,12 +1,11 @@ define([ "ace", - "skylark/spa", - "skylark/css", - "skylark/eventer", - "skylark/finder", - "skylark/async", + "skylarkjs/spa", + "skylarkjs/css", + "skylarkjs/eventer", + "skylarkjs/finder", "jquery", - "skylark/langx", + "skylarkjs/langx", "handlebars", "jotted", "scripts/helpers/isMobile", @@ -14,7 +13,7 @@ define([ "scripts/helpers/FolderTreeDomEvent", "text!contents/examples/examples.json", "text!scripts/routes/examples/examples.hbs" -], function(ace, spa, css, eventer, finder, async, $, langx, handlebars, Jotted, isMobile, +], function(ace, spa, css, eventer, finder, $, langx, handlebars, Jotted, isMobile, Partial, FolderTreeDomEvent, examplesJson, examplesTpl) { var currentFileItem; return spa.RouteController.inherit({ diff --git a/src/scripts/routes/guide/GuideController.js b/src/scripts/routes/guide/GuideController.js index da9b40f..377a4c2 100644 --- a/src/scripts/routes/guide/GuideController.js +++ b/src/scripts/routes/guide/GuideController.js @@ -1,16 +1,15 @@ define([ - "skylark/spa", - "skylark/async", + "skylarkjs/spa", "jquery", - "skylark/eventer", - "skylark/langx", + "skylarkjs/eventer", + "skylarkjs/langx", "handlebars", "scripts/helpers/AceEditor", "scripts/helpers/Partial", "scripts/helpers/FolderTreeDomEvent", "text!contents/guide/guide.json", "text!scripts/routes/guide/guide.hbs" -], function(spa, async, $, eventer, langx, handlebars, AceEditor, Partial, FolderTreeDomEvent, guideJson, guideTpl) { +], function(spa, $, eventer, langx, handlebars, AceEditor, Partial, FolderTreeDomEvent, guideJson, guideTpl) { var _heightObj = {}, _currentRange = null, _isClickScroll = false, diff --git a/src/scripts/routes/home/HomeController.js b/src/scripts/routes/home/HomeController.js index 328d6c6..a0cb786 100644 --- a/src/scripts/routes/home/HomeController.js +++ b/src/scripts/routes/home/HomeController.js @@ -1,9 +1,9 @@ define([ - "skylark/spa", - "skylark/langx", - "skylark/noder", + "skylarkjs/spa", + "skylarkjs/langx", + "skylarkjs/noder", "jquery", - "skylark/eventer", + "skylarkjs/eventer", "jotted", "particles", "scripts/helpers/isMobile", diff --git a/src/scripts/routes/home/home.html b/src/scripts/routes/home/home.html index f101583..20e97ee 100644 --- a/src/scripts/routes/home/home.html +++ b/src/scripts/routes/home/home.html @@ -67,7 +67,7 @@

Concise

Compatible

Skylark.js has a high compatibility with other javascript libraries. - The skylark/query module and optional skylark.jquery library provides a fully compatible API with jquery, JQuery plugins and applications can run directly on skylark. + The skylarkjs/query module and optional skylark.jquery library provides a fully compatible API with jquery, JQuery plugins and applications can run directly on skylark. The skylark single application framework has high extensibility, and easy to integrate with bootstrap, backbone and other GUI libraries.