Permalink
Browse files

continued

  • Loading branch information...
1 parent 064bcbd commit b9eb011f02f60e51655bb8475b813ea2adba2aac @bartcc bartcc committed Oct 22, 2011
Showing with 390 additions and 186 deletions.
  1. +2 −2 app/app_controller.php
  2. +18 −2 app/controllers/users_controller.php
  3. +1 −1 app/views/director_app/index.ctp
  4. +4 −1 app/views/elements/simple_json.ctp
  5. +1 −0 app/views/layouts/director_layout.ctp
  6. +25 −9 app/webroot/js/spine/app/director/application.coffee
  7. +28 −18 app/webroot/js/spine/app/director/application.js
  8. +1 −0 app/webroot/js/spine/app/director/controllers/album.coffee
  9. +1 −0 app/webroot/js/spine/app/director/controllers/album.js
  10. +8 −4 app/webroot/js/spine/app/director/controllers/album_list.coffee
  11. +9 −7 app/webroot/js/spine/app/director/controllers/album_list.js
  12. +2 −2 app/webroot/js/spine/app/director/controllers/albums_edit_view.coffee
  13. +1 −1 app/webroot/js/spine/app/director/controllers/albums_edit_view.js
  14. +19 −36 app/webroot/js/spine/app/director/controllers/albums_show_view.coffee
  15. +21 −72 app/webroot/js/spine/app/director/controllers/albums_show_view.js
  16. +5 −6 app/webroot/js/spine/app/director/controllers/gallery.coffee
  17. +5 −5 app/webroot/js/spine/app/director/controllers/gallery.js
  18. +4 −3 app/webroot/js/spine/app/director/controllers/gallery_list.coffee
  19. +8 −4 app/webroot/js/spine/app/director/controllers/gallery_list.js
  20. +7 −4 app/webroot/js/spine/app/director/controllers/sidebar.coffee
  21. +10 −6 app/webroot/js/spine/app/director/controllers/sidebar.js
  22. +34 −1 app/webroot/js/spine/app/director/models/user.coffee
  23. +40 −2 app/webroot/js/spine/app/director/models/user.js
  24. +64 −0 app/webroot/js/spine/app/director/plugins/toolbars.coffee
  25. +72 −0 app/webroot/js/spine/app/director/plugins/toolbars.js
