diff --git a/build/construct-min.js b/build/construct-min.js index 0813608..0e9fdf9 100644 --- a/build/construct-min.js +++ b/build/construct-min.js @@ -1 +1 @@ -!function(){var e=function(e){var t=null,n=[],s=!1;this.add=function(c){s?c.apply(e,t):n.push(c)},this.resolve=function(){if(!s){t=arguments,s=!0;for(var c=n.shift();c;)c.apply(e,arguments),c=n.shift();n=null}}};Object.extend=function(e,t){for(var n in t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},arguments.callee(e[n],t[n])):e[n]=t[n];return e};var t={"en-US":{errors:{No_Backbone:"Backbone is not available: http://backbonejs.org/",No_jQuery:"jQuery is not available: http://jquery.com/",No_jQueryThree:"jQuery Three is required: http://github.com/makesites/jquery-three",No_BackboneApp:"This function requires Backbone APP: http://github.com/makesites/backbone-app"}}};construct=function(e,t){e.deps&&Object.extend(construct.config,e.deps),t&&(construct.callback=t),construct.promise.resolve(),construct.init()},construct.init=function(){var e=new APP;window.app=e,Backbone.history.start(),construct.callback&&construct.callback(e)},construct.register=function(e){e&&e.update&&construct.loop.push(e.update)},construct.configure=function(e){construct.promise.add(e)},construct.lang=function(e){Object.extend(t,e)},construct.loop=[],construct.update=function(){},construct.promise=new e,construct.config={paths:{jquery:["//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min"],json2:["//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.min"],underscore:["//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min"],handlebars:["//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min"],backbone:["//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min"],"three.js":["//cdnjs.cloudflare.com/ajax/libs/three.js/r58/three.min"],"backbone.app":["//rawgithub.com/makesites/backbone-app/0.9.0/build/backbone.app-min"],"jquery.three":["//rawgithub.com/makesites/jquery-three/master/build/jquery.three"]},shim:{jquery:{deps:["json2"]},underscore:{exports:"_"},backbone:{deps:["underscore","jquery"],exports:"Backbone"},"backbone.app":{deps:["backbone","underscore","jquery"]},"jquery.three":{deps:["jquery","three.js"]},"construct.input":{deps:["construct"]},"construct.editor":{deps:["construct"]}},deps:[]},construct.promise.add(function(){require(["backbone.app"],function(){APP.Models.User=APP.Model.extend({defaults:{admin:!0}}),APP.Models.Asset=APP.Model.extend({defaults:{x:0,y:0,editable:!0}}),APP.Collections.Users=APP.Collection.extend({}),APP.Collections.Assets=APP.Collection.extend({})})}),construct.promise.add(function(){require(["backbone.app","jquery.three"],function(){APP.Meshes={},APP.Sprites={},APP.Actors={},APP.Mesh=Backbone.View.extend({preRender:function(){},render:function(){},postRender:function(){},update:function(){}}),APP.Meshes.Static=APP.Mesh.extend({}),APP.Meshes.Dynamic=APP.Meshes.Static.extend({}),APP.Meshes.Avatar=APP.Meshes.Dynamic.extend({}),APP.Meshes.NPC=APP.Meshes.Avatar.extend({}),APP.Meshes.Player=APP.Meshes.Avatar.extend({}),APP.Sprite=Backbone.View.extend({}),APP.Sprites.Static=APP.Sprite.extend({}),APP.Sprites.Animated=APP.Sprite.extend({}),APP.Views.Asset=APP.View.extend({})})})}(); \ No newline at end of file +!function(){var e=function(e){var t=null,n=[],s=!1;this.add=function(c){s?c.apply(e,t):n.push(c)},this.resolve=function(){if(!s){t=arguments,s=!0;for(var c=n.shift();c;)c.apply(e,arguments),c=n.shift();n=null}}};Object.extend=function(e,t){for(var n in t)t[n]&&t[n].constructor&&t[n].constructor===Object?(e[n]=e[n]||{},arguments.callee(e[n],t[n])):e[n]=t[n];return e};var t={"en-US":{error:{"no-backbone":"Backbone is not available: http://backbonejs.org/","no-jquery":"jQuery is not available: http://jquery.com/","no-jquery-three":"jQuery Three is required: http://github.com/makesites/jquery-three","no-backbone-app":"This function requires Backbone APP: http://github.com/makesites/backbone-app"}}};construct=function(e,t){e.deps&&Object.extend(construct.config,e.deps),t&&(construct.callback=t),construct.promise.resolve(),construct.init()},construct.init=function(){var e=new APP;window.app=e,Backbone.history.start(),construct.callback&&construct.callback(e)},construct.register=function(e){e&&e.update&&construct.loop.push(e.update)},construct.configure=function(e){construct.promise.add(e)},construct.lang=function(e){Object.extend(t,e)},construct.loop=[],construct.update=function(){},construct.log=function(e,n){if(e&&n){var s=navigator.language?navigator.language:navigator.userLanguage,c=t[s][e][n]||t["en-US"][e][n]||e+": "+n;console.log(c)}},construct.promise=new e,construct.config={paths:{jquery:["//cdnjs.cloudflare.com/ajax/libs/jquery/2.0.2/jquery.min"],json2:["//cdnjs.cloudflare.com/ajax/libs/json2/20121008/json2.min"],underscore:["//cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.4/underscore-min"],handlebars:["//cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.min"],backbone:["//cdnjs.cloudflare.com/ajax/libs/backbone.js/1.0.0/backbone-min"],"three.js":["//cdnjs.cloudflare.com/ajax/libs/three.js/r58/three.min"],"backbone.app":["//rawgithub.com/makesites/backbone-app/0.9.0/build/backbone.app-min"],"jquery.three":["//rawgithub.com/makesites/jquery-three/master/build/jquery.three"]},shim:{jquery:{deps:["json2"]},underscore:{exports:"_"},backbone:{deps:["underscore","jquery"],exports:"Backbone"},"backbone.app":{deps:["backbone","underscore","jquery"]},"jquery.three":{deps:["jquery","three.js"]},"construct.input":{deps:["construct"]},"construct.editor":{deps:["construct"]}},deps:[]},construct.promise.add(function(){require(["backbone.app"],function(){APP.Models.User=APP.Model.extend({defaults:{admin:!0}}),APP.Models.Asset=APP.Model.extend({defaults:{x:0,y:0,editable:!0}}),APP.Collections.Users=APP.Collection.extend({}),APP.Collections.Assets=APP.Collection.extend({})})}),construct.promise.add(function(){require(["backbone.app","jquery.three"],function(){APP.Meshes={},APP.Sprites={},APP.Actors={},APP.Mesh=Backbone.View.extend({preRender:function(){},render:function(){},postRender:function(){},update:function(){}}),APP.Meshes.Static=APP.Mesh.extend({}),APP.Meshes.Dynamic=APP.Meshes.Static.extend({}),APP.Meshes.Avatar=APP.Meshes.Dynamic.extend({}),APP.Meshes.NPC=APP.Meshes.Avatar.extend({}),APP.Meshes.Player=APP.Meshes.Avatar.extend({}),APP.Sprite=Backbone.View.extend({}),APP.Sprites.Static=APP.Sprite.extend({}),APP.Sprites.Animated=APP.Sprite.extend({}),APP.Views.Asset=APP.View.extend({})})})}(); \ No newline at end of file diff --git a/build/construct.js b/build/construct.js index 7a3906f..00b946b 100644 --- a/build/construct.js +++ b/build/construct.js @@ -60,11 +60,11 @@ Object.extend = function(destination, source) { var locale = { "en-US": { - "errors": { - "No_Backbone": "Backbone is not available: http://backbonejs.org/", - "No_jQuery": "jQuery is not available: http://jquery.com/", - "No_jQueryThree": "jQuery Three is required: http://github.com/makesites/jquery-three", - "No_BackboneApp": "This function requires Backbone APP: http://github.com/makesites/backbone-app" + "error": { + "no-backbone": "Backbone is not available: http://backbonejs.org/", + "no-jquery": "jQuery is not available: http://jquery.com/", + "no-jquery-three": "jQuery Three is required: http://github.com/makesites/jquery-three", + "no-backbone-app": "This function requires Backbone APP: http://github.com/makesites/backbone-app" } } }; @@ -144,6 +144,26 @@ construct.update = function( fn ){ }; +// output status messages +// inspired by the l10n handlebars helper: https://gist.github.com/tracend/3261055 +construct.log = function( type, key ){ + //prerequisites + if(!type || !key) return; + // find language + // make this a config option? (to avoid repeat lookups) + var lang = (navigator.language) ? navigator.language : navigator.userLanguage; + + // pick the right dictionary - rever to the passed type/key + var string = locale[lang][type][key] || locale['en-US'][type][key] || type +": "+ key; + + // check if console.log exists first? + + //output + console.log(string); + +}; + + construct.promise = new Promise(); diff --git a/lib/helpers.js b/lib/helpers.js index 8fa0899..b44837d 100644 --- a/lib/helpers.js +++ b/lib/helpers.js @@ -11,4 +11,24 @@ construct.update = function( fn ){ }; +// output status messages +// inspired by the l10n handlebars helper: https://gist.github.com/tracend/3261055 +construct.log = function( type, key ){ + //prerequisites + if(!type || !key) return; + // find language + // make this a config option? (to avoid repeat lookups) + var lang = (navigator.language) ? navigator.language : navigator.userLanguage; + + // pick the right dictionary - rever to the passed type/key + var string = locale[lang][type][key] || locale['en-US'][type][key] || type +": "+ key; + + // check if console.log exists first? + + //output + console.log(string); + +}; + + construct.promise = new Promise();