Skip to content

Commit

Permalink
v1 file & folder structres
Browse files Browse the repository at this point in the history
  • Loading branch information
bcinarli committed Oct 2, 2015
1 parent 23c2e7f commit 8f7d584
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 184 deletions.
4 changes: 4 additions & 0 deletions dist/uxrocket.modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/* @author Bilal Cinarli */
/** -------------------------------------------
Modal
------------------------------------------- **/
File renamed without changes.
File renamed without changes.
File renamed without changes.
90 changes: 5 additions & 85 deletions lib/_uxrocket-modal.scss
Original file line number Diff line number Diff line change
@@ -1,88 +1,8 @@
/* @author Bilal Cinarli */
$modal-version: "0.6.0";
//@import "../vendors/colorbox/colorbox";
$modal-version: 1.0.0;

// User Style:
// Change the following styles to modify the appearance of Colorbox. They are
// ordered & tabbed in a way that represents the nesting of the generated HTML.
#cboxOverlay{

}

#colorbox{

}

#cboxContent{
background:#fff;
}

.cboxIframe{
background:#fff;
}

#cboxError{
padding:50px;
border: none;
}

#cboxLoadedContent{
padding: 10px;
}

#cboxTitle{

}

#cboxCurrent{

}

#cboxLoadingGraphic{
background: url("../images/loading.gif") center no-repeat;
}

/* these elements are buttons, and may need to have additional styles reset to avoid unwanted base styles */
#cboxPrevious, #cboxNext, #cboxSlideshow, #cboxClose { }

/* avoid outlines on :active (mouseclick), but preserve outlines on :focus (tabbed navigating) */
#cboxPrevious:active, #cboxNext:active, #cboxSlideshow:active, #cboxClose:active { }

#cboxSlideshow{

}

#cboxPrevious,
#cboxNext {

}

#cboxPrevious{

&:hover {}
}

#cboxNext{
&:hover {}
}

#cboxClose {
position:absolute;
top:3px;
right:3px;
@include dims(30px);
@extend .icon-cross !optional;
overflow: hidden;
display: block;
background-color: #ccc;
text-indent: 0;

&:hover {}

&:before {
@extend %font-icon !optional;
display: block;
padding: 5px 8px;
color: #fff;
}
/** -------------------------------------------
Modal
------------------------------------------- **/
.uxr-modal {
}
8 changes: 3 additions & 5 deletions lib/uxrocket-modal.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
/* @author Bilal Cinarli */

/** -------------------------------------------
------------------------------------------- **/
// Output wrapper for dist folder. If you want to use scss file
// you can import the partial file to your project
@import "_uxrocket-modal";
230 changes: 136 additions & 94 deletions lib/uxrocket.modal.js
Original file line number Diff line number Diff line change
@@ -1,133 +1,175 @@
/**
* UX Rocket
* Modal Plugin
* UX Rocket Modal
* jQuery based modal
* @author Bilal Cinarli
*
* @dependency jQuery Colorbox
*/