View
@@ -45,8 +45,8 @@ function beforeFilter() {
if ($this->RequestHandler->isAjax()) {
$data = $this->getPayLoad();
if(!empty($data)) {
- //$this->log('Payload', LOG_DEBUG);
- //$this->log($data, LOG_DEBUG);
+// $this->log('Payload', LOG_DEBUG);
+// $this->log($data, LOG_DEBUG);
$data = $this->object2Array($data);
if(empty($data[$this->modelClass])) {
$this->data[$this->modelClass] = $data;
@@ -6,7 +6,7 @@ class UsersController extends AppController {
function beforeFilter() {
$this->disableCache();
- $this->Auth->allowedActions = array('login', 'logout', 'auth');
+ $this->Auth->allowedActions = array('login', 'logout', 'auth', 'ping');
$this->Cookie->name = 'TODOS';
$this->Cookie->time = 3600; // 1 hour
@@ -153,7 +153,23 @@ function delete($id = null) {
$this->Session->setFlash(__('User was not deleted', true));
$this->redirect(array('action' => 'index'));
}
-
+
+ function ping() {
+ $user = $this->Auth->user();
+ if($this->RequestHandler->isAjax()) {
+ if(!empty($this->data) && $user) {
+ $this->data['User'] = array_merge($this->data['User'], array('sessionid' => $this->Session->id(), 'success' => true));
+ $this->set('json', $this->data);
+ // $this->log('User::ping', LOG_DEBUG);
+ // $this->log($json, LOG_DEBUG);
+ $this->render(SIMPLE_JSON);
+ } else {
+ $json = array('User' => array('success' => false));
+ $json = $this->set(compact('json'));
+ $this->render(SIMPLE_JSON);
+ }
+ }
+ }
}
?>
@@ -51,7 +51,7 @@
</div>
</div>
<ul class="options hbox">
- <li class="disabled">Properties:</li>
+ <li class="disabled"></li>
<li class="opt optGallery">Gallery</li>
<li class="opt optAlbum">Album</li>
<li class="opt optUpload">Upload Photo</li>
@@ -5,5 +5,8 @@ header('Content-Type: text/x-json; charset=utf-8');
header("X-JSON: ");
$json = compact('json');
$json = $json['json'];
-echo $js->object($json);
+$json = $js->object($json);
+//$this->log('SIMPLEJSON', LOG_DEBUG);
+//$this->log($json, LOG_DEBUG);
+echo $json;
?>
@@ -57,6 +57,7 @@
echo $this->Html->script('spine/app/director/plugins/drag');
echo $this->Html->script('spine/app/director/plugins/model_extender');
echo $this->Html->script('spine/app/director/plugins/ajax_relations');
+ echo $this->Html->script('spine/app/director/plugins/toolbars');
echo $this->Html->script('spine/app/director/models/galleries_albums');
echo $this->Html->script('spine/app/director/models/albums_images');
echo $this->Html->script('spine/app/director/models/gallery');
@@ -17,25 +17,32 @@ class App extends Spine.Controller
constructor: ->
super
-
+ User.bind('pinger', @proxy @userconfirmation)
@sidebar = new SidebarView
el: @sidebarEl
+ className: 'SidebarView'
@gallery = new GalleryView
el: @galleryEl
+ className: 'GalleryView'
@album = new AlbumView
el: @albumEl
+ className: 'AlbumView'
@upload = new UploadView
el: @uploadEl
+ className: 'UploadView'
@grid = new GridView
el: @gridEl
+ className: 'GridView'
@albumsShowView = new AlbumsShowView
el: @albumsShowEl
- name: 'AlbumsShowView'
+ toolbar: 'Gallery'
+ className: 'AlbumsShowView'
@albumsEditView = new AlbumsEditView
el: @albumsEditEl
- name: 'AlbumsEditView'
+ className: 'AlbumsEditView'
@loginView = new LoginView
el: @loginEl
+ className: 'LoginView'
@vmanager = new Spine.Manager(@sidebar)
@vmanager.initDrag @vDrag,
@@ -58,15 +65,24 @@ class App extends Spine.Controller
goSleep: => @albumsShowView.activeControl?.click()
@albumsManager = new Spine.Manager(@albumsShowView, @albumsEditView)
+
+ userconfirmation: (user, json) ->
+ console.log 'Server ping has finished'
+ unless user.sessionid is json.User.sessionid
+ alert 'Invalid Session, Please login again'
+ User.shred()
+ window.location = base_url + 'users/login'
+
$ ->
window.App = new App(el: $('body'))
- User.fetch()
+ # verify current session
+ User.ping()
+
App.loginView.render User.first()
App.albumsManager.change(App.albumsShowView)
- App.albumsShowView.btnGallery.click()
- callback = ->
- App.closePanel('gallery', App.albumsShowView.btnGallery) if Gallery.count()
- App.openPanel('gallery', App.albumsShowView.btnGallery)
- App.delay callback, 1000
+# cb = ->
+# App.closePanel('gallery', App.albumsShowView.btnGallery) if Gallery.count()
+ App.openPanel('gallery', App.albumsShowView.btnGallery) unless Gallery.count()
+# App.delay cb, 1000
@@ -25,31 +25,39 @@ App = (function() {
};
function App() {
App.__super__.constructor.apply(this, arguments);
+ User.bind('pinger', this.proxy(this.userconfirmation));
this.sidebar = new SidebarView({
- el: this.sidebarEl
+ el: this.sidebarEl,
+ className: 'SidebarView'
});
this.gallery = new GalleryView({
- el: this.galleryEl
+ el: this.galleryEl,
+ className: 'GalleryView'
});
this.album = new AlbumView({
- el: this.albumEl
+ el: this.albumEl,
+ className: 'AlbumView'
});
this.upload = new UploadView({
- el: this.uploadEl
+ el: this.uploadEl,
+ className: 'UploadView'
});
this.grid = new GridView({
- el: this.gridEl
+ el: this.gridEl,
+ className: 'GridView'
});
this.albumsShowView = new AlbumsShowView({
el: this.albumsShowEl,
- name: 'AlbumsShowView'
+ toolbar: 'Gallery',
+ className: 'AlbumsShowView'
});
this.albumsEditView = new AlbumsEditView({
el: this.albumsEditEl,
- name: 'AlbumsEditView'
+ className: 'AlbumsEditView'
});
this.loginView = new LoginView({
- el: this.loginEl
+ el: this.loginEl,
+ className: 'LoginView'
});
this.vmanager = new Spine.Manager(this.sidebar);
this.vmanager.initDrag(this.vDrag, {
@@ -94,22 +102,24 @@ App = (function() {
});
this.albumsManager = new Spine.Manager(this.albumsShowView, this.albumsEditView);
}
+ App.prototype.userconfirmation = function(user, json) {
+ console.log('Server ping has finished');
+ if (user.sessionid !== json.User.sessionid) {
+ alert('Invalid Session, Please login again');
+ User.shred();
+ return window.location = base_url + 'users/login';
+ }
+ };
return App;
})();
$(function() {
- var callback;
window.App = new App({
el: $('body')
});
- User.fetch();
+ User.ping();
App.loginView.render(User.first());
App.albumsManager.change(App.albumsShowView);
- App.albumsShowView.btnGallery.click();
- callback = function() {
- if (Gallery.count()) {
- return App.closePanel('gallery', App.albumsShowView.btnGallery);
- }
- };
- App.openPanel('gallery', App.albumsShowView.btnGallery);
- return App.delay(callback, 1000);
+ if (!Gallery.count()) {
+ return App.openPanel('gallery', App.albumsShowView.btnGallery);
+ }
});
@@ -18,6 +18,7 @@ class AlbumView extends Spine.Controller
constructor: ->
super
+ @className = 'AlbumView'
#Album.bind("ajaxError", @proxy @error)
Spine.bind('change:selectedAlbum', @proxy @change)
Spine.bind('change:selectedGallery', @proxy @change)
@@ -28,6 +28,7 @@ AlbumView = (function() {
};
function AlbumView() {
this.saveOnEnter = __bind(this.saveOnEnter, this); AlbumView.__super__.constructor.apply(this, arguments);
+ this.className = 'AlbumView';
Spine.bind('change:selectedAlbum', this.proxy(this.change));
Spine.bind('change:selectedGallery', this.proxy(this.change));
}
@@ -1,7 +1,7 @@
Spine ?= require("spine")
$ = Spine.$
-class Spine.AlbumList extends Spine.Controller
+class AlbumList extends Spine.Controller
elements:
'.optCreate' : 'btnCreate'
@@ -35,6 +35,7 @@ class Spine.AlbumList extends Spine.Controller
Album.current(selected)
Spine.trigger('change:selectedAlbum', selected)
+ Spine.trigger('change:toolbar', 'Album')
exposeSelection: (list) ->
for id in list
@@ -61,12 +62,15 @@ class Spine.AlbumList extends Spine.Controller
click: (e) ->
console.log 'AlbumList::click'
item = $(e.target).item()
- Spine.trigger('change:selection', item.constructor.className) unless @isCtrlClick(e)
-
+
if App.hmanager.hasActive()
@openPanel('album', App.albumsShowView.btnAlbum)
item.addRemoveSelection(Gallery, @isCtrlClick(e))
+
+ Spine.trigger('change:selected', item.constructor.className) unless @isCtrlClick(e)
+ Spine.trigger('change:toolbar', item.constructor.className)
+
@change item
dblclick: (e) ->
@@ -77,4 +81,4 @@ class Spine.AlbumList extends Spine.Controller
item = $(e.target).item()
@change item
-module?.exports = Spine.AlbumList
+module?.exports = AlbumList
@@ -1,4 +1,4 @@
-var $;
+var $, AlbumList;
var __hasProp = Object.prototype.hasOwnProperty, __extends = function(child, parent) {
for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; }
function ctor() { this.constructor = child; }
@@ -11,7 +11,7 @@ if (typeof Spine === "undefined" || Spine === null) {
Spine = require("spine");
}
$ = Spine.$;
-Spine.AlbumList = (function() {
+AlbumList = (function() {
__extends(AlbumList, Spine.Controller);
AlbumList.prototype.elements = {
'.optCreate': 'btnCreate'
@@ -44,7 +44,8 @@ Spine.AlbumList = (function() {
Album.current(selected);
}
}
- return Spine.trigger('change:selectedAlbum', selected);
+ Spine.trigger('change:selectedAlbum', selected);
+ return Spine.trigger('change:toolbar', 'Album');
};
AlbumList.prototype.exposeSelection = function(list) {
var id, item, _i, _len, _results;
@@ -75,13 +76,14 @@ Spine.AlbumList = (function() {
var item;
console.log('AlbumList::click');
item = $(e.target).item();
- if (!this.isCtrlClick(e)) {
- Spine.trigger('change:selection', item.constructor.className);
- }
if (App.hmanager.hasActive()) {
this.openPanel('album', App.albumsShowView.btnAlbum);
}
item.addRemoveSelection(Gallery, this.isCtrlClick(e));
+ if (!this.isCtrlClick(e)) {
+ Spine.trigger('change:selected', item.constructor.className);
+ }
+ Spine.trigger('change:toolbar', item.constructor.className);
return this.change(item);
};
AlbumList.prototype.dblclick = function(e) {
@@ -96,5 +98,5 @@ Spine.AlbumList = (function() {
return AlbumList;
})();
if (typeof module !== "undefined" && module !== null) {
- module.exports = Spine.AlbumList;
+ module.exports = AlbumList;
}
@@ -45,7 +45,7 @@ class AlbumsEditView extends Spine.Controller
change: (item, mode) ->
console.log 'AlbumsEditView::change'
- @current = item if !(item?.destroyed)
+ @current = item unless item?.destroyed
@render @current
render: (item) ->
@@ -92,4 +92,4 @@ class AlbumsEditView extends Spine.Controller
return if(e.keyCode != 13)
@trigger('save:gallery', @)
-module?.exports = AlbumsView
+module?.exports = AlbumsEditView
@@ -126,5 +126,5 @@ AlbumsEditView = (function() {
return AlbumsEditView;
})();
if (typeof module !== "undefined" && module !== null) {
- module.exports = AlbumsView;
+ module.exports = AlbumsEditView;
}
Oops, something went wrong.

0 comments on commit b9eb011

Please sign in to comment.