Oct

07

Application Framework Infidelity

2 comments    print    email    feed   Javascript , Code

On the whole, I tend to be fairly loyal in media technologies.  I do what I can to support Adobe --I use ColdFusion, the Adobe Creative Suite , and I have even blogged several posts about Adobe's cool javascript framework, Spry .  However, sometimes loyalty doesn't cut it.  Every once and a while one will run across a problem that requires a certain solution, and said solution cannot be had in such a way that loyalty can be maintained.

Such happened to me recently.  I have been developing an application at work that will be using a drag-and-drop feature.  Being the loyal Adobe fan that I am, I went immediately to Adobe's Spry framework to search out an answer.  Unfortunately, Spry does not currently include drag-and-drop functionality.  As an aside, this is not something accidental.  I found a thread from a few months back (Spry 1.5 era) in which this functionality was requested.  The powers-that-be responded that they did not see enough use cases in which this kind of functionality would be needed.  Although the thread participants presented a good number of suggested use-cases, Spry 1.6 is conspicuously missing this functionality.  

So...what do you do when your go-to framework doesn't have what you need?  You cheat on your lover.  

For a while, I have known about (and...shhh!...) used MooTools ' extremely fun framework.  It is simple to implement and has a lot of fun special effects stuff.  For regular visitors to this site, you may have seen it in action on the green circles in the logo of this site (go ahead, you can grab them).  So anyway, I checked out the actual drag and drop functionality...it worked great!  

Here is the code that I used to instantiate the drag functionality:

function startDrag() {
    var fx = [];
    $$('#draggables div').each(function(drag){
        new Drag.Move(drag);
    });
}



Pretty simple, eh?

Then, I wanted to be able to let the user add x number of draggable elements, so I created another function that would add an additional div with a class of whichever color the user selects:



function createShape(color) {
    var newDiv = document.getElementById('draggables');
    var myCode = document.createElement("DIV");
        myCode.setAttribute('class',color)
        newDiv.appendChild(myCode);
        startDrag();
}



This function is very simple.  It accepts a single argument, "color".  It then identifies the parent element (here "draggables" div) and creates a new childNode div with a class of the argument that is passed to function.  (I have additional CSS rules to determine the attributes of each created div class.)  Finally, I reinvoke the startDrag() function to apply the drag to the newly created element.

I still really love Spry, especially for the data management side of things, but MooTools has some really incredible effects.  Maybe Spry will get their act together on 1.7 and include some cooler effect widgets like drag-and-drop. 

Oh yeah, forgot to mention:  this code will soon be part of an interesting little thing I'm cooking up for this site, so stay tuned! 

Click here to see an example of this code in action:

 


Recent Posts
  • A Feedreader with Spry

    I know I've been posting alot about Spry lately, but the more I use it, the more I love it! Using the simple-to-implement tools which Spry provides, I am able to spend more time dealing with server-... [more]


  • Making All Things New

    And He who sits on the throne said, "Behold, I am making all things new."

    In an age in which global warming, climate change and concerns about the viability of our planet's environment ar... [more]


  • Quick Post: blogactionday.org Reminder

    Just a quick reminder: blogactionday (October 15) is approaching rapidly--next Monday! This is a day where bloggers are encouraged to devote a posting to the environment, regardless of their views o... [more]


  • Application Framework Infidelity

    On the whole, I tend to be fairly loyal in media technologies. I do what I can to support Adobe --I use ColdFusion, the more]


  • CD Review - Emery's "I'm Only a Man"

    Within the last six months, my little brother has introduced me to some seriously cool music. One of my favorite bands from this "education" is Emery, a hard-hitting "screamo" band hailing from the ... [more]


  • A Little Taste of Spry 1.6 Goodness

    A few days I blogged about Adobe's release (and sexy-fication) of the javascript framework Spry 1.6. While I have not had a lot of time to play around with the absolutely unique elements, some cool ... [more]


  • Peacocke Tuesday - Randomness and Causality

    Over the last week, I have rolled through several chapters of Peacocke's book, "Theology for a Scientific Age," and I will not spend time going over the finer details of each discussion. I simply wi... [more]


  • A New Day, A New Spry

    Recently, I have blogged about how incredibly cool Adobe's javascript framework---Spry---is and what potential it has for making great dynamic web content. In those posts, I was talking about Spry p... [more]


  • A New Communion Experience

    Growing up in the Wesleyan Church, I've not had tremendously moving experiences with the celebration of communion. In the Wesleyan Church--as in many others--communion is served (by Discipline requi... [more]


  • CD Review - Rascal Flatt's "Still Feels Good"

    Since their self-titled debut in 2000, Rascal Flatts has consistently and with ever-growing force become a presence within the country-pop crossover music scene to be reckoned with. Boasting such awa... [more]


Extra Stuff
/*/ About Me

Welcome to my blog. I am often asked what "Exist/Dissolve" means. Well, that is certainly a good question, and I am currently in the process of discovering the answer myself. Prima facie, it strikes me as encapsulating the existensial crisis that is our lives as finite, contingent beings. For a brief moment, we exist, and the next we dissolve into the nothingness of non-existence. From a theological perspective, it is, for me, a sort of ad hoc apologetic for resurrection - i.e., if to exist/dissolve is the human dilemma, there is nothing inherent to the person that guarantees existence, either now or "after" death. Therefore, resurrection is at the same time both the height of absurdity (for it is a notion entirely alien to the paradigm of existence to which we are naturally enculturated) and the only hope for the human to persevere beyond the pale of death.

Do Something

/*/ My Awards

/*/ Non-Hostiles
/*/ Browser Happiness
/*/ Syndication

Syndicated feed of existdissolve.com

Semi-often podcast
(coming soon!)