Revision 82189820
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/components/tag-el.js | ||
---|---|---|
15 | 15 |
deleteTag: function() { |
16 | 16 |
this.sendAction('deleteTag', this.get('param')); |
17 | 17 |
}, |
18 |
} |
|
18 |
},
|
|
19 | 19 |
|
20 | 20 |
}); |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/components/volume-el.js | ||
---|---|---|
1 | 1 |
App.VolumeElComponent = Ember.Component.extend({ |
2 | 2 |
tagName: 'section', |
3 |
actions: { |
|
4 |
|
|
5 |
revealModal: function(){ |
|
6 |
|
|
7 |
var component = Ember.View.views.generic; |
|
8 |
component.set('message', '<p>Are you sure you want to dettach this Volume?</p>'); |
|
9 |
component.set('okCallback', _.bind(function() { |
|
10 |
$("#generic").foundation('reveal', 'close'); |
|
11 |
this.sendAction('ok'); |
|
12 |
}, this)); |
|
13 |
$("#generic").foundation('reveal', 'open'); |
|
14 |
}, |
|
15 |
|
|
16 |
}, |
|
3 | 17 |
}); |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/controllers/vm.js | ||
---|---|---|
27 | 27 |
this.get('model').get('tags').removeObject(tag); |
28 | 28 |
}, |
29 | 29 |
|
30 |
dettachVolume: function(volume){ |
|
31 |
alert('I am now dettaching this volume'); |
|
32 |
//this.get('model').get('volumes').removeObject(volume); |
|
33 |
}, |
|
34 |
|
|
30 | 35 |
modalConnect: function(){ |
31 | 36 |
var component = Ember.View.views["modal-connect"]; |
32 | 37 |
component.set('message', 'connect to your <3 ' + this.get('model').get('name')); |
... | ... | |
69 | 74 |
}); |
70 | 75 |
|
71 | 76 |
App.VmInfoController = App.VmController.extend(); |
77 |
|
|
78 |
App.VmDiskConnectedController = App.VmController.extend(); |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/models/volume.js | ||
---|---|---|
19 | 19 |
name: 'Ο αγαπημένος μου δίσκος', |
20 | 20 |
status: 'running', |
21 | 21 |
size: 10737418240, |
22 |
vms: [1],
|
|
22 |
vm: 1,
|
|
23 | 23 |
}, |
24 | 24 |
{ |
25 | 25 |
id: 2, |
26 | 26 |
name: 'Crypto', |
27 | 27 |
status: 'running', |
28 | 28 |
size: 2048, |
29 |
vms: [1],
|
|
29 |
vm: 1,
|
|
30 | 30 |
}, |
31 | 31 |
{ |
32 | 32 |
id: 3, |
... | ... | |
34 | 34 |
status: 'running', |
35 | 35 |
size: 4096, |
36 | 36 |
storageType: 'drpd', |
37 |
vms: [2],
|
|
37 |
vm: 3,
|
|
38 | 38 |
}, |
39 | 39 |
]; |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/routes/vm.js | ||
---|---|---|
1 | 1 |
App.VmRoute = Ember.Route.extend({ |
2 |
|
|
2 |
/* |
|
3 | 3 |
redirect: function() { |
4 | 4 |
this.transitionTo('vm.info'); |
5 |
}, |
|
5 |
},*/
|
|
6 | 6 |
|
7 | 7 |
renderTemplate: function() { |
8 | 8 |
|
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/ember/views/volumes-list.js | ||
---|---|---|
1 |
App.volumesListView = Ember.View.extend({
|
|
1 |
App.VolumesListView = Ember.View.extend({
|
|
2 | 2 |
templateName: 'volumes-list', |
3 | 3 |
}); |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates.js | ||
---|---|---|
174 | 174 |
'id': ("modal-destroy"), |
175 | 175 |
'hasButtons': ("true") |
176 | 176 |
},hashTypes:{'id': "STRING",'hasButtons': "STRING"},hashContexts:{'id': depth0,'hasButtons': depth0},contexts:[],types:[],data:data},helper ? helper.call(depth0, options) : helperMissing.call(depth0, "reveal-modal", options)))); |
177 |
data.buffer.push("\n\n "); |
|
178 |
data.buffer.push(escapeExpression((helper = helpers['reveal-modal'] || (depth0 && depth0['reveal-modal']),options={hash:{ |
|
179 |
'id': ("generic"), |
|
180 |
'hasButtons': ("true") |
|
181 |
},hashTypes:{'id': "STRING",'hasButtons': "STRING"},hashContexts:{'id': depth0,'hasButtons': depth0},contexts:[],types:[],data:data},helper ? helper.call(depth0, options) : helperMissing.call(depth0, "reveal-modal", options)))); |
|
177 | 182 |
data.buffer.push("\n</section>"); |
178 | 183 |
return buffer; |
179 | 184 |
|
... | ... | |
254 | 259 |
|
255 | 260 |
}); |
256 | 261 |
|
262 |
Ember.TEMPLATES["components/open-reveal"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) { |
|
263 |
this.compilerInfo = [4,'>= 1.0.0']; |
|
264 |
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {}; |
|
265 |
var buffer = '', escapeExpression=this.escapeExpression; |
|
266 |
|
|
267 |
|
|
268 |
data.buffer.push("<a "); |
|
269 |
data.buffer.push(escapeExpression(helpers.action.call(depth0, "deleteTag", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data}))); |
|
270 |
data.buffer.push(" class=\"act\" data-reveal-id=\"detach-volume\"> </a>"); |
|
271 |
return buffer; |
|
272 |
|
|
273 |
}); |
|
274 |
|
|
257 | 275 |
Ember.TEMPLATES["components/resource-tags"] = Ember.Handlebars.template(function anonymous(Handlebars,depth0,helpers,partials,data) { |
258 | 276 |
this.compilerInfo = [4,'>= 1.0.0']; |
259 | 277 |
helpers = this.merge(helpers, Ember.Handlebars.helpers); data = data || {}; |
... | ... | |
327 | 345 |
data.buffer.push(">\n <div class=\"what\">\n <div class=\"img-wrap\">\n <span class=\"snf-volume-full snf-font\"></span>\n </div>\n <h4>"); |
328 | 346 |
stack1 = helpers._triageMustache.call(depth0, "item.name", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); |
329 | 347 |
if(stack1 || stack1 === 0) { data.buffer.push(stack1); } |
330 |
data.buffer.push("</h4>\n </div>\n <div class=\"clearfix\">\n <ul class=\"connections\">\n <li>\n <a href=\"#\" class=\"act\" data-reveal-id=\"detach-volume\"> </a>\n <div class=\"icon\"></div>\n <div class=\"data\">\n <ul>\n <li>\n <h5 class=\"volume-data\">Size</h5>\n <p>"); |
|
348 |
data.buffer.push("</h4>\n </div>\n <div class=\"clearfix\">\n <ul class=\"connections\">\n <li>\n\n <a href=\"#\" "); |
|
349 |
data.buffer.push(escapeExpression(helpers.action.call(depth0, "revealModal", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data}))); |
|
350 |
data.buffer.push(" class=\"act\" > </a>\n <div class=\"icon\"></div>\n <div class=\"data\">\n <ul>\n <li>\n <h5 class=\"volume-data\">Size</h5>\n <p>"); |
|
331 | 351 |
data.buffer.push(escapeExpression((helper = helpers['bytes-to-human'] || (depth0 && depth0['bytes-to-human']),options={hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data},helper ? helper.call(depth0, "item.size", options) : helperMissing.call(depth0, "bytes-to-human", "item.size", options)))); |
332 | 352 |
data.buffer.push("</p>\n </li>\n <li>\n <h5 class=\"volume-data\">Storage Type</h5>\n <p>"); |
333 | 353 |
stack1 = helpers._triageMustache.call(depth0, "item.storageType", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}); |
... | ... | |
429 | 449 |
|
430 | 450 |
var buffer = ''; |
431 | 451 |
data.buffer.push("\n"); |
432 |
data.buffer.push(escapeExpression(helpers.view.call(depth0, "App.volumesListView", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data})));
|
|
452 |
data.buffer.push(escapeExpression(helpers.view.call(depth0, "App.VolumesListView", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data})));
|
|
433 | 453 |
data.buffer.push("\n <section class=\"connect-new disk\">\n <div class=\"img-wrap\">\n <a href=\"\" data-reveal-id=\"attach-volume\">\n <span class=\"snf-volume-full snf-font\"></span>\n </a>\n </div>\n <p><a href=\"\" data-reveal-id=\"attach-volume\">Attach Volume</a></p>\n </section>\n"); |
434 | 454 |
return buffer; |
435 | 455 |
} |
... | ... | |
501 | 521 |
data.buffer.push("<li "); |
502 | 522 |
data.buffer.push(escapeExpression(helpers['bind-attr'].call(depth0, {hash:{ |
503 | 523 |
'data-status': ("status"), |
504 |
'class': ("status") |
|
505 |
},hashTypes:{'data-status': "ID",'class': "ID"},hashContexts:{'data-status': depth0,'class': depth0},contexts:[],types:[],data:data})));
|
|
506 |
data.buffer.push(">\n "); |
|
524 |
'class': ("this.status")
|
|
525 |
},hashTypes:{'data-status': "ID",'class': "STRING"},hashContexts:{'data-status': depth0,'class': depth0},contexts:[],types:[],data:data})));
|
|
526 |
data.buffer.push(">\n\n ");
|
|
507 | 527 |
data.buffer.push(escapeExpression(helpers.view.call(depth0, "App.sideActionsView", {hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["ID"],data:data}))); |
508 | 528 |
data.buffer.push("\n\n <div class=\"container\">\n\n <a href=\"\" class=\"check\">\n <span class=\"snf-checkbox-unchecked\"></span>\n </a>\n \n "); |
509 | 529 |
data.buffer.push(escapeExpression((helper = helpers.partial || (depth0 && depth0.partial),options={hash:{},hashTypes:{},hashContexts:{},contexts:[depth0],types:["STRING"],data:data},helper ? helper.call(depth0, "img-wrap", options) : helperMissing.call(depth0, "partial", "img-wrap", options)))); |
... | ... | |
766 | 786 |
var buffer = '', helper, options; |
767 | 787 |
data.buffer.push("\n "); |
768 | 788 |
data.buffer.push(escapeExpression((helper = helpers['volume-el'] || (depth0 && depth0['volume-el']),options={hash:{ |
769 |
'item': ("volume") |
|
770 |
},hashTypes:{'item': "ID"},hashContexts:{'item': depth0},contexts:[],types:[],data:data},helper ? helper.call(depth0, options) : helperMissing.call(depth0, "volume-el", options)))); |
|
789 |
'item': ("volume"), |
|
790 |
'ok': ("dettachVolume"), |
|
791 |
'param': ("volume") |
|
792 |
},hashTypes:{'item': "ID",'ok': "STRING",'param': "ID"},hashContexts:{'item': depth0,'ok': depth0,'param': depth0},contexts:[],types:[],data:data},helper ? helper.call(depth0, options) : helperMissing.call(depth0, "volume-el", options)))); |
|
771 | 793 |
data.buffer.push("\n"); |
772 | 794 |
return buffer; |
773 | 795 |
} |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/_modals.hbs | ||
---|---|---|
4 | 4 |
{{reveal-modal id="modal-reboot" hasButtons="true"}} |
5 | 5 |
{{reveal-modal id="modal-shutdown" hasButtons="true"}} |
6 | 6 |
{{reveal-modal id="modal-destroy" hasButtons="true"}} |
7 |
|
|
8 |
{{reveal-modal id="generic" hasButtons="true"}} |
|
7 | 9 |
</section> |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/components/open-reveal.hbs | ||
---|---|---|
1 |
<a {{action 'deleteTag' }} class="act" data-reveal-id="detach-volume"> </a> |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/components/volume-el.hbs | ||
---|---|---|
8 | 8 |
<div class="clearfix"> |
9 | 9 |
<ul class="connections"> |
10 | 10 |
<li> |
11 |
<a href="#" class="act" data-reveal-id="detach-volume"> </a> |
|
11 |
|
|
12 |
<a href="#" {{action "revealModal" }} class="act" > </a> |
|
12 | 13 |
<div class="icon"></div> |
13 | 14 |
<div class="data"> |
14 | 15 |
<ul> |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/details/disk-connected.hbs | ||
---|---|---|
1 | 1 |
{{#details-content id="disk-connected" class="connected disk"}} |
2 |
{{view App.volumesListView}}
|
|
2 |
{{view App.VolumesListView}}
|
|
3 | 3 |
<section class="connect-new disk"> |
4 | 4 |
<div class="img-wrap"> |
5 | 5 |
<a href="" data-reveal-id="attach-volume"> |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/item.hbs | ||
---|---|---|
1 |
<li {{bind-attr data-status=this.status class=this.status}}> |
|
1 |
<li {{bind-attr data-status=this.status class="this.status"}}> |
|
2 |
|
|
2 | 3 |
{{view App.sideActionsView}} |
3 | 4 |
|
4 | 5 |
<div class="container"> |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/templates/volumes-list.hbs | ||
---|---|---|
1 | 1 |
{{#each volume in this.volumes}} |
2 |
{{volume-el item=volume}} |
|
2 |
{{volume-el item=volume ok="dettachVolume" param=volume}}
|
|
3 | 3 |
{{/each}} |
/dev/null | ||
---|---|---|
1 |
// Underscore.js 1.5.2 |
|
2 |
// http://underscorejs.org |
|
3 |
// (c) 2009-2013 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors |
|
4 |
// Underscore may be freely distributed under the MIT license. |
|
5 |
(function(){var n=this,t=n._,r={},e=Array.prototype,u=Object.prototype,i=Function.prototype,a=e.push,o=e.slice,c=e.concat,l=u.toString,f=u.hasOwnProperty,s=e.forEach,p=e.map,h=e.reduce,v=e.reduceRight,g=e.filter,d=e.every,m=e.some,y=e.indexOf,b=e.lastIndexOf,x=Array.isArray,w=Object.keys,_=i.bind,j=function(n){return n instanceof j?n:this instanceof j?(this._wrapped=n,void 0):new j(n)};"undefined"!=typeof exports?("undefined"!=typeof module&&module.exports&&(exports=module.exports=j),exports._=j):n._=j,j.VERSION="1.5.2";var A=j.each=j.forEach=function(n,t,e){if(null!=n)if(s&&n.forEach===s)n.forEach(t,e);else if(n.length===+n.length){for(var u=0,i=n.length;i>u;u++)if(t.call(e,n[u],u,n)===r)return}else for(var a=j.keys(n),u=0,i=a.length;i>u;u++)if(t.call(e,n[a[u]],a[u],n)===r)return};j.map=j.collect=function(n,t,r){var e=[];return null==n?e:p&&n.map===p?n.map(t,r):(A(n,function(n,u,i){e.push(t.call(r,n,u,i))}),e)};var E="Reduce of empty array with no initial value";j.reduce=j.foldl=j.inject=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),h&&n.reduce===h)return e&&(t=j.bind(t,e)),u?n.reduce(t,r):n.reduce(t);if(A(n,function(n,i,a){u?r=t.call(e,r,n,i,a):(r=n,u=!0)}),!u)throw new TypeError(E);return r},j.reduceRight=j.foldr=function(n,t,r,e){var u=arguments.length>2;if(null==n&&(n=[]),v&&n.reduceRight===v)return e&&(t=j.bind(t,e)),u?n.reduceRight(t,r):n.reduceRight(t);var i=n.length;if(i!==+i){var a=j.keys(n);i=a.length}if(A(n,function(o,c,l){c=a?a[--i]:--i,u?r=t.call(e,r,n[c],c,l):(r=n[c],u=!0)}),!u)throw new TypeError(E);return r},j.find=j.detect=function(n,t,r){var e;return O(n,function(n,u,i){return t.call(r,n,u,i)?(e=n,!0):void 0}),e},j.filter=j.select=function(n,t,r){var e=[];return null==n?e:g&&n.filter===g?n.filter(t,r):(A(n,function(n,u,i){t.call(r,n,u,i)&&e.push(n)}),e)},j.reject=function(n,t,r){return j.filter(n,function(n,e,u){return!t.call(r,n,e,u)},r)},j.every=j.all=function(n,t,e){t||(t=j.identity);var u=!0;return null==n?u:d&&n.every===d?n.every(t,e):(A(n,function(n,i,a){return(u=u&&t.call(e,n,i,a))?void 0:r}),!!u)};var O=j.some=j.any=function(n,t,e){t||(t=j.identity);var u=!1;return null==n?u:m&&n.some===m?n.some(t,e):(A(n,function(n,i,a){return u||(u=t.call(e,n,i,a))?r:void 0}),!!u)};j.contains=j.include=function(n,t){return null==n?!1:y&&n.indexOf===y?n.indexOf(t)!=-1:O(n,function(n){return n===t})},j.invoke=function(n,t){var r=o.call(arguments,2),e=j.isFunction(t);return j.map(n,function(n){return(e?t:n[t]).apply(n,r)})},j.pluck=function(n,t){return j.map(n,function(n){return n[t]})},j.where=function(n,t,r){return j.isEmpty(t)?r?void 0:[]:j[r?"find":"filter"](n,function(n){for(var r in t)if(t[r]!==n[r])return!1;return!0})},j.findWhere=function(n,t){return j.where(n,t,!0)},j.max=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.max.apply(Math,n);if(!t&&j.isEmpty(n))return-1/0;var e={computed:-1/0,value:-1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a>e.computed&&(e={value:n,computed:a})}),e.value},j.min=function(n,t,r){if(!t&&j.isArray(n)&&n[0]===+n[0]&&n.length<65535)return Math.min.apply(Math,n);if(!t&&j.isEmpty(n))return 1/0;var e={computed:1/0,value:1/0};return A(n,function(n,u,i){var a=t?t.call(r,n,u,i):n;a<e.computed&&(e={value:n,computed:a})}),e.value},j.shuffle=function(n){var t,r=0,e=[];return A(n,function(n){t=j.random(r++),e[r-1]=e[t],e[t]=n}),e},j.sample=function(n,t,r){return arguments.length<2||r?n[j.random(n.length-1)]:j.shuffle(n).slice(0,Math.max(0,t))};var k=function(n){return j.isFunction(n)?n:function(t){return t[n]}};j.sortBy=function(n,t,r){var e=k(t);return j.pluck(j.map(n,function(n,t,u){return{value:n,index:t,criteria:e.call(r,n,t,u)}}).sort(function(n,t){var r=n.criteria,e=t.criteria;if(r!==e){if(r>e||r===void 0)return 1;if(e>r||e===void 0)return-1}return n.index-t.index}),"value")};var F=function(n){return function(t,r,e){var u={},i=null==r?j.identity:k(r);return A(t,function(r,a){var o=i.call(e,r,a,t);n(u,o,r)}),u}};j.groupBy=F(function(n,t,r){(j.has(n,t)?n[t]:n[t]=[]).push(r)}),j.indexBy=F(function(n,t,r){n[t]=r}),j.countBy=F(function(n,t){j.has(n,t)?n[t]++:n[t]=1}),j.sortedIndex=function(n,t,r,e){r=null==r?j.identity:k(r);for(var u=r.call(e,t),i=0,a=n.length;a>i;){var o=i+a>>>1;r.call(e,n[o])<u?i=o+1:a=o}return i},j.toArray=function(n){return n?j.isArray(n)?o.call(n):n.length===+n.length?j.map(n,j.identity):j.values(n):[]},j.size=function(n){return null==n?0:n.length===+n.length?n.length:j.keys(n).length},j.first=j.head=j.take=function(n,t,r){return null==n?void 0:null==t||r?n[0]:o.call(n,0,t)},j.initial=function(n,t,r){return o.call(n,0,n.length-(null==t||r?1:t))},j.last=function(n,t,r){return null==n?void 0:null==t||r?n[n.length-1]:o.call(n,Math.max(n.length-t,0))},j.rest=j.tail=j.drop=function(n,t,r){return o.call(n,null==t||r?1:t)},j.compact=function(n){return j.filter(n,j.identity)};var M=function(n,t,r){return t&&j.every(n,j.isArray)?c.apply(r,n):(A(n,function(n){j.isArray(n)||j.isArguments(n)?t?a.apply(r,n):M(n,t,r):r.push(n)}),r)};j.flatten=function(n,t){return M(n,t,[])},j.without=function(n){return j.difference(n,o.call(arguments,1))},j.uniq=j.unique=function(n,t,r,e){j.isFunction(t)&&(e=r,r=t,t=!1);var u=r?j.map(n,r,e):n,i=[],a=[];return A(u,function(r,e){(t?e&&a[a.length-1]===r:j.contains(a,r))||(a.push(r),i.push(n[e]))}),i},j.union=function(){return j.uniq(j.flatten(arguments,!0))},j.intersection=function(n){var t=o.call(arguments,1);return j.filter(j.uniq(n),function(n){return j.every(t,function(t){return j.indexOf(t,n)>=0})})},j.difference=function(n){var t=c.apply(e,o.call(arguments,1));return j.filter(n,function(n){return!j.contains(t,n)})},j.zip=function(){for(var n=j.max(j.pluck(arguments,"length").concat(0)),t=new Array(n),r=0;n>r;r++)t[r]=j.pluck(arguments,""+r);return t},j.object=function(n,t){if(null==n)return{};for(var r={},e=0,u=n.length;u>e;e++)t?r[n[e]]=t[e]:r[n[e][0]]=n[e][1];return r},j.indexOf=function(n,t,r){if(null==n)return-1;var e=0,u=n.length;if(r){if("number"!=typeof r)return e=j.sortedIndex(n,t),n[e]===t?e:-1;e=0>r?Math.max(0,u+r):r}if(y&&n.indexOf===y)return n.indexOf(t,r);for(;u>e;e++)if(n[e]===t)return e;return-1},j.lastIndexOf=function(n,t,r){if(null==n)return-1;var e=null!=r;if(b&&n.lastIndexOf===b)return e?n.lastIndexOf(t,r):n.lastIndexOf(t);for(var u=e?r:n.length;u--;)if(n[u]===t)return u;return-1},j.range=function(n,t,r){arguments.length<=1&&(t=n||0,n=0),r=arguments[2]||1;for(var e=Math.max(Math.ceil((t-n)/r),0),u=0,i=new Array(e);e>u;)i[u++]=n,n+=r;return i};var R=function(){};j.bind=function(n,t){var r,e;if(_&&n.bind===_)return _.apply(n,o.call(arguments,1));if(!j.isFunction(n))throw new TypeError;return r=o.call(arguments,2),e=function(){if(!(this instanceof e))return n.apply(t,r.concat(o.call(arguments)));R.prototype=n.prototype;var u=new R;R.prototype=null;var i=n.apply(u,r.concat(o.call(arguments)));return Object(i)===i?i:u}},j.partial=function(n){var t=o.call(arguments,1);return function(){return n.apply(this,t.concat(o.call(arguments)))}},j.bindAll=function(n){var t=o.call(arguments,1);if(0===t.length)throw new Error("bindAll must be passed function names");return A(t,function(t){n[t]=j.bind(n[t],n)}),n},j.memoize=function(n,t){var r={};return t||(t=j.identity),function(){var e=t.apply(this,arguments);return j.has(r,e)?r[e]:r[e]=n.apply(this,arguments)}},j.delay=function(n,t){var r=o.call(arguments,2);return setTimeout(function(){return n.apply(null,r)},t)},j.defer=function(n){return j.delay.apply(j,[n,1].concat(o.call(arguments,1)))},j.throttle=function(n,t,r){var e,u,i,a=null,o=0;r||(r={});var c=function(){o=r.leading===!1?0:new Date,a=null,i=n.apply(e,u)};return function(){var l=new Date;o||r.leading!==!1||(o=l);var f=t-(l-o);return e=this,u=arguments,0>=f?(clearTimeout(a),a=null,o=l,i=n.apply(e,u)):a||r.trailing===!1||(a=setTimeout(c,f)),i}},j.debounce=function(n,t,r){var e,u,i,a,o;return function(){i=this,u=arguments,a=new Date;var c=function(){var l=new Date-a;t>l?e=setTimeout(c,t-l):(e=null,r||(o=n.apply(i,u)))},l=r&&!e;return e||(e=setTimeout(c,t)),l&&(o=n.apply(i,u)),o}},j.once=function(n){var t,r=!1;return function(){return r?t:(r=!0,t=n.apply(this,arguments),n=null,t)}},j.wrap=function(n,t){return function(){var r=[n];return a.apply(r,arguments),t.apply(this,r)}},j.compose=function(){var n=arguments;return function(){for(var t=arguments,r=n.length-1;r>=0;r--)t=[n[r].apply(this,t)];return t[0]}},j.after=function(n,t){return function(){return--n<1?t.apply(this,arguments):void 0}},j.keys=w||function(n){if(n!==Object(n))throw new TypeError("Invalid object");var t=[];for(var r in n)j.has(n,r)&&t.push(r);return t},j.values=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=n[t[u]];return e},j.pairs=function(n){for(var t=j.keys(n),r=t.length,e=new Array(r),u=0;r>u;u++)e[u]=[t[u],n[t[u]]];return e},j.invert=function(n){for(var t={},r=j.keys(n),e=0,u=r.length;u>e;e++)t[n[r[e]]]=r[e];return t},j.functions=j.methods=function(n){var t=[];for(var r in n)j.isFunction(n[r])&&t.push(r);return t.sort()},j.extend=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]=t[r]}),n},j.pick=function(n){var t={},r=c.apply(e,o.call(arguments,1));return A(r,function(r){r in n&&(t[r]=n[r])}),t},j.omit=function(n){var t={},r=c.apply(e,o.call(arguments,1));for(var u in n)j.contains(r,u)||(t[u]=n[u]);return t},j.defaults=function(n){return A(o.call(arguments,1),function(t){if(t)for(var r in t)n[r]===void 0&&(n[r]=t[r])}),n},j.clone=function(n){return j.isObject(n)?j.isArray(n)?n.slice():j.extend({},n):n},j.tap=function(n,t){return t(n),n};var S=function(n,t,r,e){if(n===t)return 0!==n||1/n==1/t;if(null==n||null==t)return n===t;n instanceof j&&(n=n._wrapped),t instanceof j&&(t=t._wrapped);var u=l.call(n);if(u!=l.call(t))return!1;switch(u){case"[object String]":return n==String(t);case"[object Number]":return n!=+n?t!=+t:0==n?1/n==1/t:n==+t;case"[object Date]":case"[object Boolean]":return+n==+t;case"[object RegExp]":return n.source==t.source&&n.global==t.global&&n.multiline==t.multiline&&n.ignoreCase==t.ignoreCase}if("object"!=typeof n||"object"!=typeof t)return!1;for(var i=r.length;i--;)if(r[i]==n)return e[i]==t;var a=n.constructor,o=t.constructor;if(a!==o&&!(j.isFunction(a)&&a instanceof a&&j.isFunction(o)&&o instanceof o))return!1;r.push(n),e.push(t);var c=0,f=!0;if("[object Array]"==u){if(c=n.length,f=c==t.length)for(;c--&&(f=S(n[c],t[c],r,e)););}else{for(var s in n)if(j.has(n,s)&&(c++,!(f=j.has(t,s)&&S(n[s],t[s],r,e))))break;if(f){for(s in t)if(j.has(t,s)&&!c--)break;f=!c}}return r.pop(),e.pop(),f};j.isEqual=function(n,t){return S(n,t,[],[])},j.isEmpty=function(n){if(null==n)return!0;if(j.isArray(n)||j.isString(n))return 0===n.length;for(var t in n)if(j.has(n,t))return!1;return!0},j.isElement=function(n){return!(!n||1!==n.nodeType)},j.isArray=x||function(n){return"[object Array]"==l.call(n)},j.isObject=function(n){return n===Object(n)},A(["Arguments","Function","String","Number","Date","RegExp"],function(n){j["is"+n]=function(t){return l.call(t)=="[object "+n+"]"}}),j.isArguments(arguments)||(j.isArguments=function(n){return!(!n||!j.has(n,"callee"))}),"function"!=typeof/./&&(j.isFunction=function(n){return"function"==typeof n}),j.isFinite=function(n){return isFinite(n)&&!isNaN(parseFloat(n))},j.isNaN=function(n){return j.isNumber(n)&&n!=+n},j.isBoolean=function(n){return n===!0||n===!1||"[object Boolean]"==l.call(n)},j.isNull=function(n){return null===n},j.isUndefined=function(n){return n===void 0},j.has=function(n,t){return f.call(n,t)},j.noConflict=function(){return n._=t,this},j.identity=function(n){return n},j.times=function(n,t,r){for(var e=Array(Math.max(0,n)),u=0;n>u;u++)e[u]=t.call(r,u);return e},j.random=function(n,t){return null==t&&(t=n,n=0),n+Math.floor(Math.random()*(t-n+1))};var I={escape:{"&":"&","<":"<",">":">",'"':""","'":"'"}};I.unescape=j.invert(I.escape);var T={escape:new RegExp("["+j.keys(I.escape).join("")+"]","g"),unescape:new RegExp("("+j.keys(I.unescape).join("|")+")","g")};j.each(["escape","unescape"],function(n){j[n]=function(t){return null==t?"":(""+t).replace(T[n],function(t){return I[n][t]})}}),j.result=function(n,t){if(null==n)return void 0;var r=n[t];return j.isFunction(r)?r.call(n):r},j.mixin=function(n){A(j.functions(n),function(t){var r=j[t]=n[t];j.prototype[t]=function(){var n=[this._wrapped];return a.apply(n,arguments),z.call(this,r.apply(j,n))}})};var N=0;j.uniqueId=function(n){var t=++N+"";return n?n+t:t},j.templateSettings={evaluate:/<%([\s\S]+?)%>/g,interpolate:/<%=([\s\S]+?)%>/g,escape:/<%-([\s\S]+?)%>/g};var q=/(.)^/,B={"'":"'","\\":"\\","\r":"r","\n":"n"," ":"t","\u2028":"u2028","\u2029":"u2029"},D=/\\|'|\r|\n|\t|\u2028|\u2029/g;j.template=function(n,t,r){var e;r=j.defaults({},r,j.templateSettings);var u=new RegExp([(r.escape||q).source,(r.interpolate||q).source,(r.evaluate||q).source].join("|")+"|$","g"),i=0,a="__p+='";n.replace(u,function(t,r,e,u,o){return a+=n.slice(i,o).replace(D,function(n){return"\\"+B[n]}),r&&(a+="'+\n((__t=("+r+"))==null?'':_.escape(__t))+\n'"),e&&(a+="'+\n((__t=("+e+"))==null?'':__t)+\n'"),u&&(a+="';\n"+u+"\n__p+='"),i=o+t.length,t}),a+="';\n",r.variable||(a="with(obj||{}){\n"+a+"}\n"),a="var __t,__p='',__j=Array.prototype.join,"+"print=function(){__p+=__j.call(arguments,'');};\n"+a+"return __p;\n";try{e=new Function(r.variable||"obj","_",a)}catch(o){throw o.source=a,o}if(t)return e(t,j);var c=function(n){return e.call(this,n,j)};return c.source="function("+(r.variable||"obj")+"){\n"+a+"}",c},j.chain=function(n){return j(n).chain()};var z=function(n){return this._chain?j(n).chain():n};j.mixin(j),A(["pop","push","reverse","shift","sort","splice","unshift"],function(n){var t=e[n];j.prototype[n]=function(){var r=this._wrapped;return t.apply(r,arguments),"shift"!=n&&"splice"!=n||0!==r.length||delete r[0],z.call(this,r)}}),A(["concat","join","slice"],function(n){var t=e[n];j.prototype[n]=function(){return z.call(this,t.apply(this._wrapped,arguments))}}),j.extend(j.prototype,{chain:function(){return this._chain=!0,this},value:function(){return this._wrapped}})}).call(this); |
|
6 |
//# sourceMappingURL=underscore-min.map |
b/snf-cyclades-app/synnefo/ui/new_ui/ui/javascripts/vendor/_ember.js | ||
---|---|---|
1 |
/*! |
|
2 |
* @overview Ember - JavaScript Application Framework |
|
3 |
* @copyright Copyright 2011-2014 Tilde Inc. and contributors |
|
4 |
* Portions Copyright 2006-2011 Strobe Inc. |
|
5 |
* Portions Copyright 2008-2011 Apple Inc. All rights reserved. |
|
6 |
* @license Licensed under MIT license |
|
7 |
* See https://raw.github.com/emberjs/ember.js/master/LICENSE |
|
8 |
* @version 1.4.0 |
|
9 |
*/ |
|
10 |
|
|
11 |
|
|
12 |
(function() { |
|
13 |
var define, requireModule, require, requirejs; |
|
14 |
|
|
15 |
(function() { |
|
16 |
var registry = {}, seen = {}; |
|
17 |
|
|
18 |
define = function(name, deps, callback) { |
|
19 |
registry[name] = { deps: deps, callback: callback }; |
|
20 |
}; |
|
21 |
|
|
22 |
requirejs = require = requireModule = function(name) { |
|
23 |
requirejs._eak_seen = registry; |
|
24 |
|
|
25 |
if (seen[name]) { return seen[name]; } |
|
26 |
seen[name] = {}; |
|
27 |
|
|
28 |
if (!registry[name]) { |
|
29 |
throw new Error("Could not find module " + name); |
|
30 |
} |
|
31 |
|
|
32 |
var mod = registry[name], |
|
33 |
deps = mod.deps, |
|
34 |
callback = mod.callback, |
|
35 |
reified = [], |
|
36 |
exports; |
|
37 |
|
|
38 |
for (var i=0, l=deps.length; i<l; i++) { |
|
39 |
if (deps[i] === 'exports') { |
|
40 |
reified.push(exports = {}); |
|
41 |
} else { |
|
42 |
reified.push(requireModule(resolve(deps[i]))); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
var value = callback.apply(this, reified); |
|
47 |
return seen[name] = exports || value; |
|
48 |
|
|
49 |
function resolve(child) { |
|
50 |
if (child.charAt(0) !== '.') { return child; } |
|
51 |
var parts = child.split("/"); |
|
52 |
var parentBase = name.split("/").slice(0, -1); |
|
53 |
|
|
54 |
for (var i=0, l=parts.length; i<l; i++) { |
|
55 |
var part = parts[i]; |
|
56 |
|
|
57 |
if (part === '..') { parentBase.pop(); } |
|
58 |
else if (part === '.') { continue; } |
|
59 |
else { parentBase.push(part); } |
|
60 |
} |
|
61 |
|
|
62 |
return parentBase.join("/"); |
|
63 |
} |
|
64 |
}; |
|
65 |
})(); |
|
66 |
(function() { |
|
67 |
/*globals Em:true ENV EmberENV MetamorphENV:true */ |
|
68 |
|
|
69 |
/** |
|
70 |
@module ember |
|
71 |
@submodule ember-metal |
|
72 |
*/ |
|
73 |
|
|
74 |
/** |
|
75 |
All Ember methods and functions are defined inside of this namespace. You |
|
76 |
generally should not add new properties to this namespace as it may be |
|
77 |
overwritten by future versions of Ember. |
|
78 |
|
|
79 |
You can also use the shorthand `Em` instead of `Ember`. |
|
80 |
|
|
81 |
Ember-Runtime is a framework that provides core functions for Ember including |
|
82 |
cross-platform functions, support for property observing and objects. Its |
|
83 |
focus is on small size and performance. You can use this in place of or |
|
84 |
along-side other cross-platform libraries such as jQuery. |
|
85 |
|
|
86 |
The core Runtime framework is based on the jQuery API with a number of |
|
87 |
performance optimizations. |
|
88 |
|
|
89 |
@class Ember |
|
90 |
@static |
|
91 |
@version 1.4.0 |
|
92 |
*/ |
|
93 |
|
|
94 |
if ('undefined' === typeof Ember) { |
|
95 |
// Create core object. Make it act like an instance of Ember.Namespace so that |
|
96 |
// objects assigned to it are given a sane string representation. |
|
97 |
Ember = {}; |
|
98 |
} |
|
99 |
|
|
100 |
// Default imports, exports and lookup to the global object; |
|
101 |
var imports = Ember.imports = Ember.imports || this; |
|
102 |
var exports = Ember.exports = Ember.exports || this; |
|
103 |
var lookup = Ember.lookup = Ember.lookup || this; |
|
104 |
|
|
105 |
// aliases needed to keep minifiers from removing the global context |
|
106 |
exports.Em = exports.Ember = Em = Ember; |
|
107 |
|
|
108 |
// Make sure these are set whether Ember was already defined or not |
|
109 |
|
|
110 |
Ember.isNamespace = true; |
|
111 |
|
|
112 |
Ember.toString = function() { return "Ember"; }; |
|
113 |
|
|
114 |
|
|
115 |
/** |
|
116 |
@property VERSION |
|
117 |
@type String |
|
118 |
@default '1.4.0' |
|
119 |
@static |
|
120 |
*/ |
|
121 |
Ember.VERSION = '1.4.0'; |
|
122 |
|
|
123 |
/** |
|
124 |
Standard environmental variables. You can define these in a global `EmberENV` |
|
125 |
variable before loading Ember to control various configuration settings. |
|
126 |
|
|
127 |
For backwards compatibility with earlier versions of Ember the global `ENV` |
|
128 |
variable will be used if `EmberENV` is not defined. |
|
129 |
|
|
130 |
@property ENV |
|
131 |
@type Hash |
|
132 |
*/ |
|
133 |
|
|
134 |
// This needs to be kept in sync with the logic in |
|
135 |
// `packages/ember-debug/lib/main.js`. |
|
136 |
if (Ember.ENV) { |
|
137 |
// do nothing if Ember.ENV is already setup |
|
138 |
} else if ('undefined' !== typeof EmberENV) { |
|
139 |
Ember.ENV = EmberENV; |
|
140 |
} else if('undefined' !== typeof ENV) { |
|
141 |
Ember.ENV = ENV; |
|
142 |
} else { |
|
143 |
Ember.ENV = {}; |
|
144 |
} |
|
145 |
|
|
146 |
Ember.config = Ember.config || {}; |
|
147 |
|
|
148 |
// We disable the RANGE API by default for performance reasons |
|
149 |
if ('undefined' === typeof Ember.ENV.DISABLE_RANGE_API) { |
|
150 |
Ember.ENV.DISABLE_RANGE_API = true; |
|
151 |
} |
|
152 |
|
|
153 |
if ("undefined" === typeof MetamorphENV) { |
|
154 |
exports.MetamorphENV = {}; |
|
155 |
} |
|
156 |
|
|
157 |
MetamorphENV.DISABLE_RANGE_API = Ember.ENV.DISABLE_RANGE_API; |
|
158 |
|
|
159 |
/** |
|
160 |
Hash of enabled Canary features. Add to before creating your application. |
|
161 |
|
|
162 |
You can also define `ENV.FEATURES` if you need to enable features flagged at runtime. |
|
163 |
|
|
164 |
@property FEATURES |
|
165 |
@type Hash |
|
166 |
*/ |
|
167 |
|
|
168 |
Ember.FEATURES = Ember.ENV.FEATURES || {}; |
|
169 |
|
|
170 |
/** |
|
171 |
Test that a feature is enabled. Parsed by Ember's build tools to leave |
|
172 |
experimental features out of beta/stable builds. |
|
173 |
|
|
174 |
You can define the following configuration options: |
|
175 |
|
|
176 |
* `ENV.ENABLE_ALL_FEATURES` - force all features to be enabled. |
|
177 |
* `ENV.ENABLE_OPTIONAL_FEATURES` - enable any features that have not been explicitly |
|
178 |
enabled/disabled. |
|
179 |
|
|
180 |
@method isEnabled |
|
181 |
@param {string} feature |
|
182 |
*/ |
|
183 |
|
|
184 |
Ember.FEATURES.isEnabled = function(feature) { |
|
185 |
var featureValue = Ember.FEATURES[feature]; |
|
186 |
|
|
187 |
if (Ember.ENV.ENABLE_ALL_FEATURES) { |
|
188 |
return true; |
|
189 |
} else if (featureValue === true || featureValue === false || featureValue === undefined) { |
|
190 |
return featureValue; |
|
191 |
} else if (Ember.ENV.ENABLE_OPTIONAL_FEATURES) { |
|
192 |
return true; |
|
193 |
} else { |
|
194 |
return false; |
|
195 |
} |
|
196 |
}; |
|
197 |
|
|
198 |
// .......................................................... |
|
199 |
// BOOTSTRAP |
|
200 |
// |
|
201 |
|
|
202 |
/** |
|
203 |
Determines whether Ember should enhances some built-in object prototypes to |
|
204 |
provide a more friendly API. If enabled, a few methods will be added to |
|
205 |
`Function`, `String`, and `Array`. `Object.prototype` will not be enhanced, |
|
206 |
which is the one that causes most trouble for people. |
|
207 |
|
|
208 |
In general we recommend leaving this option set to true since it rarely |
|
209 |
conflicts with other code. If you need to turn it off however, you can |
|
210 |
define an `ENV.EXTEND_PROTOTYPES` config to disable it. |
|
211 |
|
|
212 |
@property EXTEND_PROTOTYPES |
|
213 |
@type Boolean |
|
214 |
@default true |
|
215 |
*/ |
|
216 |
Ember.EXTEND_PROTOTYPES = Ember.ENV.EXTEND_PROTOTYPES; |
|
217 |
|
|
218 |
if (typeof Ember.EXTEND_PROTOTYPES === 'undefined') { |
|
219 |
Ember.EXTEND_PROTOTYPES = true; |
|
220 |
} |
|
221 |
|
|
222 |
/** |
|
223 |
Determines whether Ember logs a full stack trace during deprecation warnings |
|
224 |
|
|
225 |
@property LOG_STACKTRACE_ON_DEPRECATION |
|
226 |
@type Boolean |
|
227 |
@default true |
|
228 |
*/ |
|
229 |
Ember.LOG_STACKTRACE_ON_DEPRECATION = (Ember.ENV.LOG_STACKTRACE_ON_DEPRECATION !== false); |
|
230 |
|
|
231 |
/** |
|
232 |
Determines whether Ember should add ECMAScript 5 shims to older browsers. |
|
233 |
|
|
234 |
@property SHIM_ES5 |
|
235 |
@type Boolean |
|
236 |
@default Ember.EXTEND_PROTOTYPES |
|
237 |
*/ |
|
238 |
Ember.SHIM_ES5 = (Ember.ENV.SHIM_ES5 === false) ? false : Ember.EXTEND_PROTOTYPES; |
|
239 |
|
|
240 |
/** |
|
241 |
Determines whether Ember logs info about version of used libraries |
|
242 |
|
|
243 |
@property LOG_VERSION |
|
244 |
@type Boolean |
|
245 |
@default true |
|
246 |
*/ |
|
247 |
Ember.LOG_VERSION = (Ember.ENV.LOG_VERSION === false) ? false : true; |
|
248 |
|
|
249 |
/** |
|
250 |
Empty function. Useful for some operations. Always returns `this`. |
|
251 |
|
|
252 |
@method K |
|
253 |
@private |
|
254 |
@return {Object} |
|
255 |
*/ |
|
256 |
Ember.K = function() { return this; }; |
|
257 |
|
|
258 |
|
|
259 |
// Stub out the methods defined by the ember-debug package in case it's not loaded |
|
260 |
|
|
261 |
if ('undefined' === typeof Ember.assert) { Ember.assert = Ember.K; } |
|
262 |
if ('undefined' === typeof Ember.warn) { Ember.warn = Ember.K; } |
|
263 |
if ('undefined' === typeof Ember.debug) { Ember.debug = Ember.K; } |
|
264 |
if ('undefined' === typeof Ember.deprecate) { Ember.deprecate = Ember.K; } |
|
265 |
if ('undefined' === typeof Ember.deprecateFunc) { |
|
266 |
Ember.deprecateFunc = function(_, func) { return func; }; |
|
267 |
} |
|
268 |
|
|
269 |
/** |
|
270 |
Previously we used `Ember.$.uuid`, however `$.uuid` has been removed from |
|
271 |
jQuery master. We'll just bootstrap our own uuid now. |
|
272 |
|
|
273 |
@property uuid |
|
274 |
@type Number |
|
275 |
@private |
|
276 |
*/ |
|
277 |
Ember.uuid = 0; |
|
278 |
|
|
279 |
/** |
|
280 |
Merge the contents of two objects together into the first object. |
|
281 |
|
|
282 |
```javascript |
|
283 |
Ember.merge({first: 'Tom'}, {last: 'Dale'}); // {first: 'Tom', last: 'Dale'} |
|
284 |
var a = {first: 'Yehuda'}, b = {last: 'Katz'}; |
|
285 |
Ember.merge(a, b); // a == {first: 'Yehuda', last: 'Katz'}, b == {last: 'Katz'} |
|
286 |
``` |
|
287 |
|
|
288 |
@method merge |
|
289 |
@for Ember |
|
290 |
@param {Object} original The object to merge into |
|
291 |
@param {Object} updates The object to copy properties from |
|
292 |
@return {Object} |
|
293 |
*/ |
|
294 |
Ember.merge = function(original, updates) { |
|
295 |
for (var prop in updates) { |
|
296 |
if (!updates.hasOwnProperty(prop)) { continue; } |
|
297 |
original[prop] = updates[prop]; |
|
298 |
} |
|
299 |
return original; |
|
300 |
}; |
|
301 |
|
|
302 |
/** |
|
303 |
Returns true if the passed value is null or undefined. This avoids errors |
|
304 |
from JSLint complaining about use of ==, which can be technically |
|
305 |
confusing. |
|
306 |
|
|
307 |
```javascript |
|
308 |
Ember.isNone(); // true |
|
309 |
Ember.isNone(null); // true |
|
310 |
Ember.isNone(undefined); // true |
|
311 |
Ember.isNone(''); // false |
|
312 |
Ember.isNone([]); // false |
|
313 |
Ember.isNone(function() {}); // false |
|
314 |
``` |
|
315 |
|
|
316 |
@method isNone |
|
317 |
@for Ember |
|
318 |
@param {Object} obj Value to test |
|
319 |
@return {Boolean} |
|
320 |
*/ |
|
321 |
Ember.isNone = function(obj) { |
|
322 |
return obj === null || obj === undefined; |
|
323 |
}; |
|
324 |
Ember.none = Ember.deprecateFunc("Ember.none is deprecated. Please use Ember.isNone instead.", Ember.isNone); |
|
325 |
|
|
326 |
/** |
|
327 |
Verifies that a value is `null` or an empty string, empty array, |
|
328 |
or empty function. |
|
329 |
|
|
330 |
Constrains the rules on `Ember.isNone` by returning false for empty |
|
331 |
string and empty arrays. |
|
332 |
|
|
333 |
```javascript |
|
334 |
Ember.isEmpty(); // true |
|
335 |
Ember.isEmpty(null); // true |
|
336 |
Ember.isEmpty(undefined); // true |
|
337 |
Ember.isEmpty(''); // true |
|
338 |
Ember.isEmpty([]); // true |
|
339 |
Ember.isEmpty('Adam Hawkins'); // false |
|
340 |
Ember.isEmpty([0,1,2]); // false |
|
341 |
``` |
|
342 |
|
|
343 |
@method isEmpty |
|
344 |
@for Ember |
|
345 |
@param {Object} obj Value to test |
|
346 |
@return {Boolean} |
|
347 |
*/ |
|
348 |
Ember.isEmpty = function(obj) { |
|
349 |
return Ember.isNone(obj) || (obj.length === 0 && typeof obj !== 'function') || (typeof obj === 'object' && Ember.get(obj, 'length') === 0); |
|
350 |
}; |
|
351 |
Ember.empty = Ember.deprecateFunc("Ember.empty is deprecated. Please use Ember.isEmpty instead.", Ember.isEmpty) ; |
|
352 |
|
|
353 |
|
|
354 |
})(); |
|
355 |
|
|
356 |
|
|
357 |
|
|
358 |
(function() { |
|
359 |
/*globals Node */ |
|
360 |
/** |
|
361 |
@module ember-metal |
|
362 |
*/ |
|
363 |
|
|
364 |
/** |
|
365 |
Platform specific methods and feature detectors needed by the framework. |
|
366 |
|
|
367 |
@class platform |
|
368 |
@namespace Ember |
|
369 |
@static |
|
370 |
*/ |
|
371 |
var platform = Ember.platform = {}; |
|
372 |
|
|
373 |
|
|
374 |
/** |
|
375 |
Identical to `Object.create()`. Implements if not available natively. |
|
376 |
|
|
377 |
@method create |
|
378 |
@for Ember |
|
379 |
*/ |
|
380 |
Ember.create = Object.create; |
|
381 |
|
|
382 |
// IE8 has Object.create but it couldn't treat property descriptors. |
|
383 |
if (Ember.create) { |
|
384 |
if (Ember.create({a: 1}, {a: {value: 2}}).a !== 2) { |
|
385 |
Ember.create = null; |
|
386 |
} |
|
387 |
} |
|
388 |
|
|
389 |
// STUB_OBJECT_CREATE allows us to override other libraries that stub |
|
390 |
// Object.create different than we would prefer |
|
391 |
if (!Ember.create || Ember.ENV.STUB_OBJECT_CREATE) { |
|
392 |
var K = function() {}; |
|
393 |
|
|
394 |
Ember.create = function(obj, props) { |
|
395 |
K.prototype = obj; |
|
396 |
obj = new K(); |
|
397 |
if (props) { |
|
398 |
K.prototype = obj; |
|
399 |
for (var prop in props) { |
|
400 |
K.prototype[prop] = props[prop].value; |
|
401 |
} |
|
402 |
obj = new K(); |
|
403 |
} |
|
404 |
K.prototype = null; |
|
405 |
|
|
406 |
return obj; |
|
407 |
}; |
|
408 |
|
|
409 |
Ember.create.isSimulated = true; |
|
410 |
} |
|
411 |
|
|
412 |
var defineProperty = Object.defineProperty; |
|
413 |
var canRedefineProperties, canDefinePropertyOnDOM; |
|
414 |
|
|
415 |
// Catch IE8 where Object.defineProperty exists but only works on DOM elements |
|
416 |
if (defineProperty) { |
|
417 |
try { |
|
418 |
defineProperty({}, 'a',{get:function() {}}); |
|
419 |
} catch (e) { |
|
420 |
defineProperty = null; |
|
421 |
} |
|
422 |
} |
|
423 |
|
|
424 |
if (defineProperty) { |
|
425 |
// Detects a bug in Android <3.2 where you cannot redefine a property using |
|
426 |
// Object.defineProperty once accessors have already been set. |
|
427 |
canRedefineProperties = (function() { |
|
428 |
var obj = {}; |
|
429 |
|
|
430 |
defineProperty(obj, 'a', { |
|
431 |
configurable: true, |
|
432 |
enumerable: true, |
|
433 |
get: function() { }, |
|
434 |
set: function() { } |
|
435 |
}); |
|
436 |
|
|
437 |
defineProperty(obj, 'a', { |
|
438 |
configurable: true, |
|
439 |
enumerable: true, |
|
440 |
writable: true, |
|
441 |
value: true |
|
442 |
}); |
|
443 |
|
|
444 |
return obj.a === true; |
|
445 |
})(); |
|
446 |
|
|
447 |
// This is for Safari 5.0, which supports Object.defineProperty, but not |
|
448 |
// on DOM nodes. |
|
449 |
canDefinePropertyOnDOM = (function() { |
|
450 |
try { |
|
451 |
defineProperty(document.createElement('div'), 'definePropertyOnDOM', {}); |
|
452 |
return true; |
|
453 |
} catch(e) { } |
|
454 |
|
|
455 |
return false; |
|
456 |
})(); |
|
457 |
|
|
458 |
if (!canRedefineProperties) { |
|
459 |
defineProperty = null; |
|
460 |
} else if (!canDefinePropertyOnDOM) { |
|
461 |
defineProperty = function(obj, keyName, desc) { |
|
462 |
var isNode; |
|
463 |
|
|
464 |
if (typeof Node === "object") { |
|
465 |
isNode = obj instanceof Node; |
|
466 |
} else { |
|
467 |
isNode = typeof obj === "object" && typeof obj.nodeType === "number" && typeof obj.nodeName === "string"; |
|
468 |
} |
|
469 |
|
|
470 |
if (isNode) { |
|
471 |
// TODO: Should we have a warning here? |
|
472 |
return (obj[keyName] = desc.value); |
|
473 |
} else { |
|
474 |
return Object.defineProperty(obj, keyName, desc); |
|
475 |
} |
|
476 |
}; |
|
477 |
} |
|
478 |
} |
|
479 |
|
|
480 |
/** |
|
481 |
@class platform |
|
482 |
@namespace Ember |
|
483 |
*/ |
|
484 |
|
|
485 |
/** |
|
486 |
Identical to `Object.defineProperty()`. Implements as much functionality |
|
487 |
as possible if not available natively. |
|
488 |
|
|
489 |
@method defineProperty |
|
490 |
@param {Object} obj The object to modify |
|
491 |
@param {String} keyName property name to modify |
|
492 |
@param {Object} desc descriptor hash |
|
493 |
@return {void} |
|
494 |
*/ |
|
495 |
platform.defineProperty = defineProperty; |
|
496 |
|
|
497 |
/** |
|
498 |
Set to true if the platform supports native getters and setters. |
|
499 |
|
|
500 |
@property hasPropertyAccessors |
|
501 |
@final |
|
502 |
*/ |
|
503 |
platform.hasPropertyAccessors = true; |
|
504 |
|
|
505 |
if (!platform.defineProperty) { |
|
506 |
platform.hasPropertyAccessors = false; |
|
507 |
|
|
508 |
platform.defineProperty = function(obj, keyName, desc) { |
|
509 |
if (!desc.get) { obj[keyName] = desc.value; } |
|
510 |
}; |
|
511 |
|
|
512 |
platform.defineProperty.isSimulated = true; |
|
513 |
} |
|
514 |
|
|
515 |
if (Ember.ENV.MANDATORY_SETTER && !platform.hasPropertyAccessors) { |
|
516 |
Ember.ENV.MANDATORY_SETTER = false; |
|
517 |
} |
|
518 |
|
|
519 |
})(); |
|
520 |
|
|
521 |
|
|
522 |
|
|
523 |
(function() { |
|
524 |
/*jshint newcap:false*/ |
|
525 |
/** |
|
526 |
@module ember-metal |
|
527 |
*/ |
|
528 |
|
|
529 |
// NOTE: There is a bug in jshint that doesn't recognize `Object()` without `new` |
|
530 |
// as being ok unless both `newcap:false` and not `use strict`. |
|
531 |
// https://github.com/jshint/jshint/issues/392 |
|
532 |
|
|
533 |
// Testing this is not ideal, but we want to use native functions |
|
534 |
// if available, but not to use versions created by libraries like Prototype |
|
535 |
var isNativeFunc = function(func) { |
|
536 |
// This should probably work in all browsers likely to have ES5 array methods |
|
537 |
return func && Function.prototype.toString.call(func).indexOf('[native code]') > -1; |
|
538 |
}; |
|
539 |
|
|
540 |
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/map |
|
541 |
var arrayMap = isNativeFunc(Array.prototype.map) ? Array.prototype.map : function(fun /*, thisp */) { |
|
542 |
//"use strict"; |
|
543 |
|
|
544 |
if (this === void 0 || this === null) { |
|
545 |
throw new TypeError(); |
|
546 |
} |
|
547 |
|
|
548 |
var t = Object(this); |
|
549 |
var len = t.length >>> 0; |
|
550 |
if (typeof fun !== "function") { |
|
551 |
throw new TypeError(); |
|
552 |
} |
|
553 |
|
|
554 |
var res = new Array(len); |
|
555 |
var thisp = arguments[1]; |
|
556 |
for (var i = 0; i < len; i++) { |
|
557 |
if (i in t) { |
|
558 |
res[i] = fun.call(thisp, t[i], i, t); |
|
559 |
} |
|
560 |
} |
|
561 |
|
|
562 |
return res; |
|
563 |
}; |
|
564 |
|
|
565 |
// From: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/array/foreach |
|
566 |
var arrayForEach = isNativeFunc(Array.prototype.forEach) ? Array.prototype.forEach : function(fun /*, thisp */) { |
|
567 |
//"use strict"; |
|
568 |
|
|
569 |
if (this === void 0 || this === null) { |
|
570 |
throw new TypeError(); |
|
571 |
} |
|
572 |
|
|
573 |
var t = Object(this); |
|
574 |
var len = t.length >>> 0; |
|
575 |
if (typeof fun !== "function") { |
|
576 |
throw new TypeError(); |
|
577 |
} |
|
578 |
|
|
579 |
var thisp = arguments[1]; |
|
580 |
for (var i = 0; i < len; i++) { |
|
581 |
if (i in t) { |
|
582 |
fun.call(thisp, t[i], i, t); |
|
583 |
} |
|
584 |
} |
|
585 |
}; |
|
586 |
|
|
587 |
var arrayIndexOf = isNativeFunc(Array.prototype.indexOf) ? Array.prototype.indexOf : function (obj, fromIndex) { |
|
588 |
if (fromIndex === null || fromIndex === undefined) { fromIndex = 0; } |
|
589 |
else if (fromIndex < 0) { fromIndex = Math.max(0, this.length + fromIndex); } |
|
590 |
for (var i = fromIndex, j = this.length; i < j; i++) { |
|
591 |
if (this[i] === obj) { return i; } |
|
592 |
} |
|
593 |
return -1; |
|
594 |
}; |
|
595 |
|
|
596 |
|
|
597 |
/** |
|
598 |
Array polyfills to support ES5 features in older browsers. |
|
599 |
|
|
600 |
@namespace Ember |
|
601 |
@property ArrayPolyfills |
|
602 |
*/ |
|
603 |
Ember.ArrayPolyfills = { |
|
604 |
map: arrayMap, |
|
605 |
forEach: arrayForEach, |
|
606 |
indexOf: arrayIndexOf |
|
607 |
}; |
|
608 |
|
|
609 |
|
|
610 |
if (Ember.SHIM_ES5) { |
|
611 |
if (!Array.prototype.map) { |
|
612 |
Array.prototype.map = arrayMap; |
|
613 |
} |
|
614 |
|
|
615 |
if (!Array.prototype.forEach) { |
|
616 |
Array.prototype.forEach = arrayForEach; |
|
617 |
} |
|
618 |
|
|
619 |
if (!Array.prototype.indexOf) { |
|
620 |
Array.prototype.indexOf = arrayIndexOf; |
|
621 |
} |
|
622 |
} |
|
623 |
|
|
624 |
})(); |
|
625 |
|
|
626 |
|
|
627 |
|
|
628 |
(function() { |
|
629 |
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; |
|
630 |
|
|
631 |
/** |
|
632 |
A subclass of the JavaScript Error object for use in Ember. |
|
633 |
|
|
634 |
@class Error |
|
635 |
@namespace Ember |
|
636 |
@extends Error |
|
637 |
@constructor |
|
638 |
*/ |
|
639 |
Ember.Error = function() { |
|
640 |
var tmp = Error.apply(this, arguments); |
|
641 |
|
|
642 |
// Adds a `stack` property to the given error object that will yield the |
|
643 |
// stack trace at the time captureStackTrace was called. |
|
644 |
// When collecting the stack trace all frames above the topmost call |
|
645 |
// to this function, including that call, will be left out of the |
|
646 |
// stack trace. |
|
647 |
// This is useful because we can hide Ember implementation details |
|
648 |
// that are not very helpful for the user. |
|
649 |
if (Error.captureStackTrace) { |
|
650 |
Error.captureStackTrace(this, Ember.Error); |
|
651 |
} |
|
652 |
// Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. |
|
653 |
for (var idx = 0; idx < errorProps.length; idx++) { |
|
654 |
this[errorProps[idx]] = tmp[errorProps[idx]]; |
|
655 |
} |
|
656 |
}; |
|
657 |
|
|
658 |
Ember.Error.prototype = Ember.create(Error.prototype); |
|
659 |
|
|
660 |
// .......................................................... |
|
661 |
// ERROR HANDLING |
|
662 |
// |
|
663 |
|
|
664 |
/** |
|
665 |
A function may be assigned to `Ember.onerror` to be called when Ember |
|
666 |
internals encounter an error. This is useful for specialized error handling |
|
667 |
and reporting code. |
|
668 |
|
|
669 |
```javascript |
|
670 |
Ember.onerror = function(error) { |
|
671 |
Em.$.ajax('/report-error', 'POST', { |
|
672 |
stack: error.stack, |
|
673 |
otherInformation: 'whatever app state you want to provide' |
|
674 |
}); |
|
675 |
}; |
|
676 |
``` |
|
677 |
|
|
678 |
@event onerror |
|
679 |
@for Ember |
|
680 |
@param {Exception} error the error object |
|
681 |
*/ |
|
682 |
Ember.onerror = null; |
|
683 |
|
|
684 |
/** |
|
685 |
Wrap code block in a try/catch if `Ember.onerror` is set. |
|
686 |
|
|
687 |
@private |
|
688 |
@method handleErrors |
|
689 |
@for Ember |
|
690 |
@param {Function} func |
|
691 |
@param [context] |
|
692 |
*/ |
|
693 |
Ember.handleErrors = function(func, context) { |
|
694 |
// Unfortunately in some browsers we lose the backtrace if we rethrow the existing error, |
|
695 |
// so in the event that we don't have an `onerror` handler we don't wrap in a try/catch |
|
696 |
if ('function' === typeof Ember.onerror) { |
|
697 |
try { |
|
698 |
return func.call(context || this); |
|
699 |
} catch (error) { |
|
700 |
Ember.onerror(error); |
|
701 |
} |
|
702 |
} else { |
|
703 |
return func.call(context || this); |
|
704 |
} |
|
705 |
}; |
|
706 |
|
|
707 |
})(); |
|
708 |
|
|
709 |
|
|
710 |
|
|
711 |
(function() { |
|
712 |
/** |
|
713 |
@module ember-metal |
|
714 |
*/ |
|
715 |
|
|
716 |
/** |
|
717 |
Prefix used for guids through out Ember. |
|
718 |
@private |
|
719 |
*/ |
|
720 |
Ember.GUID_PREFIX = 'ember'; |
|
721 |
|
|
722 |
|
|
723 |
var o_defineProperty = Ember.platform.defineProperty, |
|
724 |
o_create = Ember.create, |
|
725 |
// Used for guid generation... |
|
726 |
GUID_KEY = '__ember'+ (+ new Date()), |
|
727 |
uuid = 0, |
|
728 |
numberCache = [], |
|
729 |
stringCache = {}; |
|
730 |
|
|
731 |
var MANDATORY_SETTER = Ember.ENV.MANDATORY_SETTER; |
|
732 |
|
|
733 |
/** |
|
734 |
A unique key used to assign guids and other private metadata to objects. |
|
735 |
If you inspect an object in your browser debugger you will often see these. |
|
736 |
They can be safely ignored. |
|
737 |
|
|
738 |
On browsers that support it, these properties are added with enumeration |
|
739 |
disabled so they won't show up when you iterate over your properties. |
|
740 |
|
|
741 |
@private |
|
742 |
@property GUID_KEY |
|
743 |
@for Ember |
|
744 |
@type String |
|
745 |
@final |
|
746 |
*/ |
|
747 |
Ember.GUID_KEY = GUID_KEY; |
|
748 |
|
|
749 |
var GUID_DESC = { |
|
750 |
writable: false, |
|
751 |
configurable: false, |
|
752 |
enumerable: false, |
|
753 |
value: null |
|
754 |
}; |
|
755 |
|
|
756 |
/** |
|
757 |
Generates a new guid, optionally saving the guid to the object that you |
|
758 |
pass in. You will rarely need to use this method. Instead you should |
|
759 |
call `Ember.guidFor(obj)`, which return an existing guid if available. |
|
760 |
|
|
761 |
@private |
|
762 |
@method generateGuid |
|
763 |
@for Ember |
|
764 |
@param {Object} [obj] Object the guid will be used for. If passed in, the guid will |
|
765 |
be saved on the object and reused whenever you pass the same object |
|
766 |
again. |
|
767 |
|
|
768 |
If no object is passed, just generate a new guid. |
|
769 |
@param {String} [prefix] Prefix to place in front of the guid. Useful when you want to |
|
770 |
separate the guid into separate namespaces. |
|
771 |
@return {String} the guid |
|
772 |
*/ |
|
773 |
Ember.generateGuid = function generateGuid(obj, prefix) { |
|
774 |
if (!prefix) prefix = Ember.GUID_PREFIX; |
|
775 |
var ret = (prefix + (uuid++)); |
|
776 |
if (obj) { |
|
777 |
GUID_DESC.value = ret; |
|
778 |
o_defineProperty(obj, GUID_KEY, GUID_DESC); |
|
779 |
} |
|
780 |
return ret; |
|
781 |
}; |
|
782 |
|
|
783 |
/** |
|
784 |
Returns a unique id for the object. If the object does not yet have a guid, |
|
785 |
one will be assigned to it. You can call this on any object, |
|
786 |
`Ember.Object`-based or not, but be aware that it will add a `_guid` |
|
787 |
property. |
|
788 |
|
|
789 |
You can also use this method on DOM Element objects. |
|
790 |
|
|
791 |
@private |
|
792 |
@method guidFor |
|
793 |
@for Ember |
|
794 |
@param {Object} obj any object, string, number, Element, or primitive |
|
795 |
@return {String} the unique guid for this instance. |
|
796 |
*/ |
|
797 |
Ember.guidFor = function guidFor(obj) { |
|
798 |
|
|
799 |
// special cases where we don't want to add a key to object |
|
800 |
if (obj === undefined) return "(undefined)"; |
|
801 |
if (obj === null) return "(null)"; |
|
802 |
|
|
803 |
var ret; |
|
804 |
var type = typeof obj; |
|
805 |
|
|
806 |
// Don't allow prototype changes to String etc. to change the guidFor |
|
807 |
switch(type) { |
|
808 |
case 'number': |
|
809 |
ret = numberCache[obj]; |
|
810 |
if (!ret) ret = numberCache[obj] = 'nu'+obj; |
|
811 |
return ret; |
|
812 |
|
|
813 |
case 'string': |
|
814 |
ret = stringCache[obj]; |
|
815 |
if (!ret) ret = stringCache[obj] = 'st'+(uuid++); |
|
816 |
return ret; |
|
817 |
|
|
818 |
case 'boolean': |
|
819 |
return obj ? '(true)' : '(false)'; |
|
820 |
|
|
821 |
default: |
|
822 |
if (obj[GUID_KEY]) return obj[GUID_KEY]; |
|
823 |
if (obj === Object) return '(Object)'; |
|
824 |
if (obj === Array) return '(Array)'; |
|
825 |
ret = 'ember'+(uuid++); |
|
826 |
GUID_DESC.value = ret; |
|
827 |
o_defineProperty(obj, GUID_KEY, GUID_DESC); |
|
828 |
return ret; |
|
829 |
} |
|
830 |
}; |
|
831 |
|
|
832 |
// .......................................................... |
|
833 |
// META |
|
834 |
// |
|
835 |
|
|
836 |
var META_DESC = Ember.META_DESC = { |
|
837 |
writable: true, |
|
838 |
configurable: false, |
|
839 |
enumerable: false, |
|
840 |
value: null |
|
841 |
}; |
|
842 |
|
|
843 |
var META_KEY = Ember.GUID_KEY+'_meta'; |
|
844 |
|
|
845 |
/** |
|
846 |
The key used to store meta information on object for property observing. |
|
847 |
|
|
848 |
@property META_KEY |
|
849 |
@for Ember |
|
850 |
@private |
|
851 |
@final |
|
852 |
@type String |
|
853 |
*/ |
|
854 |
Ember.META_KEY = META_KEY; |
|
855 |
|
|
856 |
var isDefinePropertySimulated = Ember.platform.defineProperty.isSimulated; |
|
857 |
|
|
858 |
function Meta(obj) { |
|
859 |
this.descs = {}; |
|
860 |
this.watching = {}; |
|
861 |
this.cache = {}; |
|
862 |
this.source = obj; |
|
863 |
} |
|
864 |
|
|
865 |
Meta.prototype = { |
|
866 |
descs: null, |
|
867 |
deps: null, |
|
868 |
watching: null, |
|
869 |
listeners: null, |
|
870 |
cache: null, |
|
871 |
source: null, |
|
872 |
mixins: null, |
|
873 |
bindings: null, |
|
874 |
chains: null, |
|
875 |
chainWatchers: null, |
|
876 |
values: null, |
|
877 |
proto: null |
|
878 |
}; |
|
879 |
|
|
880 |
if (isDefinePropertySimulated) { |
|
881 |
// on platforms that don't support enumerable false |
|
882 |
// make meta fail jQuery.isPlainObject() to hide from |
|
883 |
// jQuery.extend() by having a property that fails |
|
884 |
// hasOwnProperty check. |
|
885 |
Meta.prototype.__preventPlainObject__ = true; |
|
886 |
|
|
887 |
// Without non-enumerable properties, meta objects will be output in JSON |
|
888 |
// unless explicitly suppressed |
|
889 |
Meta.prototype.toJSON = function () { }; |
|
890 |
} |
|
891 |
|
|
892 |
// Placeholder for non-writable metas. |
|
893 |
var EMPTY_META = new Meta(null); |
|
894 |
|
|
895 |
if (MANDATORY_SETTER) { EMPTY_META.values = {}; } |
|
896 |
|
|
897 |
Ember.EMPTY_META = EMPTY_META; |
|
898 |
|
|
899 |
/** |
|
900 |
Retrieves the meta hash for an object. If `writable` is true ensures the |
|
901 |
hash is writable for this object as well. |
|
902 |
|
|
903 |
The meta object contains information about computed property descriptors as |
|
904 |
well as any watched properties and other information. You generally will |
|
905 |
not access this information directly but instead work with higher level |
|
906 |
methods that manipulate this hash indirectly. |
|
907 |
|
|
908 |
@method meta |
|
909 |
@for Ember |
|
910 |
@private |
|
911 |
|
|
912 |
@param {Object} obj The object to retrieve meta for |
|
913 |
@param {Boolean} [writable=true] Pass `false` if you do not intend to modify |
|
914 |
the meta hash, allowing the method to avoid making an unnecessary copy. |
|
915 |
@return {Object} the meta hash for an object |
|
916 |
*/ |
|
917 |
Ember.meta = function meta(obj, writable) { |
|
918 |
|
|
919 |
var ret = obj[META_KEY]; |
|
920 |
if (writable===false) return ret || EMPTY_META; |
|
921 |
|
|
922 |
if (!ret) { |
|
923 |
if (!isDefinePropertySimulated) o_defineProperty(obj, META_KEY, META_DESC); |
|
924 |
|
|
925 |
ret = new Meta(obj); |
|
926 |
|
|
927 |
if (MANDATORY_SETTER) { ret.values = {}; } |
|
928 |
|
|
929 |
obj[META_KEY] = ret; |
|
930 |
|
|
931 |
// make sure we don't accidentally try to create constructor like desc |
|
932 |
ret.descs.constructor = null; |
|
933 |
|
|
934 |
} else if (ret.source !== obj) { |
|
935 |
if (!isDefinePropertySimulated) o_defineProperty(obj, META_KEY, META_DESC); |
|
936 |
|
|
937 |
ret = o_create(ret); |
|
938 |
ret.descs = o_create(ret.descs); |
|
939 |
ret.watching = o_create(ret.watching); |
|
940 |
ret.cache = {}; |
|
941 |
ret.source = obj; |
|
942 |
|
|
943 |
if (MANDATORY_SETTER) { ret.values = o_create(ret.values); } |
|
944 |
|
|
945 |
obj[META_KEY] = ret; |
|
946 |
} |
|
947 |
return ret; |
|
948 |
}; |
|
949 |
|
|
950 |
Ember.getMeta = function getMeta(obj, property) { |
|
951 |
var meta = Ember.meta(obj, false); |
|
952 |
return meta[property]; |
|
953 |
}; |
|
954 |
|
|
955 |
Ember.setMeta = function setMeta(obj, property, value) { |
|
956 |
var meta = Ember.meta(obj, true); |
|
957 |
meta[property] = value; |
|
958 |
return value; |
|
959 |
}; |
|
960 |
|
|
961 |
/** |
|
962 |
@deprecated |
|
963 |
@private |
|
964 |
|
|
965 |
In order to store defaults for a class, a prototype may need to create |
|
966 |
a default meta object, which will be inherited by any objects instantiated |
|
967 |
from the class's constructor. |
|
968 |
|
|
969 |
However, the properties of that meta object are only shallow-cloned, |
|
970 |
so if a property is a hash (like the event system's `listeners` hash), |
|
971 |
it will by default be shared across all instances of that class. |
|
972 |
|
|
973 |
This method allows extensions to deeply clone a series of nested hashes or |
|
974 |
other complex objects. For instance, the event system might pass |
|
975 |
`['listeners', 'foo:change', 'ember157']` to `prepareMetaPath`, which will |
|
976 |
walk down the keys provided. |
|
977 |
|
|
978 |
For each key, if the key does not exist, it is created. If it already |
|
979 |
exists and it was inherited from its constructor, the constructor's |
|
980 |
key is cloned. |
|
981 |
|
|
982 |
You can also pass false for `writable`, which will simply return |
|
983 |
undefined if `prepareMetaPath` discovers any part of the path that |
|
984 |
shared or undefined. |
|
985 |
|
|
986 |
@method metaPath |
|
987 |
@for Ember |
|
988 |
@param {Object} obj The object whose meta we are examining |
|
989 |
@param {Array} path An array of keys to walk down |
|
990 |
@param {Boolean} writable whether or not to create a new meta |
|
991 |
(or meta property) if one does not already exist or if it's |
|
992 |
shared with its constructor |
|
993 |
*/ |
|
994 |
Ember.metaPath = function metaPath(obj, path, writable) { |
|
995 |
var meta = Ember.meta(obj, writable), keyName, value; |
|
996 |
|
|
997 |
for (var i=0, l=path.length; i<l; i++) { |
|
998 |
keyName = path[i]; |
|
999 |
value = meta[keyName]; |
|
1000 |
|
|
1001 |
if (!value) { |
|
1002 |
if (!writable) { return undefined; } |
|
1003 |
value = meta[keyName] = { __ember_source__: obj }; |
|
1004 |
} else if (value.__ember_source__ !== obj) { |
|
1005 |
if (!writable) { return undefined; } |
|
1006 |
value = meta[keyName] = o_create(value); |
|
1007 |
value.__ember_source__ = obj; |
|
1008 |
} |
|
1009 |
|
|
1010 |
meta = value; |
|
1011 |
} |
|
1012 |
|
|
1013 |
return value; |
|
1014 |
}; |
|
1015 |
|
|
1016 |
/** |
|
1017 |
Wraps the passed function so that `this._super` will point to the superFunc |
|
1018 |
when the function is invoked. This is the primitive we use to implement |
|
1019 |
calls to super. |
|
1020 |
|
|
1021 |
@private |
|
1022 |
@method wrap |
|
1023 |
@for Ember |
|
1024 |
@param {Function} func The function to call |
|
1025 |
@param {Function} superFunc The super function. |
|
1026 |
@return {Function} wrapped function. |
|
1027 |
*/ |
|
1028 |
Ember.wrap = function(func, superFunc) { |
|
1029 |
function K() {} |
|
1030 |
|
|
1031 |
function superWrapper() { |
|
1032 |
var ret, sup = this._super; |
|
1033 |
this._super = superFunc || K; |
|
1034 |
ret = func.apply(this, arguments); |
|
1035 |
this._super = sup; |
|
1036 |
return ret; |
|
1037 |
} |
|
1038 |
|
|
1039 |
superWrapper.wrappedFunction = func; |
|
1040 |
superWrapper.__ember_observes__ = func.__ember_observes__; |
|
1041 |
superWrapper.__ember_observesBefore__ = func.__ember_observesBefore__; |
|
1042 |
superWrapper.__ember_listens__ = func.__ember_listens__; |
|
1043 |
|
|
1044 |
return superWrapper; |
|
1045 |
}; |
|
1046 |
|
|
1047 |
/** |
|
1048 |
Returns true if the passed object is an array or Array-like. |
|
1049 |
|
|
1050 |
Ember Array Protocol: |
|
1051 |
|
|
1052 |
- the object has an objectAt property |
|
1053 |
- the object is a native Array |
|
1054 |
- the object is an Object, and has a length property |
|
1055 |
|
|
1056 |
Unlike `Ember.typeOf` this method returns true even if the passed object is |
|
1057 |
not formally array but appears to be array-like (i.e. implements `Ember.Array`) |
|
1058 |
|
|
1059 |
```javascript |
|
1060 |
Ember.isArray(); // false |
|
1061 |
Ember.isArray([]); // true |
|
1062 |
Ember.isArray( Ember.ArrayProxy.create({ content: [] }) ); // true |
|
1063 |
``` |
|
1064 |
|
|
1065 |
@method isArray |
|
1066 |
@for Ember |
|
1067 |
@param {Object} obj The object to test |
|
1068 |
@return {Boolean} true if the passed object is an array or Array-like |
|
1069 |
*/ |
|
1070 |
Ember.isArray = function(obj) { |
|
1071 |
if (!obj || obj.setInterval) { return false; } |
|
1072 |
if (Array.isArray && Array.isArray(obj)) { return true; } |
|
1073 |
if (Ember.Array && Ember.Array.detect(obj)) { return true; } |
|
1074 |
if ((obj.length !== undefined) && 'object'===typeof obj) { return true; } |
|
1075 |
return false; |
|
1076 |
}; |
|
1077 |
|
|
1078 |
/** |
|
1079 |
Forces the passed object to be part of an array. If the object is already |
|
1080 |
an array or array-like, returns the object. Otherwise adds the object to |
|
1081 |
an array. If obj is `null` or `undefined`, returns an empty array. |
|
1082 |
|
|
1083 |
```javascript |
|
1084 |
Ember.makeArray(); // [] |
|
1085 |
Ember.makeArray(null); // [] |
|
1086 |
Ember.makeArray(undefined); // [] |
|
1087 |
Ember.makeArray('lindsay'); // ['lindsay'] |
|
1088 |
Ember.makeArray([1,2,42]); // [1,2,42] |
|
1089 |
|
|
1090 |
var controller = Ember.ArrayProxy.create({ content: [] }); |
|
1091 |
Ember.makeArray(controller) === controller; // true |
|
1092 |
``` |
|
1093 |
|
|
1094 |
@method makeArray |
|
1095 |
@for Ember |
|
1096 |
@param {Object} obj the object |
|
1097 |
@return {Array} |
|
1098 |
*/ |
|
1099 |
Ember.makeArray = function(obj) { |
|
1100 |
if (obj === null || obj === undefined) { return []; } |
|
1101 |
return Ember.isArray(obj) ? obj : [obj]; |
|
1102 |
}; |
|
1103 |
|
|
1104 |
function canInvoke(obj, methodName) { |
|
1105 |
return !!(obj && typeof obj[methodName] === 'function'); |
|
1106 |
} |
|
1107 |
|
|
1108 |
/** |
|
1109 |
Checks to see if the `methodName` exists on the `obj`. |
|
1110 |
|
|
1111 |
```javascript |
|
1112 |
var foo = {bar: Ember.K, baz: null}; |
|
1113 |
Ember.canInvoke(foo, 'bar'); // true |
|
1114 |
Ember.canInvoke(foo, 'baz'); // false |
|
1115 |
Ember.canInvoke(foo, 'bat'); // false |
|
1116 |
``` |
|
1117 |
|
|
1118 |
@method canInvoke |
|
1119 |
@for Ember |
|
1120 |
@param {Object} obj The object to check for the method |
|
1121 |
@param {String} methodName The method name to check for |
|
1122 |
@return {Boolean} |
|
1123 |
*/ |
|
1124 |
Ember.canInvoke = canInvoke; |
|
1125 |
|
|
1126 |
/** |
|
1127 |
Checks to see if the `methodName` exists on the `obj`, |
|
1128 |
and if it does, invokes it with the arguments passed. |
|
1129 |
|
|
1130 |
```javascript |
|
1131 |
var d = new Date('03/15/2013'); |
|
1132 |
Ember.tryInvoke(d, 'getTime'); // 1363320000000 |
|
1133 |
Ember.tryInvoke(d, 'setFullYear', [2014]); // 1394856000000 |
|
1134 |
Ember.tryInvoke(d, 'noSuchMethod', [2014]); // undefined |
|
1135 |
``` |
|
1136 |
|
|
1137 |
@method tryInvoke |
|
1138 |
@for Ember |
|
1139 |
@param {Object} obj The object to check for the method |
|
1140 |
@param {String} methodName The method name to check for |
|
1141 |
@param {Array} [args] The arguments to pass to the method |
|
1142 |
@return {*} the return value of the invoked method or undefined if it cannot be invoked |
|
1143 |
*/ |
|
1144 |
Ember.tryInvoke = function(obj, methodName, args) { |
|
1145 |
if (canInvoke(obj, methodName)) { |
|
1146 |
return obj[methodName].apply(obj, args || []); |
|
1147 |
} |
|
1148 |
}; |
|
1149 |
|
|
1150 |
// https://github.com/emberjs/ember.js/pull/1617 |
|
1151 |
var needsFinallyFix = (function() { |
|
1152 |
var count = 0; |
|
1153 |
try{ |
|
1154 |
try { } |
|
1155 |
finally { |
|
1156 |
count++; |
|
1157 |
throw new Error('needsFinallyFixTest'); |
|
1158 |
} |
|
1159 |
} catch (e) {} |
|
1160 |
|
|
1161 |
return count !== 1; |
|
1162 |
})(); |
|
1163 |
|
|
1164 |
/** |
|
1165 |
Provides try { } finally { } functionality, while working |
|
1166 |
around Safari's double finally bug. |
|
1167 |
|
|
1168 |
```javascript |
|
1169 |
var tryable = function() { |
|
1170 |
someResource.lock(); |
|
1171 |
runCallback(); // May throw error. |
|
1172 |
}; |
|
1173 |
var finalizer = function() { |
|
1174 |
someResource.unlock(); |
|
1175 |
}; |
|
1176 |
Ember.tryFinally(tryable, finalizer); |
|
1177 |
``` |
|
1178 |
|
|
1179 |
@method tryFinally |
|
1180 |
@for Ember |
|
1181 |
@param {Function} tryable The function to run the try callback |
|
1182 |
@param {Function} finalizer The function to run the finally callback |
|
1183 |
@param {Object} [binding] The optional calling object. Defaults to 'this' |
|
1184 |
@return {*} The return value is the that of the finalizer, |
|
1185 |
unless that value is undefined, in which case it is the return value |
|
1186 |
of the tryable |
|
1187 |
*/ |
|
1188 |
|
|
1189 |
if (needsFinallyFix) { |
|
1190 |
Ember.tryFinally = function(tryable, finalizer, binding) { |
|
1191 |
var result, finalResult, finalError; |
|
1192 |
|
|
1193 |
binding = binding || this; |
|
1194 |
|
|
1195 |
try { |
|
1196 |
result = tryable.call(binding); |
|
1197 |
} finally { |
|
1198 |
try { |
|
1199 |
finalResult = finalizer.call(binding); |
|
1200 |
} catch (e) { |
|
1201 |
finalError = e; |
|
1202 |
} |
|
1203 |
} |
|
1204 |
|
|
1205 |
if (finalError) { throw finalError; } |
|
1206 |
|
|
1207 |
return (finalResult === undefined) ? result : finalResult; |
|
1208 |
}; |
|
1209 |
} else { |
|
1210 |
Ember.tryFinally = function(tryable, finalizer, binding) { |
|
1211 |
var result, finalResult; |
|
1212 |
|
|
1213 |
binding = binding || this; |
|
1214 |
|
|
1215 |
try { |
|
1216 |
result = tryable.call(binding); |
|
1217 |
} finally { |
|
1218 |
finalResult = finalizer.call(binding); |
|
1219 |
} |
Also available in: Unified diff