Skip to content

Instantly share code, notes, and snippets.

@nerdsrescueme
Created January 16, 2012 17:30
Show Gist options
  • Save nerdsrescueme/1621928 to your computer and use it in GitHub Desktop.
Save nerdsrescueme/1621928 to your computer and use it in GitHub Desktop.
cms
/**
* CMS Functionality
*
* @author Frank Bardon, Jr. <frank@nerdsrescue.me>
* @version 0.1
*/
var CMS = CMS || {};
CMS.editing = false;
CMS.regions = null;
CMS.modules = null;
CMS.control = null;
CMS.drawer = null;
CMS.UI = (function(CMS, $) { return {
init: function() { },
activate: function(flag) {
CMS.editing = (flag != 'undefined' ? flag : CMS.editing);
if(CMS.editing) {
// Setup
} else {
// Teardown
}
return CMS.editing;
}
}; }(CMS, jQuery));
CMS.Dialog = (function (CMS, $) { return {
init: function() {
this.html = null;
this.modal = $('#cms-modal');
this.content = $('#cms-modal-content', this.modal);
this.loading = $('#cms-modal-loading', this.modal);
this.triggers = $('a[rel="dialog"]').overlay({
closeOnClick: false,
mask: '#000',
effect: 'apple',
top: 'center',
onBeforeLoad: function() {
CMS.Dialog.loading(true);
CMS.Dialog.load(this.getTrigger().attr('href'));
},
onLoad: function() {
CMS.Dialog.loading(false);
CMS.Dialog.open();
CMS.Dialog.content.fadeIn();
},
onBeforeClose: function() {
CMS.Dialog.content.fadeOut();
},
onClose: function() {
CMS.Dialog.close();
}
});
},
loading: function(flag) {
flag ? this.loading.fadeIn() : this.loading.fadeOut();
},
load: function(href) {
this.html = this.content.load(href);
return this.html;
},
close: function() {
this.html = null;
this.content.html('');
},
open: function() {
this.content.html(this.html);
}
},
}; }(CMS, jQuery));
$(function() {
CMS.control = $('#cms-control');
CMS.drawer = $('#cms-drawer', this.control);
CMS.regions = $('.cms-region, .cms-global');
CMS.modules = $('.cms-module');
CMS.UI.init();
CMS.Dialog.init();
/*CMS.control.on('click', 'a[rel="dialog"]', function(event) {
CMS.Dialog.open(this);
return false;
});*/
CMS.control.on('click', 'a[rel="edit-page"]', function(event) {
CMS.editing ? CMS.UI.activate(false) : CMS.UI.activate(true);
return false;
});
// Create drag and droppables from drawer...
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment