Skip to content

Instantly share code, notes, and snippets.

View elidupuis's full-sized avatar

Eli Dupuis elidupuis

View GitHub Profile
@elidupuis
elidupuis / component.json
Last active August 29, 2015 14:00
Combining Cordova deviceready and domready in a Component(1) app
{
"locals": [
"foobar"
],
"dependencies": {
"jb55/domready": "*"
},
"scripts": [
"index.js"
]
@elidupuis
elidupuis / README.md
Last active August 29, 2015 14:00
Cordova cross platform configuration gotchas

Cordova handles A LOT of cross platform issues for us, but not all of them. We can simplify these by using a YML or JSON config file to keep track of the differences so our code can stay slim and maintainable.

This concept is based on this article which I found from this SO answer.

@elidupuis
elidupuis / web-intent.js
Created May 13, 2014 03:23
Simple Cordova WebIntent test function
// https://github.com/InQBarna/WebIntent
function testIntent () {
console.log('testIntent...');
if (window.device) {
console.log('DEVICE mode; testing web intent: startActivity');
var address = 'edmonton alberta';
CDV.WEBINTENT.startActivity({
action: CDV.WEBINTENT.ACTION_VIEW,
@elidupuis
elidupuis / reload-hasmany.js
Created December 5, 2014 21:12
Dynamically reload all hasMany relationships for a model.
/**
* You can use this in a model or afterModel hook...
* see http://emberjs.com/api/data/classes/DS.Model.html#method_eachRelationship
*
* Not really tested or sure if this is a good idea... just had the thought and wanted to record it.
*/
model.eachRelationship(function(name, relationship) {
if (relationship.kind === 'hasMany' && relationship.options.async) {
this.get(name).reload();
}
@elidupuis
elidupuis / application.js
Created April 20, 2015 15:39
Inject your Ember Application object into other parts of your app.
// app/intializers/application.js
/**
* Expose the Application object to all Routes, Controllers, and Services.
* This is a simple way to gain access to things like `application.verison`...
*/
export function initialize(container, application) {
application.inject('route', 'application', 'application:main');
application.inject('controller', 'application', 'application:main');
application.inject('service', 'application', 'application:main');
}
@elidupuis
elidupuis / foo.js
Last active August 29, 2015 14:22
Ember inject POJO
// app/initializers/foo.js
var POJO = {
bar: 'this is your POJO'
// whatever you need here
// this can also be import from another file...
};
export function initialize(container, application) {
application.register('pojo:main', POJO, { instantiate: false, singleton: true });
@elidupuis
elidupuis / controllers.application.js
Created August 19, 2015 05:19
link-to active state
import Ember from 'ember';
export default Ember.Controller.extend({
appName:'Ember Twiddle'
});
@elidupuis
elidupuis / component.js
Last active September 1, 2015 17:42
Closure action not bubbling to Route; controller is not define...
// components/split-view/component.js
actions: {
showUserPopover() {
// Ember.debug('showUserPopover action from split-view');
// Getting error: `An action named 'showUserPopover' was not found in (generated classes controller).`
// got same result using closure action instead of `sendAction`
this.sendAction('showUserPopover');
}
}
$('#slideshow').qCycle({
toLoad: images,
cycleOpts: {
fx: 'fade',
timeout: 3*1000,
pager: '#pagers'
},
createSlide: function (img) {
var data = img.data('qCycle.slideData');
var slide = $('<div>').addClass('slide').append($(img).attr('alt',data.title));
(function($) {
$.fn.thePlugin = function(options) {
// build main options before element iteration:
var opts = $.extend({}, $.fn.thePlugin.defaults, options);
var $this = $(this);
var thePlugin = {
index: 0,