Good Luck ;)
Lately I'm experimenting with Backbone.js together with a REST API and krpano. Backbone has models, views, collections and routes
for instance I can say:
|
Source code
|
1
2
|
var hotspot = new HotspotView({model: new Hotspot()});
hotspot.render()
|
or even simpeler:
var hotspot = new Hotspot({ath: 10, atv: 10});
|
Source code
|
1
2
3
|
hotspots.add(hotspot); //add it to collection which has hooks to auto render a hotspot in krpano
hotspots.save() //save all hotspots through a REST API directly in the database.
//or just save 1 hotspots, hotspot.save()
|
And it autogenerates a hotspot within krpano, with a random name and default values and styles.
I dont want a hotspot? Easy
|
Source code
|
1
2
|
hotspot.remove() //removes it from collection
hotspot.destroy() //remove from collection and database
|
this ofcourse alsoo works with View, Display (which has checks to updateobject()) and Plugins.
Since it's all javascript, binding a jquery ui slider to for instance the x/y or ath/atv values of a hotspot is a piece of cake. I bind the slider change event to update the Hotspot model. The hotspot model listens to changes, and updates krpano automagicly.
|
Source code
|
1
|
hotspot.set({url: 'test.png', ath: 0, atv: 100, customproperty: 'cake', customobject: {yup: 'even nested object'}}
|
Next to that. Collections allows me to filter real quick. Just show hotspots within a certain ath range? Or all hotspots that open a panorama, or just all hotspots with visible false. Just a few lines
|
Source code
|
1
2
3
|
var visible_hotspots = hotspots.filter(function(hotspot) {
return hotspot.get("visible") === true;
});
|
This allows me to work MVC and OOP with krpano. I can create tiny plugins or define hotspots that open popups, locations, videos, galleries etc and create a whole reusuable library.
It's the basis of my CMS now.
Real fun stuff :) I get exited just talking about it