;
(function($) {

var ux, // local shorthand
(function(factory) {
'use strict';
if(typeof define === 'function' && define.amd) {
// AMD. Register as an anonymous module.
define(['jquery'], factory);
} else if(typeof exports === 'object' && typeof require === 'function') {
// Browserify
factory(jQuery);
} else {
// Browser globals
factory(jQuery);
}
}(function($) {
var ux,
rocketName = 'uxrModal',

defaults = {
maxWidth : '90%',
maxHeight : '90%',
openOnload: false,

onReady : false,
onOpen : false,
onLoad : false,
onComplete: false,
onCleanup : false,
onClosed : false
className: '',
href : '',
width : '',
height : '',
maxWidth : '',
maxHeight: '',

onReady : false,
onOpen : false,
onClose : false,
onRemove: false
},

events = {
click : 'click.' + rocketName,
open : 'uxropen.' + rocketName,
close : 'uxrclose.' + rocketName,
ready : 'uxrready.' + rocketName,
resize: 'uxrresize.' + rocketName
},

ns = {
prefix : 'uxr-',
rocket : 'uxRocket',
data : rocketName,
name : 'modal',
classes: {
overlay : 'overlay',
container: 'container',
content : 'content'
}
};

var Modal = function(el, options, selector) {
var $el = $(el),
opts = $.extend({}, defaults, options, $el.data(), {'selector': selector});
this._name = rocketName;
this._defaults = defaults;

callback(opts.onReady);
this.el = el;
this.$el = $(el);
this.options = $.extend(true, {}, defaults, options, this.$el.data());
this.selector = selector;

/**
* cbox event should defined as
* onEvent: function() { event function callback }
* our data event string reformatted to the function callback
*/
opts.onOpen = reformatCBoxEvents(opts.onOpen);
opts.onLoad = reformatCBoxEvents(opts.onLoad);
opts.onComplete = reformatCBoxEvents(opts.onComplete);
opts.onCleanup = reformatCBoxEvents(opts.onCleanup);
opts.onClosed = reformatCBoxEvents(opts.onClosed);
this.init();
};

opts.className = 'uxitd-modal';
Modal.prototype.init = function() {
var uxrocket = this.$el.data(ns.rocket) || {};

$el.data('uxModal', opts);
// register plugin data to rocket
uxrocket[ns.data] = {hasWrapper: false, ready: utils.getClassname('ready'), selector: this.selector, options: this.options};
this.$el.data(ns.rocket, uxrocket);

// init colorbox
if($el.length == 0) {
$.colorbox(opts);
}
else {
if(opts.openOnload == true){
$.colorbox(opts);
}
$el.colorbox(opts);
}
this.bindUIActions();

this.emitEvent('ready');
};

var reformatCBoxEvents = function(event) {
if(event !== false && typeof event === 'string') {
var fn = window[event.replace('()', '')];
Modal.prototype.bindUIActions = function() {
this.$el.on(events.click, function() {

if(fn !== 'undefined') {
event = function() {
fn();
};
}
}
});
};

Modal.prototype.open = function() {

return event;
};

// global callback
var callback = function(fn) {
// if callback string is function call it directly
if(typeof fn === 'function') {
fn.apply(this);
}
Modal.prototype.close = function() {

};

Modal.prototype.resize = function() {

};

Modal.prototype.emitEvent = function(which) {
this.$el.trigger(events[which]);
};

var utils = {
callback: function(fn) {
// if callback string is function call it directly
if(typeof fn === 'function') {
fn.apply(this);
}

// if callback defined via data-attribute, call it via new Function
else {
if(fn !== false) {
var _fn = /([a-zA-Z._$0-9]+)(\(?(.*)?\))?/.exec(fn),
_fn_ns = _fn[1].split('.'),
_args = _fn[3] ? _fn[3] : '',
func = _fn_ns.pop(),
context = _fn_ns[0] ? window[_fn_ns[0]] : window;

for(var i = 1; i < _fn_ns.length; i++) {
context = context[_fn_ns[i]];
}

return context[func](_args);
}
}
},

// if callback defined via data-attribute, call it via new Function
else {
if(fn !== false) {
var func = new Function('return ' + fn);
func();
getStringVariable: function(str) {
var val;
// check if it is chained
if(str.indexOf('.') > -1) {
var chain = str.split('.'),
chainVal = window[chain[0]];

for(var i = 1; i < chain.length; i++) {
chainVal = chainVal[chain[i]];
}

val = chainVal;
}

else {
val = window[str];
}

return val;
},

getClassname: function(which) {
return ns.prefix + ns.name + '-' + ns.classes[which];
}
};

ux = $.fn.modal = $.uxmodal = function(options) {
ux = $.fn.modal = $.fn.uxrmodal = $.uxrmodal = function(options) {
var selector = this.selector;

// direct call to colorbox
if(typeof this === "function") {
// direct call to dialog
if(typeof this === 'function') {
Modal(null, options, null);
}

return this.each(function() {
var $el = $(this),
uxrocket = $el.data('uxRocket') || {},
modal;

if($el.hasClass('uxitd-modal-ready')) {
if($.data(this, ns.data)) {
return;
}

$el.addClass('uxitd-modal-ready');

uxrocket['uxModal'] = {'hasWrapper': false, 'ready': 'uxitd-modal-ready', 'selector': selector, 'options': options};

$el.data('uxRocket', uxrocket);
modal = new Modal(this, options, selector);
// Bind the plugin and attach the instance to data
$.data(this, ns.data, new Modal(this, options, selector));
});
};

// Public methods
ux.close = function() {
return $.colorbox.close();
};

ux.resize = function(options) {
return $.colorbox.resize(options);
};

ux.remove = function() {
return $.colorbox.remove();
};
ux.version = '1.0.0';

// version
ux.version = "0.8.0";
// settings
ux.settings = defaults;
})(jQuery);
}));
Loading

0 comments on commit 8f7d584

Please sign in to comment.