This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp.HAS_AUTH = SC.State.design({ | |
initialSubstate: 'SHOWING_APP', | |
SHOWING_APP: SC.State.design({ | |
substates: [ | |
SC.State.design({ | |
enterState: function() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp.statechart = SC.Statechart.create({ | |
trace: YES, | |
rootState: SC.State.design({ | |
initialSubstate: 'CHECKAUTH', | |
CHECKAUTH: SC.State.plugin('MyApp.CHECK_AUTH'), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> var c = SC.Object.create({ foo: "bar" }); | |
undefined | |
> c | |
SC.Object {__sc_super__: Object, _kvo_cloned: null, foo: "bar", _observers: Array[0], outlets: Array[0]…} | |
> var d = JSON.stringify(c) | |
undefined | |
> var e = JSON.parse(d) | |
undefined | |
> e | |
Object {__sc_super__: Object, _kvo_cloned: null, foo: "bar", _observers: Array[0], outlets: Array[0]…} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Faces.SinatraDataSource = SC.DataSource.extend( | |
/** @scope Faces.SinatraDataSource.prototype */ { | |
// .......................................................... | |
// QUERY SUPPORT | |
// | |
fetch: function(store, query) { | |
if (query == Faces.PEOPLE_QUERY) { | |
SC.Request.getUrl('/people').header({'Accept': 'application/json'}).json() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApp.PhpDataSource = SC.DataSource.extend({ | |
queryQueries: function(query) { | |
var url, callback = ""; | |
if (query == MyApp.FIRST_QUERY) { | |
url = "/books"; | |
callback = "didFetchBooks"; | |
} | |
else if (query == MyApp.SECOND_QUERY) { | |
url = "/test"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
toolbarBeltView: SC.GridView.design({ | |
layout: { centerX: 0, height: 56, width: 68 * MyApp.toolbarMenuItemsController.get('length') }, | |
columnWidth: 68, | |
rowHeight: 56, | |
classNames: ['header-background'], | |
contentBinding: 'MyApp.toolbarMenuItemsController.arrangedObjects', | |
exampleView: SC.View.design(SC.Control, { | |
childViews: 'textLabelView imageLabelView' . w(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
${1}: SC.LabelView.design({ | |
layout: { width: ${2}, height: ${3}, left: ${4}, top: ${5} }, | |
value: '${6}' | |
}) | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>sclabel</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<snippet> | |
<content><![CDATA[ | |
${1}: SC.TextFieldView.design({ | |
layout: { width: ${2}, height: ${3}, left: ${4}, top: ${5} }, | |
isTextArea: ${6:'NO'} | |
}) | |
]]></content> | |
<!-- Optional: Set a tabTrigger to define how to trigger the snippet --> | |
<tabTrigger>sctext</tabTrigger> | |
<!-- Optional: Set a scope to limit where the snippet will trigger --> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var validator = require('validator'); | |
var hankaku = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '; | |
var zenkaku = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ '; | |
var zenkakuToHankaku = function (word) { | |
for (var i = 0, n = zenkaku.length; i < n; i++) { | |
word = word.replace(new RegExp(zenkaku[i], 'gm'), hankaku[i]); | |
} | |
return word.replace(/^\s+|\s+$/g, ''); // trim head and tail white space | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Server side, BarController | |
module.exports = { | |
foo: function (req, res) { | |
res.view('foo'); | |
}, | |
save: function (req, res) { | |
Bar.create({ | |
name: 'bar' |
OlderNewer